Skip to content

Commit

Permalink
fix: validate atoms modulo leading and trailing whitespace
Browse files Browse the repository at this point in the history
Closes #6011
  • Loading branch information
david-christiansen committed Nov 8, 2024
1 parent c779f3a commit 2c372e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Lean/Elab/Syntax.lean
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ where
processAtom (stx : Syntax) := do
match stx[0].isStrLit? with
| some atom =>
unless isValidAtom atom do
unless isValidAtom atom.trim do
throwErrorAt stx "invalid atom"
/- For syntax categories where initialized with `LeadingIdentBehavior` different from default (e.g., `tactic`), we automatically mark
the first symbol as nonReserved. -/
Expand Down
4 changes: 4 additions & 0 deletions tests/lean/242.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ syntax "0" : term
syntax "'a'" : term
syntax "`a" : term
syntax "\"a" : term
syntax " 0" : term
syntax " 'a'" : term
syntax " `a" : term
syntax " \"a" : term
4 changes: 4 additions & 0 deletions tests/lean/242.lean.expected.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
242.lean:2:7-2:12: error: invalid atom
242.lean:3:7-3:11: error: invalid atom
242.lean:4:7-4:12: error: invalid atom
242.lean:5:7-5:11: error: invalid atom
242.lean:6:7-6:13: error: invalid atom
242.lean:7:7-7:12: error: invalid atom
242.lean:8:7-8:13: error: invalid atom

0 comments on commit 2c372e9

Please sign in to comment.