Commit aacd612
authored
feat: forbid non-reserved identifiers via
This PR makes `withForbidden` stop a term at a non-reserved word used as
an identifier, not just at a registered token. A parser like
`withForbidden "invariant" termParser` now ends the term when it reaches
a bare `invariant`, while `invariant` remains usable as an identifier
everywhere else.
`identFn` rejects an identifier whose text is in `forbiddenTks`,
mirroring the forbidden-token check in `mkTokenAndFixPos`. The check is
guarded by `forbiddenTks.isEmpty`, so the common identifier path is
unchanged.
We considered putting a unified check in `tokenFn` or `mkIdResult`, but
decided against that. The former would move the check outside the cache
and regress some benchmarks by ~1%. The latter forces a flag on
`mkIdResult` and `identFnAux` because `nameLitAux` and `rawLitFn` must
not forbid any tokens.withForbidden (#14432)1 parent 49ac957 commit aacd612
2 files changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1295 | 1295 | | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | | - | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1299 | 1312 | | |
1300 | 1313 | | |
1301 | 1314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments