Open auduchinok opened 5 years ago
Wait, doesn't in
introduce scope? Shouldn't the last line x
be out of scope for x
?
(I admit I'm not sure of this, I use the in
syntax rarely)
@abelbraaksma It does, and its scope should be x + 1
here.
Edit, I may misunderstand the scoping here, as this seems to work ~properly~ well, it works, not sure of "properly":
let _ =
let x = 1 in 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):
I'd expect it to be parsed as:
do
(let x = 1 in (x + 1));
x
And the latter x
would be unresolved.
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
@dsyme How bad would be changing the parsing rules here?
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.In addition to the unexpected tree form it also creates a wrong scope for
x
.AST viewer