Repository navigation
Conversation
Buffer speculative parser diagnostics until an attempt is kept, scope parser and resolver destinations, and hold validation context and listener together. Restore reporting and validation state on early returns and exceptions; initialize evaluation and source-node buffers once. Preserve current parser nesting limits and add regression coverage for nested attempts, host callback failures, resolver reuse, statement restoration and diagnostic buffer draining. Document the parser API migration and thread confinement.
lagergren
changed the base branch from
master
to
errs/c2-explicit-listeners-20261008
October 9, 2026 13:14
Contributor
Author
|
Superseded by #685. The combined PR retains scoped parser/resolver reporting and validation-state restoration, includes the newer behavioral test rewrites, and preserves the lexical-rollback correction from #684 through the active Reporting/Parser.Attempt scope. It also includes the compilation-result and cancellation APIs that consume these guarantees. Please continue review on #685. This branch and the existing review discussion are preserved; #683 and #684 remain separate prerequisites. |
ggleyzer
added a commit
that referenced
this pull request
Oct 9, 2026
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.
Summary
This is the first PR that uses the new diagnostics compatible error listeners. We will carefully introduce scoped diagnostics and the restoration of validation state, both which are absolutely necessary and hard requirements to start LSP-speculative compilation and recompilation.
Why?
The README's scoped-reporting section explains the lifetime rules, API migration and regression coverage. #680 establishes the reporting/abort contract; #681 supplies explicit destinations. This change controls how long temporary destinations remain active. An LSP wrapper cannot reliably repair private parser, resolver or AST state left behind inside a failed operation, so these guarantees belong in the compiler itself.
How?
finallyon normal, early and exceptional exits.Implications
Parser.SafeLookAheadbecomesParser.Attempt, normally opened withparser.attempt();keepResults()becomeskeep(). Java callers using the old nested class must migrate and recompile.NameResolver.getErrorListener()returns null outside an active resolution. During callbacks it exposes the current caller's non-null destination; nested resolution restores the outer caller's destination.Changes
The incremental change is 18 files: 11 production files, 6 test files and the README, with 887 additions / 175 deletions. Of the additions, 481 lines are tests.
javatools/src/main/java/org/xvm/asm/Reporting.java— new scoped diagnostic destination with restoration on exit.javatools/src/main/java/org/xvm/compiler/Parser.java— buffered attempts, diagnostic commit/discard, token rollback and scoped module-name scanning.javatools/src/main/java/org/xvm/compiler/ast/NameResolver.java— borrow the caller's listener only for the duration ofresolve.javatools/src/main/java/org/xvm/compiler/ast/ValidationScope.javaandStatement.java— immutable context/listener pairing and guaranteed restoration of the common validation context.ForEachStatement.java,ForStatement.java,WhileStatement.javaandTryStatement.javain that AST package — restore state used by lazy label-variable and jump callbacks on every exit.javatools/src/main/java/org/xvm/compiler/EvalCompiler.javaandjavatools/src/main/java/org/xvm/tool/ModuleInfo.java— final owned diagnostic buffers; successful forwarding drains the node's buffer.The kept-warning parser test is explicitly a forward-looking guard: the ordinary parser currently reports ERROR or higher. The old lookahead machinery discarded lower-severity reports even when it kept the parse, but this PR does not claim that ordinary parsing already produced such warnings. The exception/restoration tests exercise active scopes and check that the previous state is restored after the failure.
Known follow-ups
Manual verification
Stacked-target CI: Automatic PR runs currently target
masterorJIT. Verify Commit is running for this head, explicitly dispatched with all publishing inputs disabled. Further head updates while this PR targets the parent branch also require a validation dispatch;All builds completeremains a required merge check.Verified on the published commit's code after restacking on #681:
CompilerConsumerTest: 1 passed, zero skips/failures/errors, using compiled modules supplied by Gradle dependencies.manualTests/src/main/x/loop.xandexceptions.xwith the rebuilt XDK and executedTestLoopsandTestTry; both exited successfully. Output exercised loopfirst/last/countvariables,TRY.exception, expected caught exceptions, and inner/outerfinallyexecution.git diff --checkpassed, and a merge simulation against current master found no conflicts. A merge into the protected parent branch is subject to its review and CI requirements; landing the combined work on master still depends on [LSP] Separate diagnostic reporting from listener abort policy (C1) #680.The build and automated checks can be reproduced from the repository root:
These results support ordinary compiler behavior and the specific scope-restoration guarantees. They do not imply Java source/binary compatibility with the removed parser API or establish thread safety.