Compare commits

...

1 Commits

Author SHA1 Message Date
Leonardo de Moura
56c95028d0 fix: match_expr parser
closes #3989
closes #3990
2024-04-27 16:37:49 -07:00
5 changed files with 13 additions and 1 deletions

View File

@@ -870,7 +870,7 @@ def matchExprElseAlt (rhsParser : Parser) := leading_parser "| " >> ppIndent (ho
def matchExprAlts (rhsParser : Parser) :=
leading_parser withPosition $
many (ppLine >> checkColGe "irrelevant" >> notFollowedBy (symbol "| " >> " _ ") "irrelevant" >> matchExprAlt rhsParser)
>> (ppLine >> checkColGe "irrelevant" >> matchExprElseAlt rhsParser)
>> (ppLine >> checkColGe "else-alternative for `match_expr`, i.e., `| _ => ...`" >> matchExprElseAlt rhsParser)
@[builtin_term_parser] def matchExpr := leading_parser:leadPrec
"match_expr " >> termParser >> " with" >> ppDedent (matchExprAlts termParser)

3
tests/lean/3989_1.lean Normal file
View File

@@ -0,0 +1,3 @@
def foo (ty : Expr) : MetaM Expr :=
match_expr ty with
| Nat => sorry

View File

@@ -0,0 +1 @@
3989_1.lean:4:0: error: expected else-alternative for `match_expr`, i.e., `| _ => ...`

6
tests/lean/3989_2.lean Normal file
View File

@@ -0,0 +1,6 @@
def foo (ty : Expr) : MetaM Expr :=
match_expr ty with
| Nat => sorry
| BitVec n => sorry
#check Nat

View File

@@ -0,0 +1,2 @@
3989_2.lean:6:0: error: expected else-alternative for `match_expr`, i.e., `| _ => ...`
Nat : Type