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
Reduced the issue to a self-contained, reproducible test case.
Description
The parser does not accept:
example : Id Nat := dolet x ← if true then
pure 1else
pure 2
pure x
It requires an extra level of indentation:
example : Id Nat := dolet x ←
if true then
pure 1else
pure 2
pure x
Can we do something to the withPosition stuff for if to support this case? This is tricky because one-sided if is legal in that position (which is part of a do notation, even though the possible productions are limited). My suggested interpretation would be for the if to expect the else to be aligned with the let, if both are on the same line. (Banning one-sided if there is also reasonable since the let x <- part is guaranteed superfluous in that case seeing as it would bind an element of Unit.)
Note that there is no issue with this indentation pattern with let x := if ... else because in this case the if ... else is parsed as an expression and not a do seq item so the else is mandatory and does not need to be aligned in any particular way.
I would suggest a new parser combinator withPositionAfterLinebreak that applies withPosition only if checkLinebreakBefore succeeded. That would allow if to fall back to the let's position if they are on the same line. I can implement it if that sounds right.
Prerequisites
Description
The parser does not accept:
It requires an extra level of indentation:
Can we do something to the
withPosition
stuff forif
to support this case? This is tricky because one-sidedif
is legal in that position (which is part of a do notation, even though the possible productions are limited). My suggested interpretation would be for theif
to expect theelse
to be aligned with thelet
, if both are on the same line. (Banning one-sidedif
there is also reasonable since thelet x <-
part is guaranteed superfluous in that case seeing as it would bind an element ofUnit
.)Note that there is no issue with this indentation pattern with
let x := if ... else
because in this case theif ... else
is parsed as an expression and not a do seq item so theelse
is mandatory and does not need to be aligned in any particular way.Versions
Lean (version 4.0.0-nightly-2022-04-16, commit 726b735c6df7, Release)
The text was updated successfully, but these errors were encountered: