on master help sign in
Add error for type+alternatives as suggested
commita1ce5232ee6434f61b6f19db9e63c95793e62481 authorMelvar Chen <Melvar.Chen@gmail.com> dateFri 22 Dec 2017, 06:36 (9 years ago) parent2cc9ee5
1 file changed+5−7
src/Idris/Parser/Expr.hs+5−7
src/Idris/Parser/Expr.hs+5−7
@@ -1295,13 +1295,11 @@ do_ syn
12951295 reservedOp "="
12961296 (e, fc) <- withExtent $ expr (syn { withAppAllowed = False })
12971297 -- If there is an explicit type, this can’t be a pattern-matching let, so do not parse alternatives
1298− case ty' of
1299− Just ty -> return (DoLet fc RigW i ifc ty e)
1300− Nothing ->
1301− P.option (DoLet fc RigW i ifc Placeholder e)
1302− (do lchar '|'
1303− ts <- P.sepBy1 (do_alt (syn { withAppAllowed = False })) (lchar '|')
1304− return (DoLetP fc (PRef ifc [ifc] i) e ts)))
1298+ P.option (DoLet fc RigW i ifc (fromMaybe Placeholder ty') e)
1299+ (do lchar '|'
1300+ when (isJust ty') $ fail "a pattern-matching let may not have an explicit type annotation"
1301+ ts <- P.sepBy1 (do_alt (syn { withAppAllowed = False })) (lchar '|')
1302+ return (DoLetP fc (PRef ifc [ifc] i) e ts)))
13051303 <|> P.try (do keyword "let"
13061304 i <- expr' syn
13071305 reservedOp "="