Skip to content

fix: accept undefined as a statement label - #71

Merged
exKAZUu merged 1 commit into
mainfrom
fix/undefined-labels
Oct 5, 2026
Merged

exKAZUu merged 1 commit into
mainfrom
fix/undefined-labels

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Why

undefined: while (true) { break undefined; } is valid JavaScript, but released 2.0.1 reports an error at the label. The lexer selects the existing named undefined token, which the label rule does not accept. This is an uncovered identifier-consumer case related to issue #51; merged #62 repaired arrow parameters and compound assignments.

Requirements

  • required: review our repositories' issues and upstream major issues, PRs and new commits.
  • required: check existing PRs for duplicates, and create a separate PR for each worthwhile unresolved item.
  • required: run review-booster and complete-pr simultaneously, then release the PR.
  • required: preserve existing public JavaScript nodes, fields, queries and incremental parsing behavior.
  • chosen: repair undefined as a label separately because Node accepts complete strict and module programs, released 2.0.1 rejects the label, and merged fix: accept undefined in identifier expression contexts #62 addressed arrow parameters and compound assignments instead.
  • chosen: extend the existing statement_identifier alias with the existing undefined token because the lexer already selects that token at label starts; a broader identifier or scanner change is unnecessary, and undefined expression nodes remain intact.
  • chosen: retain a coherent executable corpus program and one public API regression because existing corpus/query checks do not cover this label; the API asserts label fields/ranges/captures and complete fresh-versus-incremental trees during ordinary-name/undefined renames, which corpus named-node assertions cannot detect.
  • chosen: retain the label highlight assertion because the released parser already fails error/kind/capture guards, the proposed label-ID filter also misses its absent definition, and an actual statement_identifier highlight-query mutation makes the current assertion fail; replacement changes no verification outcome.
  • chosen: retain the caller-local token choice because substituting _identifier regenerates byte-identical parser and node metadata with no warning or changed caller behavior; the reported future-token drift establishes no current defect.

Customer Summary

Labels named undefined parse correctly, including labeled loops, break/continue targets, comments before the colon and escaped spellings.

Technical Summary

The existing label-name choice accepts undefined through its statement_identifier alias. Public node metadata, scanner code, external tokens and query files are unchanged. Generation adds two states, 3,726 bytes of C and 336 bytes of Wasm (0.042%).

Testing

  • Node 24.21.0 accepts the complete corpus program as Script and Module; executing it checks the loop and break/continue behavior.
  • The new API regression fails against the integrity-verified official 2.0.1 Wasm and passes with this implementation. Native parsing independently fails before and succeeds after the repair.
  • All 198 original corpus inputs retain identical full public trees, fields, flags, byte/point ranges and 9,241 configured query captures against published 2.0.1.
  • Six selected files pass verification and 20 tests in 31.4 seconds: 199 native/Wasm corpus cases, 1,000 seeded incremental iterations, public queries, error-recovery performance and the new rename API regression.
  • All ten exact-head CI checks passed, including the full test job, Linux/macOS jobs, Rust bindings and fuzzing. Complete-pr readiness passed on a63eab4 with no new events. Independent review da1fb252 completed seven successful sessions on this exact head; last reviewed and completion heads match. Completion coverage is reviewed (at least one successful exploration); all seven recorded exploration windows are complete at Requirements v1, and v2 retains disputed decisions without source changes. Its two reports were individually rejected on executable evidence. Reviewer notes disclose missing ignored Wasm artifacts, sandbox/cache/SDK and Cargo limitations; local verification and exact-head CI provide separate evidence. A local capacity-related progress-write failure was retained, and the same run continued to completion.

Notes

The grammar's existing undefined expression node remains distinct from label identifiers. This change does not address the separate function-context, legacy call-target or artifact-size issues #55/#58/#59. The public API regression compares syntax and query output rather than executing supplied JavaScript. Nine local warmed CPU samples on 1,500 retained ordinary labeled functions measured medians of 18.3 ms before and 19.5 ms after; the repaired-label workload fell from 44.2 ms with recovery to 10.7 ms. These variable local measurements do not establish a general speed guarantee.

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@exKAZUu exKAZUu self-assigned this Oct 5, 2026
@exKAZUu
exKAZUu merged commit 7d64aaf into main Oct 5, 2026
12 checks passed
@exKAZUu
exKAZUu deleted the fix/undefined-labels branch October 5, 2026 16:45
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