Open MilanKral opened 3 years ago
AFAICT it's unambiguous so I'm not too fussed about it.
If someone wants to look into having stricter rules for indentation levels
in Idris.Parser
's letBinder
I won't oppose it.
The token following the =
is not checked at all. The token after that one is checked. I initially fixed this when I did #3350, but I found that there are a dozen places in the Idris compiler and library code that rely on the faulty parsing. Those are easy to fix, but I was afraid that a lot of code in the wild would rely on that too.
For example, in Data.Seq.Internal
:
viewRTree (Deep s pr m (One z)) =
let tr =
case viewRTree m of
The fix is:
diff --git a/src/Idris/Parser.idr b/src/Idris/Parser.idr
index fd941c347..d833017b5 100644
--- a/src/Idris/Parser.idr
+++ b/src/Idris/Parser.idr
@@ -831,6 +831,7 @@ mutual
ty <- option (PImplicit (virtualiseFC $ boundToFC fname s))
(decoratedSymbol fname ":" *> typeExpr (pnoeq pdef) fname indents)
(decoratedSymbol fname "=" <|> decoratedSymbol fname ":=")
+ continue indents
val <- typeExpr pnowith fname indents
alts <- block (patAlt fname)
pure (MkLetBinder rig pat ty val alts)
Steps to Reproduce
The following code is accepted in Idris2
but the following code is not accepted in GHC:
Expected Behavior
Because
1000
starts on the same column asz =
there should be an error message. Idris 2 should only accept the following code as correct.Observed Behavior