You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reject reserved words used as identifiers / bindings / shorthand
The Ident token deliberately lexes keywords as identifiers, so any reserved word
could fall back to a bare identifier — letting invalid code through (often by
splitting a statement in two). Add zero-width guards before identifier positions:
- notReserved: the always-reserved set (break/case/catch/class/.../void/while/with),
valid as an identifier in NO context. Placed before the bound name in Binding,
ForBinding, BindingElement, ArrayBindingElement rest, Param rest, BindingProperty
shorthand, and the Prop shorthand. (BindingProperty was split so a reserved word
stays valid as a KEY `{ while: y }` while the bound name is guarded.)
- notReservedExpr: a NARROWER set (catch/delete/enum/throw/typeof/void) for the
expression identifier-NUD. The full set can't be used there — most reserved words
legitimately begin an expression via their own forms (new/class/function/import/
super/this/...), and TS error-recovery slides a few into the identifier fallback.
These five have no expression role, so forbidding their fallback rejects
`catch(x){}` with no try, and the operatorless prefix ops `void ;`/`typeof ;`/
`delete ;`/`throw ;`.
FN-safe by construction: a reserved word is never a valid binding name; KEYS,
member/method names, property access, and import/export specifiers use other rules
and are unaffected. A plain param name is left unguarded so `function f(this, a)`
(implicit-any this-param) still parses. Strict-only (let/static/...) and conditional
(await/yield) words stay valid since a CFG can't see the mode.
FP 88->80 (8 cases: keyword bindings/shorthand + operatorless prefix ops + catch-no-try),
FN stays 0 (3376/3376), TP unchanged, highlighter 99.3% unchanged. agnostic 5/5,
refactor-guard 112/112. Artifacts regenerated.
(Two sibling fixes from the same batch were dropped: class-body-statements needed an
invasive heritage-clause rewrite; the type-alias-name guard regressed type-name
highlighting — both deferred.)
0 commit comments