Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composed function leads to unexpected indentation warning #10852

Closed
nojaf opened this issue Jan 8, 2021 · 4 comments
Closed

Composed function leads to unexpected indentation warning #10852

nojaf opened this issue Jan 8, 2021 · 4 comments
Labels
Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@nojaf
Copy link
Contributor

nojaf commented Jan 8, 2021

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

@cartermp cartermp added Area-Compiler Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. labels Jan 17, 2021
@cartermp cartermp added this to the Backlog milestone Jan 17, 2021
@baronfel
Copy link
Member

baronfel commented Feb 1, 2021

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

@nojaf
Copy link
Contributor Author

nojaf commented Feb 5, 2021

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

@dsyme
Copy link
Contributor

dsyme commented Jul 5, 2021

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

@dsyme
Copy link
Contributor

dsyme commented Aug 24, 2021

Fixed in #11772

@dsyme dsyme closed this as completed Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
None yet
Development

No branches or pull requests

4 participants