Repository navigation
test: preserve import attribute statement boundaries - #72
Merged
Merged
Conversation
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Keep the scanner's ASI behavior and cover attributes, invalid unseparated with statements, explicit separators and incremental edits. Co-authored-by: WillBooster (Codex CLI) <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
Import/re-export attributes and a following
withstatement share a keyword. A newline beforewith (must not silently terminate the declaration: ECMAScript ASI inserts before an offending token, andwithis already a permitted WithClause continuation. V8 rejects this unseparated form.Requirements
Customer Summary
Regression coverage preserves import attributes and detects invalid statement boundaries while checking explicitly separated statements and incremental edits.
Technical Summary
A public Wasm test covers five import/re-export forms and seven existing trivia forms, including HTML comments. It checks erroneous unseparated
with (forms, attribute objects, explicit-semicolon controls, following declarations and edits in both directions. Production scanner, grammar and node schema match main.Testing
bun wb verify --full test/unit/importAttributeBoundary.test.ts test/unit/corpus.test.ts test/unit/incremental.test.tspasses. V8 rejects both import and re-export newline-with-parenthesis forms; TypeScript rejects import forms syntactically but treats re-export forms as strict-mode-invalid statements. The ECMAScript ASI and WithClause productions support keeping the existing scanner behavior. Full platform and sanitizer checks run in CI.Notes
Review established that the proposed scanner relaxation accepted invalid boundaries, so this PR retains the original implementation and adds regression coverage. Strict-mode early errors and module-only HTML-comment restrictions remain outside the existing grammar contract.