diff options
| author | tingerrr <me@tinger.dev> | 2023-11-07 12:14:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-07 12:14:20 +0100 |
| commit | 5f922abfd840425f347b7b86b1d0d81e489faf8d (patch) | |
| tree | 833978f733e761e625334224a51462039866b64f /crates/typst-syntax/src/parser.rs | |
| parent | 241a6d9e5aa36c41e1f3be8a75a769e2ce98f7fb (diff) | |
Add hints for invalid identifier errors (#2583)
Diffstat (limited to 'crates/typst-syntax/src/parser.rs')
| -rw-r--r-- | crates/typst-syntax/src/parser.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/typst-syntax/src/parser.rs b/crates/typst-syntax/src/parser.rs index f1c798c6..9397952f 100644 --- a/crates/typst-syntax/src/parser.rs +++ b/crates/typst-syntax/src/parser.rs @@ -1685,7 +1685,14 @@ impl<'s> Parser<'s> { if at { self.eat(); } else if kind == SyntaxKind::Ident && self.current.is_keyword() { - self.expected_found(kind.name(), self.current.name()); + let found_text = self.current_text(); + let found = self.current.name(); + self.expected_found(kind.name(), found); + self.hint(eco_format!( + "{} is not allowed as an identifier; try `{}_` instead", + found, + found_text + )); } else { self.balanced &= !kind.is_grouping(); self.expected(kind.name()); |
