Repository navigation
fix!: restrict class heritage expressions and preserve recovery boundaries - #145
Merged
Merged
Conversation
Co-authored-by: WillBooster (Codex) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex) <agent@willbooster.com>
…tions Co-authored-by: WillBooster (Codex) <agent@willbooster.com>
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.
Why
ECMAScript's ClassHeritage production takes a left-hand-side expression. Published 15.0.1 accepts
class C extends B < 1 {}andclass C extends B + D {}without errors, although Node 24 rejects them. Correct the operand category and preserve the following declarations in the unfinished-heritage example reported inWillBooster/tree-sitter#224.Requirements
extends B<example, including incremental edits.Customer Summary
Invalid operator operands in class heritage produce errors. Parenthesized expressions, constructors, calls, optional chains and JSX heritage remain supported, and the reported incomplete comparison keeps its following declarations separate.
Technical Summary
Heritage has a recursive reference-only graph; shared atom/call/member/subscript factories keep the ordinary expression productions unchanged. Transparent aliases preserve expression/primary query ancestry. The stateless
_class_heritage_endtoken preserves the local recovery boundary, defers async function continuations, and lets slash comments remain lexer extras while emitting HTML comments as existing extras. Heritage atom identifiers distinguish await keywords from identifiers; dedicated heritage-only identifier tokens prevent context-reserved await/yield from falling back to ordinary identifiers without changing property-name or constructor handling. Both parser goals are regenerated canonically, without serialization or runtime-cost changes.Testing
bun run verifyand canonicalbun run build-wasmpassed.12106977561683125466. Full suites remain with PR CI.Notes
Source grammars inheriting the external-symbol list must append
CLASS_HERITAGE_END,CLASS_HERITAGE_YIELD_IDENTIFIERandCLASS_HERITAGE_AWAIT_IDENTIFIERafterLINE_BREAK_BEFORE_FROMbefore their own symbols, and implement the end guard if they inheritclass_heritage. Superclass syntax extensions must use the heritage-specific atom/call/member/subscript rules; ordinary expression extensions alone do not widen that graph. The public runtime language ABI and serialized scanner state are unchanged. Current TypeScript main imports its own vendored JavaScript grammar and pins npm JavaScript 11.0.0, so its published package is unaffected; adopting this source requires separate scanner alignment.Retained code-gauge errors in touched code are
src/scanner.cfile NCSS (1044) and scanner dispatcher complexity/size (130/133). Fixing them requires a broader scanner refactor or mechanically moving cohesive logic between files. The end guard's NCSS warning (36) remains because it is one lookahead-character dispatch; threshold-only splitting would scatter that decision. No exclusions were added.