Skip to content

Commit 5c33602

Browse files
authored
fix: add term elaborator for Lean.Parser.Term.namedPattern (#4792)
closes #4662
1 parent 204d483 commit 5c33602

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Lean/Elab/BuiltinTerm.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,7 @@ private opaque evalFilePath (stx : Syntax) : TermElabM System.FilePath
362362
mkStrLit <$> IO.FS.readFile path
363363
| _, _ => throwUnsupportedSyntax
364364

365+
@[builtin_term_elab Lean.Parser.Term.namedPattern] def elabNamedPatternErr : TermElab := fun stx _ =>
366+
throwError "`<identifier>@<term>` is a named pattern and can only be used in pattern matching contexts{indentD stx}"
367+
365368
end Lean.Elab.Term

tests/lean/run/4662.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/--
2+
error: `<identifier>@<term>` is a named pattern and can only be used in pattern matching contexts
3+
p@()
4+
-/
5+
#guard_msgs in
6+
def minimal : Unit -> Unit := by
7+
intro i
8+
let k:p@() := i
9+
sorry
10+
11+
def minimal2 : Unit -> Unit := by
12+
intro i
13+
let p@k:() := i
14+
guard_hyp k : p = ()
15+
exact ()

0 commit comments

Comments
 (0)