You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Area-Compiler-Syntaxlexfilter, indentation and parsingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.
The contents of do in the following code should be parsed as a sequence of let expression and x, but it's parsed as let expression in sequence of the sum and x.
doletx=1in x +1
x
In addition to the unexpected tree form it also creates a wrong scope for x.
Edit, I may misunderstand the scoping here, as this seems to work properly well, it works, not sure of "properly":
let_=letx=1in x +2
x // in scope?
And if I take your code and paste it in VS, it correctly seems to say for each line that you're returning a value when you should return unit. But it appears to get the line number wrong for the second error.
If I remove the in it still gets the line number wrong (maybe not related to this issue):
This is a long-standing issue and I think there are various duplicates of it. I suspect the right approach here is to start raising warnings when this formulation is used
Still present in F# 10.0 (FSI 14.0.105.0, commit 632a0ab, repo as of 2026-03-25).
The parser treats let x = e1 in e2 followed by e3 on a new line as let x = e1 in (e2; e3) instead of (let x = e1 in e2); e3. This means x remains in scope in e3 when it should not be, and e3 is silently included in the let-body rather than following it in sequence.
Exact repro (script file):
// x should be unbound after the let...in... expression, but it is notletresult=letx=5in x +1
x // expected: FS0039 (x not defined); actual: compiles, result = 5
printfn "result=%d" result // prints 5 (x's value), not 6 (x+1)
```
**Output:**
```
/path/test.fsx(3,18): warning FS0020: The result ofthisexpressionhastype'int'andis implicitly ignored. ...result=5
The warning fires on x + 1 at col 18 (inside the incorrectly-extended let body). result is 5 — the value of x — rather than 6 (x + 1) or a compile error. The correct parse would give result = 6 if x is the last expression in the body, but under the correct grouping (let x = 5 in x+1); x the final x should be FS0039.
Because it would be consistent with other indentation rules, which is now not the case.
Consider this code:
leta=1in b
c
In this example b begins a new block and normally it requires the same indentation to be continued on subsequent lines. c is not indented enough to be in that block, however it unexpectedly continues it.
The only case where I'd expect it to be there is something like this:
Area-Compiler-Syntaxlexfilter, indentation and parsingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Activity
abelbraaksma commentedon Jul 23, 2020
Wait, doesn't
inintroduce scope? Shouldn't the last linexbe out of scope forx?(I admit I'm not sure of this, I use the
insyntax rarely)auduchinok commentedon Jul 23, 2020
@abelbraaksma It does, and its scope should be
x + 1here.abelbraaksma commentedon Jul 23, 2020
Edit, I may misunderstand the scoping here, as this seems to work
properlywell, it works, not sure of "properly":And if I take your code and paste it in VS, it correctly seems to say for each line that you're returning a value when you should return
unit. But it appears to get the line number wrong for the second error.If I remove the

init still gets the line number wrong (maybe not related to this issue):auduchinok commentedon Jul 23, 2020
I'd expect it to be parsed as:
And the latter
xwould be unresolved.dsyme commentedon Aug 25, 2020
This is a long-standing issue and I think there are various duplicates of it. I suspect the right approach here is to start raising warnings when this formulation is used
auduchinok commentedon Sep 1, 2020
@dsyme How bad would be changing the parsing rules here?
github-actions commentedon Mar 25, 2026
🤖 This is an automated response from Repo Assist.
Still present in F# 10.0 (FSI 14.0.105.0, commit
632a0ab, repo as of 2026-03-25).The parser treats
let x = e1 in e2followed bye3on a new line aslet x = e1 in (e2; e3)instead of(let x = e1 in e2); e3. This meansxremains in scope ine3when it should not be, ande3is silently included in the let-body rather than following it in sequence.Exact repro (script file):
The warning fires on
x + 1at col 18 (inside the incorrectly-extended let body).resultis5— the value ofx— rather than6(x + 1) or a compile error. The correct parse would giveresult = 6ifxis the last expression in the body, but under the correct grouping(let x = 5 in x+1); xthe finalxshould beFS0039.Martin521 commentedon Mar 27, 2026
The example in the OP looks correct to me.
Why should
be different from
or
Fix issue reference in release notes: #7091 -> #7741
Fix issue reference in release notes: #7091 -> #7741
auduchinok commentedon Apr 15, 2026
Because it would be consistent with other indentation rules, which is now not the case.
Consider this code:
In this example
bbegins a new block and normally it requires the same indentation to be continued on subsequent lines.cis not indented enough to be in that block, however it unexpectedly continues it.The only case where I'd expect it to be there is something like this:
Fix issue reference in release notes: #7091 -> #7741
Fix issue reference in release notes: #7091 -> #7741
Fix issue reference in release notes: #7091 -> #7741
Fix issue reference in release notes: #7091 -> #7741