Skip to content

fix!: parse grouped declarations without final semicolons - #63

Merged
exKAZUu merged 2 commits into
mainfrom
fix/grouped-declaration-terminators
Nov 1, 2026
Merged

exKAZUu merged 2 commits into
mainfrom
fix/grouped-declaration-terminators

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Why

Valid Go such as const ( A = 1 ) and var ( B = 2 ) produces an error node because both grouped declaration rules require a final terminator. The Go specification permits omitting a semicolon before ), and Go 1.27.3 compiles these declarations.

Requirements

  • required: Improve full parsing using the fork's issues and important upstream issues, pull requests, and recent changes, without preserving backward compatibility.
  • required: Keep each distinct warranted issue in a dedicated pull request based on the latest main branch, checking existing pull requests first.
  • required: A full parse of valid input yields a correct tree; invalid input yields ERROR or MISSING nodes, never crashes or hangs, and takes linear time.
  • required: Run review-booster and complete-pr concurrently, then release through merge and publication verification.
  • chosen: Reuse the existing optional trailing separator helper for constant and variable groups because it already implements this syntax for grouped type declarations.

Customer Summary

Grouped constant and variable declarations accept an omitted final semicolon before the closing parenthesis.

Technical Summary

Use optionalTrailingSep in both declaration rules and regenerate the profiled parser. Extend three existing corpus inputs to omit the final terminator. Update the expected recovery tree for an existing malformed string while retaining its error node. The breaking marker covers that recovery-tree change. Remove the pinned Go compiler fixture bug123.go from expected parse failures: it contains the supported grouped constant form, and Go's syntax parser accepts its complete source.

The upstream type-declaration fix in tree-sitter/tree-sitter-go commit e25214e92f1e997940a3bd2f3ced2a2ddf7f027f uses the same helper; constant and variable groups need the same treatment.

Testing

  • bun run verify passed; code-gauge reported no violations in changed code.
  • bun wb test test/unit/corpus.test.ts passed all 79 corpus cases. The three edited declaration cases failed before the grammar fix.
  • bun wb test test/unit/examples.test.ts passed the pinned real-world parse baseline, with 133 expected failures across 19,898 files.
  • Go 1.27.3 compiled empty, single-entry, multiple-entry, implicit-constant, typed-variable, and function-local declaration groups; the generated parser produced the expected declaration owners and ranges.
  • Missing separators between adjacent declarations still produce ERROR nodes.
  • Pull request CI passed Test, Test Rust, Robustness, and PR-title validation, including native/Wasm parsing, generation reproducibility, and sanitizer fuzzing.

exKAZUu and others added 2 commits November 1, 2026 18:06
Allow the last constant or variable specification before a closing
parenthesis to omit its terminator, using the existing separated-list rule.
Keep regression coverage for explicit and implicit constant values and
variable declarations, and regenerate the profiled parser.

Co-authored-by: WillBooster (Codex) <agent@willbooster.com>
The pinned bug123 fixture has a grouped constant without a final
semicolon and now parses. Go's syntax parser accepts the complete file;
its expected compiler diagnostic concerns calling the integer constant.

Co-authored-by: WillBooster (Codex) <agent@willbooster.com>
@exKAZUu exKAZUu self-assigned this Nov 1, 2026
@exKAZUu
exKAZUu merged commit 6311b2c into main Nov 1, 2026
10 checks passed
@exKAZUu
exKAZUu deleted the fix/grouped-declaration-terminators branch November 1, 2026 09:19
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