feat: better error recovery for match syntax

This commit is contained in:
Leonardo de Moura 2021-05-02 16:07:27 -07:00
parent 59b1f8c143
commit 78a2de4241
3 changed files with 20 additions and 1 deletions

View file

@ -406,7 +406,9 @@ private partial def compileStxMatch (discrs : List Syntax) (alts : List Alt) : T
trace[Elab.match_syntax] "match {discrs} with {alts}"
match discrs, alts with
| [], ([], rhs)::_ => pure rhs -- nothing left to match
| _, [] => throwError "non-exhaustive 'match' (syntax)"
| _, [] =>
logError "non-exhaustive 'match' (syntax)"
pure Syntax.missing
| discr::discrs, alt::alts => do
let info ← getHeadInfo alt
let pat := alt.1.head!

View file

@ -0,0 +1,10 @@
structure C where
f1 : Nat
f2 : Bool
b1 : String
def f (x : Lean.Syntax) (y : C) : IO Nat := do
match x with
| `($a + 1) =>
if y.
--^ textDocument/completion

View file

@ -0,0 +1,7 @@
{"textDocument": {"uri": "file://matchStxCompletion.lean"},
"position": {"line": 8, "character": 9}}
{"items":
[{"label": "b1", "detail": "C → String"},
{"label": "f1", "detail": "C → Nat"},
{"label": "f2", "detail": "C → Bool"}],
"isIncomplete": true}