Skip to content

Warning only when function application is inside SynExpr.IfThenElse #10929

@nojaf

Description

@nojaf

Consider the following code example:
image

let a =
  System.Text.RegularExpressions.Regex.IsMatch(
    "myInput",
    """^[a-zA-Z][a-zA-Z0-9']+$"""
   )

if System.Text.RegularExpressions.Regex.IsMatch(
    "myInput",
    """^[a-zA-Z][a-zA-Z0-9']+$"""
   ) then
  ()

I get an indentation warning when the function call is inside the if condition.
But not when it is used in a let binding body.

Expected behavior

I would expect both cases not to show any warnings.

Actual behavior

Warning for the expression inside the if/then/else

Known workarounds

Wrap the if condition inside parenthesises.

if (System.Text.RegularExpressions.Regex.IsMatch(
     "myInput",
      """^[a-zA-Z][a-zA-Z0-9']+$"""
   )) then
  ()

Related information

Provide any related information (optional):

  • Operating system: Win 10
  • .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET 5
  • Editing Tools (e.g. Visual Studio Version, Visual Studio): FCS 38.0.0

Related Fantomas bug: fsprojects/fantomas#1349

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions