Skip to content

Composed function leads to unexpected indentation warning #10852

Closed

Description

@nojaf

Consider the following code:
image

Provide the steps required to reproduce the problem:

When (f >> g) is composed, this leads to a warning while a function call with aaaaa does not.

From an AST point of view, I don't really see why there should be a warning in the second case.

let f _ b = b 
let g _ b = b

let aaaaa<'t> = f >> g

let bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb = 42
let c = 43

aaaaa (
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
    c
)

(f >> g) (
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
    c
)
DoExpr
             (DebugPointAtBinding tmp.fsx (9,0--12,1) IsSynthetic=false,
              App
                (NonAtomic, false, Ident aaaaa,
                 Paren
                   (Tuple
                      (false,
                       [Ident
                          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
                        Ident c], [tmp.fsx (10,141--10,142) IsSynthetic=false],
                       tmp.fsx (10,4--11,5) IsSynthetic=false),
                    tmp.fsx (9,6--9,7) IsSynthetic=false,
                    Some tmp.fsx (12,0--12,1) IsSynthetic=false,
                    tmp.fsx (9,6--12,1) IsSynthetic=false),
                 tmp.fsx (9,0--12,1) IsSynthetic=false),
              tmp.fsx (9,0--12,1) IsSynthetic=false);
           DoExpr
             (DebugPointAtBinding tmp.fsx (14,0--17,1) IsSynthetic=false,
              App
                (NonAtomic, false,
                 Paren
                   (App
                      (NonAtomic, false,
                       App
                         (NonAtomic, true, Ident op_ComposeRight, Ident f,
                          tmp.fsx (14,1--14,5) IsSynthetic=false), Ident g,
                       tmp.fsx (14,1--14,7) IsSynthetic=false),
                    tmp.fsx (14,0--14,1) IsSynthetic=false,
                    Some tmp.fsx (14,7--14,8) IsSynthetic=false,
                    tmp.fsx (14,0--14,8) IsSynthetic=false),
                 Paren
                   (Tuple
                      (false,
                       [Ident
                          bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
                        Ident c], [tmp.fsx (15,141--15,142) IsSynthetic=false],
                       tmp.fsx (15,4--16,5) IsSynthetic=false),
                    tmp.fsx (14,9--14,10) IsSynthetic=false,
                    Some tmp.fsx (17,0--17,1) IsSynthetic=false,
                    tmp.fsx (14,9--17,1) IsSynthetic=false),
                 tmp.fsx (14,0--17,1) IsSynthetic=false)

Ident does not have this problem, while App does.

Expected behavior

I would not expect any warnings.

Actual behavior

(f >> g) leads to a warning.

Known workarounds

Compose before invkcing the function call.

Related information

Provide any related information (optional):

  • Operating system: Windows 10
  • .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET 5
  • Editing Tools: Rider 2020.3.2

Related Fantomas issue: fsprojects/fantomas#1341

Activity

  1. added
    Impact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.
    on Jan 17, 2021
  2. added this to the Backlog milestone on Jan 17, 2021
  3. baronfel commented on Feb 1, 2021

    @baronfel
    Member

    Here are the debug-mode errors for the offsides context for this code sample:

    /Users/chethusk/oss/scratch/script.fsx(15,5): warning FS0058: possible incorrect indentation: this token is offside of context at position (14:10), newCtxt = seqblock(first, (14:4)), stack = [paren((13:9)); seqblock(subsequent, (0:0))], newCtxtPos = (14:4), c1 = 9, c2 = 4
    
    /Users/chethusk/oss/scratch/script.fsx(15,5): warning FS0058: possible incorrect indentation: this token is offside of context at position (14:10), newCtxt = seqblock(subsequent, (14:4)), stack = [paren((13:9)); seqblock(subsequent, (0:0))], newCtxtPos = (14:4), c1 = 9, c2 = 4
    
  4. nojaf commented on Feb 5, 2021

    @nojaf
    ContributorAuthor

    It also occurs regardless of what is inside the parenthesis.
    image

  5. dsyme commented on Jul 5, 2021

    @dsyme
    Contributor

    This should be tracked by a language suggestion, but in general I agree with this change (so "approved-in-principle")

  6. dsyme commented on Aug 24, 2021

    @dsyme
    Contributor

    Fixed in #11772

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions