Skip to content

fix(frontend): resolve 0.7.1 parser recovery, attribution, and completion gaps - #2

Merged
SuperIceCN merged 7 commits into
masterfrom
fix/0.7.1
Nov 22, 2026
Merged

SuperIceCN merged 7 commits into
masterfrom
fix/0.7.1

Conversation

@SuperIceCN

Copy link
Copy Markdown
Owner

Summary

Complete R1–R5 of the GDParser 0.7.1 gap-fix plan. The plan inventories 30 tracked GDScript issues, finalizes the recovery decisions, and distinguishes fixes from behavior already present in the baseline that now has stronger tests. The implementation aligns syntax checks with upstream Godot while keeping the Java parser's ability to preserve a usable AST for malformed input.

  • R1: Preserve expression and type damage. Carry lexical and structural damage through Pratt folding, lists, containers, specialized prefixes, and lambda signatures. Closed containers can retain damaged children and still allow outer operators and suffixes to parse; Lua-style dictionary keys are checked consistently when their surface syntax is complete. Preserve partial types in casts and type tests, and resume at in after a damaged for iterator type when the header boundary permits it.
  • R2: Protect delimiters and bound recovery work. Match local delimiters by kind and return real ancestor closers and unshielded commas to their owners. BracketBalanceOracle scans once per input stream using tokenizer-aligned literal boundaries. Kind-indexed poisoned-bracket unwinding uses O(1) bookkeeping and replaces at most one unmatched layer at a time without raising the depth budget. A local lambda-header state machine and bounded match colon shielding keep inner syntax from consuming the outer branch boundary. Unpaired Dictionary type commas still yield to the outer owner.
  • R3: Attribute diagnostics by position and protect block boundaries. Distinguish statement tails, suites, class bodies, and lambda bodies; preserve diagnostics from discarded fragments through authorized fallbacks to surviving owners. Isolate rejected property accessors and emit one primary diagnostic per bad accessor. Recover a dictionary value on the physical line where its key ends, and hand off a trusted cross-line -> only after a damaged signature.
  • R4: Align syntax guards with Godot. Keep pending target annotations across standalone warning-region directives without changing flat AST source order or scope eligibility; meter PendingAnnotation work with constant-time scope isolation. Give the first nested-class extends precedence, even when its target is malformed. Suppress derivative invalid-target errors for RecoveredInfixExpression without relaxing lvalue or direct-call checks. Reject bare lambdas used as statements, including parenthesized and multiply grouped forms, while preserving valid lambda values, arguments, and .call() uses.
  • R5: Lock behavior and complexity. Add positive and negative coverage for lexing, strict and tolerant parsing, diagnostic ownership, UTF-8 coordinates, real AST traversal and S-expression round trips, and completion via both the facade and the empty-AST token fallback. Exercise LF/CRLF, Unicode, EOF, and parser reuse. Measure actual work at 256, 512, 1,024, and 2,048 units for scanning, recovery, completion, and diagnostic fallback; check one oracle scan per input stream and that all three parser stacks return to baseline.

Behavior and contract changes

  • Package-private ParseOutcome now has five states: Ok, Missing, Failed, Damaged, and EnclosedDamage. EnclosedDamage marks a structurally complete value with damaged children; Damaged marks unenclosed damage. Remove isOk() and valueOrNull(). Type parsing now returns ParseOutcome<ParsedType> instead of inferring success from diagnostic counts.
  • DiagnosticCodes and RecoveryLink allow recovered cast and type-test diagnostics to bind to type.argument. Repeated nested-class inheritance uses the dedicated parse.class.duplicate_extends diagnostic on class.extends. UNEXPECTED_CLOSER retains its code and binds by position to statement.trailing, suite.body, or class.body; ancestor closers keep their existing owners, and truly ownerless top-level closers remain unlinked.
  • STATEMENT_TOO_MANY_ERRORS binds to suite.body when a suite host survives, including a lambda. Missing-expression slot diagnostics in discarded lambda defaults can fall back to the surviving function.signature or signal.parameter where registered. The position-aware I5 gate checks that every error has a registered code and that links point to reachable owners and valid facets in the same parse. All known baseline I5 violations are covered and eliminated; truly ownerless errors and independent lexical errors remain allowed.
  • AST retention does not make malformed syntax valid. The strict entry point continues to reject errors. Public AST shapes, S-expression formats, and the legacy completion API are unchanged. UTF-8 AST byte ranges remain half-open; public token columns count code points.

Affected packages

  • dev.superice.gdparser.frontend.gdscript: parser, tokenizer, completion, recovery, diagnostics, and tests.
  • dev.superice.gdparser.frontend.ast and dev.superice.gdparser.frontend.serialize: traversal and serialization tests.
  • doc/: gap inventory, architecture decisions, recovery contracts, and verification records.

Validation

  • ./gradlew clean build --no-daemon --info --console=plain at b99cb5e: 2,072 tests across 26 classes passed, with 0 failures, 0 errors, and 0 skipped.
  • Linux targeted Gradle test runs (test --tests, via the local targeted-test wrapper): R1 505 tests across 5 classes; R2 1,628 across 5; R3 1,684 across 7; R4 639 across 6; R5 1,957 across 16, followed by 1,452 across 4 after review. All passed without failures, errors, or skips.
  • All five implementation phases passed two independent reviews. Phase-level results are recorded in the gap-fix plan.

…ge 1-6 record

- Map the status of the 30 parser, recovery, and completion issues against the current baseline
- Describe root causes, target behavior, and missing test coverage for each open gap
- Define phased remediation steps, validation gates, and open design decisions
- Archive the completed stage 1-6 plan and its execution history as a historical reference
- Add `ParseOutcome.EnclosedDamage` so closed containers retain child damage while Lua-key validation and Pratt folding stay aligned
- Propagate lexical and structural header damage through Pratt operators, specialized prefixes, and lambda signatures without cascading secondary diagnostics
- Return `ParseOutcome<ParsedType>` from type parsing across all callers, drop `diagBefore` checks, and add `type.argument` owner fallback for `as`/`is`
- Synchronize `for` headers to `in` after any non-`Ok` type outcome within header boundaries, including explicit line continuations
- Sync recovery design docs and expand recovery, invariant, and serde regression tests
- Pair local openers by kind during recovery sync while yielding ancestor closers and unshielded outer commas
- Align bracket oracle literal boundaries with the tokenizer and propagate non-closer line-indent minima in O(1)
- Balance poisoned bracket chains by kind with single-layer replacement, safe inner-frame resume, and recovery-window colon guards
- Lock generic dictionary comma precedence (3A) and add four-tier linear scaling and recovery/completion regressions
- Record R2 completion status and validation summary in the 0.7.1 fix plan
…k boundaries

- Attribute orphan closers by position across statement tails, suites, class bodies, and ownerless top level while respecting semicolons and ancestor ownership
- Link discarded duplicate-parameter lambda defaults, class-body fragments, and suite circuit breakers (4B-A) to surviving owners and enforce full position-aware I5 checks
- Emit a single primary diagnostic per rejected property accessor while isolating indented/inline bodies, comma handoff, and lambdaEnded state
- Use the dictionary key physical end line for same-line value recovery and hand off trusted cross-line return arrows only on damaged signatures
- Sync R3 status and recovery contract docs
…edup, and bare lambdas

- Keep pending target annotations intact across standalone directives while preserving flat AST source order, script-root eligibility, and O(1) scoped buffer isolation
- Accept consecutive nested class body-head and inline semicolon-separated extends with first-wins precedence and CLASS_DUPLICATE_EXTENDS on class.extends
- Suppress derivative ASSIGNMENT_INVALID_TARGET on RecoveredInfixExpression targets while preserving surface lvalue and call guards
- Reject parenthesized and nested bare lambda statements uniformly via LAMBDA_BARE_STATEMENT on the enclosing ExpressionStatement
- Sync R4 status and metered linear-work validation summary in the 0.7.1 fix plan
… gates

- Add package-private read-only step counters without changing production behavior or public APIs
- Expand lexer, parser, strict, recovery, real-AST serde/walker, and dual-entry completion matrices
- Verify UTF-8 half-open ranges, I5 same-parse owner/facet attribution, and six renamed tests
- Enforce four-tier (256-2048) linear bounds across lexing, recovery, completion, and fallback chains
Copilot AI balanced review requested due to automatic review settings November 22, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@SuperIceCN
SuperIceCN merged commit 0e6164b into master Nov 22, 2026
4 checks passed
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.

3 participants