Repository navigation
Attach the receiver's states to state refinement errors - #421
Merged
Merged
Conversation
StateRefinementError now carries a StateErrorContext with the receiver, its class, the called method, the states the receiver can be in, the states that allow the call (per state set) and whether the state machine is complete, so clients can show the verifier's answer instead of re-deriving it from the predicates' text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 24, 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.
Why
The VS Code extension shows a state machine with the rejected call highlighted. Today liquidjava-fsm works out the receiver's possible and accepted states again by reading the text of the error's
expectedandfoundpredicates. The verifier has already computed both with the SMT solver, and the text reading can disagree with it, for example with guardedfromclauses,old(...)or several state sets. This PR exposes the verifier's answer, so fsm can go back to only drawing the diagram.What
StateRefinementError#getContext()returns aStateErrorContext, or null when the states could not be computed:receiverf(as written;thisif implicit)receiverClasstestSuite.ErrorStateHintCallSequencemethodread()(same format as the hints)possibleStates[["created"]]acceptedStates[["open"]], or null when they depend on the argumentscompleteEach state lists its name in every state set, in declaration order, e.g.
["closed", "locked"]. The states stay combined because projecting them onto each set separately would mark states as accepted that are not.To support this,
Statenow keeps its per-set names, andname()still joins them with " and " for the hints. Hints and the category already reach clients throughLJDiagnostic.Tests
TestStateErrorContextcovers a single state set, several state sets, a path-dependent state, an argument-dependent transition (accepted states unknown, machine incomplete) and a class without a state set (no context).mvn test: 492 tests pass.🤖 Generated with Claude Code