Skip to content

Commit

Permalink
fix: add term elaborator for Lean.Parser.Term.namedPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
leodemoura committed Jul 19, 2024
1 parent a94805f commit 8b2db11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Lean/Elab/BuiltinTerm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,7 @@ private opaque evalFilePath (stx : Syntax) : TermElabM System.FilePath
mkStrLit <$> IO.FS.readFile path
| _, _ => throwUnsupportedSyntax

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

end Lean.Elab.Term
15 changes: 15 additions & 0 deletions tests/lean/run/4662.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/--
error: `<identifier>@<term>` is a named pattern and can only be used in pattern matching contexts
p@()
-/
#guard_msgs in
def minimal : Unit -> Unit := by
intro i
let k:p@() := i
sorry

def minimal2 : Unit -> Unit := by
intro i
let p@k:() := i
guard_hyp k : p = ()
exact ()

0 comments on commit 8b2db11

Please sign in to comment.