Repository navigation
Decorators are parsed by the grammar: @ a, @a . b, @℘ accepted as tsc does; the decorator scope covers only @name - #209
Merged
Conversation
…egments and arguments are the grammar's (transplanted from land/grammar-decorators 5632dcd onto the rewritten history; regenerated) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… sizes re-recorded Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e literals): floors and P10 lists re-measured Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/COMPLETENESS.md # test/portable-recovery.ts # typescriptreact.tmLanguage.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The single-token
Decoratorpattern (@then an optionalname(.name | .#name | .)*) made a decorator'sshape a lexer decision: trivia after
@or around a.broke it (@ a class C {},@a . b class C {}),a name with a character beyond ASCII was no token (
@℘ class C {},@a.℘ class C {}), and the tokenswallowed a trailing
.and a bare@(@a. class C {},@ class C {},@() class C {}wereaccepted). tsc's parser accepts the first four and rejects the last three; the decorators proposal's
productions (
Decorator : @ DecoratorMemberExpression | @ DecoratorParenthesizedExpression | @ DecoratorCallExpression,DecoratorMemberExpression : IdentifierReference | DecoratorMemberExpression . IdentifierName | DecoratorMemberExpression . PrivateIdentifier) put every one of those tokens apart.Change (javascript.ts, typescript.ts):
@and ONE IdentifierName (ASCII and\uescapes, as before). It stays a tokenso the three highlighters keep the decorator scope on
@name.@is also a literal: a@that triviaor a non-ASCII character separates from its name lexes alone, then an Ident.
@ ( Expression ), or a head (the Decorator token, or@and anIdentifierReference) then
(. IdentifierName | . PrivateIdentifier)*and optional arguments.@new), or@and a non-reserved name or aparenthesized expression, then the LeftHandSideExpression tails as before;
@new Xis the fused@newtoken or@new.@too.Verdicts (interpreter JS / TS, before -> after; tsc):
@ a class C {}r/r -> A/A (tsc A);@a . b class C {}r/A -> A/A (A);@℘ class C {}r/r -> A/A (A);@a.℘ class C {}r/r -> A/A (A);@a. class C {}A/A -> r/r (r);@ class C {}A/A -> r/r (r);@() class C {}A/A -> r/r (r);@ new x class C {}-/A (A). Unchanged:@a,@a.b.c,@a.#p,@a(1),@(e),@new x(TS),@a.b(1).c(TS A, JS r: not a DecoratorMemberExpression),@a[0]r.Witnesses: test/js-conformance.ts (valid JS), test/portable-cases.ts TS_DECORATORS (every engine).
Highlighter changes (TextMate, Monarch, tree-sitter; expected): the decorator scope covers
@nameonly:in
@a.b.cthe.b.cis now an accessor and properties, as in any member expression (before, thewhole
@a.b.cwas one decorator-scoped token); a lone@is punctuation (punctuation.js/ts,Monarch
delimiter, tree-sitter@punctuation.delimiter). Monarch's JavaScript rules list thedelimiter rule before the parenthesis rule (an ordering of disjoint rules). The regex-start contexts
gain
@(after@an operand may start:@(…)).Records moved (re-measured on the rewritten history, master 3587831 merged in): the ECMAScript lexer goldens
(test/golden/lexer: the Decorator token and the
@literal re-derived in the frozen specs; 4 cases per golden, eacha lone
@that is now the literal); lex-family's Decorator read bounds (a failed attempt now reads an escape:failRead Infinity) and its failed-attempts list (+ Decorator); treesitter-assertions reserved-set +1 per grammar
(the
@ namearm's reserved guard); decision pages (no new ties or dead arms).Recovery (test/portable-recovery.ts):
@joins the grammar's literals and TypeScript's decorator list gainsaccepts, so both mutant sets are drawn again (the documented procedure): the farthest-hint floors move
javascript 5412 -> 5349 (5,349 of 5,850 rejects agree, 91.4%, was 91.7%) and typescript 6051 -> 6388 (6,388 of
6,845, 93.3%). P10 lists redrawn: javascript greedy captures drop two entries no longer drawn and gain
for (of of as y);; typescript's dropfor (global of of x);and gainfor (x = (y = (a in b)) constructor c);and
for (get of of x);(each an arrow body taking a suppliedin); the lookahead-bypass and unclassified listshold none of their entries in this draw and are empty (
f(class extends a?.b{ () {});,class C { static export case type\nx = 1 },export await using from|meta x = y;are not drawn; theexport await usingkind is thegrammar's
exportlookahead admitting a Stmt: it leaves with the Statement / Declaration split). The P10 checknow names the listed entries that no longer fail.
TextMate / Monarch agreement (node test/monarch-dialect.ts --agreement): identical to the record (typescript
98.70%, javascript 99.17%). Verdict scan: unchanged. test262 and tree-sitter records: unchanged (CI green).
Profile (run 45352219814, A = merge base 3587831, M = b93592e). Work counters identical on every input (rule
calls, checkpoints, restores, peeks, leaf pushes, lex_tokens). Rust instructions (parse): checker.ts +0.42%,
typescript.js +0.54%, parser.ts +0.43%, gen-tm.ts +0.63%, typescript.d.ts +0.34%, typescript.ts +0.41%
(gen-tm.tsx +1.71%, jsx-corpus.tsx +1.26%; synthetic: synth2mb +0.50%, nonascii +0.29%, dense-* 0.00%). This is
the known lexer-layout effect, decided as accepted by the coordinator: the earlier full-scope run (45327261780)
put it in lex_into, mostly "line 0" (no source line) with the same token count: the lexer dispatch function's
register allocation after the
@punctuator joined it; three attempts to cure it failed. Go instructions (reuse):checker.ts +0.35%, gen-tm.ts +0.11%, typescript.d.ts +0.25% (builder: +0.36% / +0.12% / +0.28%), with the same
work; TS target blocks: checker.ts -0.0004%, gen-tm.ts -0.005%, typescript.d.ts -0.065%.
Emitted sizes (docs/emit-sizes.json re-recorded): what the Decorator token's pattern did is now DecoratorExpr's
arms, so the parsers move: e.g. typescript js +0.73%, go -0.66%, rust +0.12%; javascript ts -0.68%, js +1.09%,
rust -0.19% against the record. NOTE: master's record already drifted before this change (textdialect, which does
not import javascript.ts, moved ts -0.53%, go -0.30%), so part of these moves is master's earlier drift absorbed
by the re-record.
Owed:
@a℘ class C {}(tsc accepts) is still refused: the Decorator token stops at℘and the Unicode fallbackcannot take a prefixed token whose prefix is also a punctuator (lexer side). The token's name is not checked
against reserved words (
@class,@thisin JavaScript: as before).🤖 Generated with Claude Code