Skip to content

fix: stop regex flags at comment boundaries - #70

Merged
exKAZUu merged 3 commits into
mainfrom
fix/regex-flags-comment-boundaries
Oct 4, 2026
Merged

exKAZUu merged 3 commits into
mainfrom
fix/regex-flags-comment-boundaries

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Why

In #51, /[/]//*c*/instanceof value is parsed with instanceof as regex flags. Named comment extras can bypass an immediate flag token's adjacency constraint. Existing open PRs do not cover this category.

Requirements

  • required: review our repositories' issues and upstream issues, PRs and new commits, and create a separate PR for each worthwhile unresolved item after checking existing PRs for duplicates.
  • required: run review-booster and complete-pr simultaneously, then release the PR.
  • required: fix each generated-program mismatch category in issue fix: parse the inputs where a generated-program comparison with acorn finds a different structure #51 in its own PR; regular expression flags must not continue across a comment.
  • required: preserve public regex nodes, pattern/flags fields, comment nodes, source ranges and expression query membership.
  • chosen: guard the flagged closing-delimiter branch before consuming the slash, because token.immediate alone allows named comment extras before a later flag token; checking literal adjacency avoids sharing comment-consumed lexer state.
  • chosen: keep the existing flag spelling rule and public regex_flags node, because this change addresses adjacency rather than JavaScript flag semantic validation.
  • chosen: use an emitted zero-width guard without persistent scanner state and verify insertions/removals at its lookahead boundary, because incremental reuse must agree with a fresh parse after flags change.
  • chosen: cover actual block and line comment nodes and their boundaries with public Wasm ranges and corpus tests, because successful acceptance alone can hide comments or operators inside a regex node; HTML-looking text after a regex parses as operators and is not evidence for comment behavior.

Customer Summary

Comments end regex literals instead of extending their flags. Operators and later statements retain their ordinary structure and source ranges.

Technical Summary

A scanner guard checks the character immediately following the closing slash before the grammar can enter its flagged branch. Existing regex nodes, fields and flag spelling rules remain unchanged. The guard has no persistent state.

Testing

  • The new public Wasm regression fails against published 1.0.30 and passes with the fix.
  • bun run build/ci, bun run verify and five relevant test files passed (11 tests before tightening comment-node coverage; the three focused files passed again after that change), including native/Wasm corpus, incremental parsing and integrated default-export checks.
  • V8 accepts the six block/line-comment controls. Public queries assert regex ranges and flags; incremental flag edits match fresh trees.

exKAZUu and others added 2 commits October 5, 2026 04:26
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@exKAZUu exKAZUu self-assigned this Oct 4, 2026
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@exKAZUu exKAZUu changed the title fix: stop regular expression flags at comments fix: stop regex flags at comment boundaries Oct 4, 2026
@exKAZUu
exKAZUu merged commit 873fc70 into main Oct 4, 2026
11 checks passed
@exKAZUu
exKAZUu deleted the fix/regex-flags-comment-boundaries branch October 4, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant