Repository navigation
Scope the type of return in state refinement checks - #441
Open
CatarinaGamboa wants to merge 1 commit into
Open
CatarinaGamboa wants to merge 1 commit into
CatarinaGamboa wants to merge 1 commit into
Conversation
createStatePredicate declared `_` (the renamed `return`) and the `this` variables in the current context, outside any scope, and only when `_` was not declared yet. The first non-void method with a `to` fixed the type of `return` for every spec checked after it, and `!return` on a later boolean method crashed with "Expr cannot be cast to BoolExpr". Declare them in a scope of their own, always with the method's return type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
[Codex review] I checked the scope change in |
Collaborator
Author
|
[Claude] Thanks for checking. No changes needed. |
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.
Fixes #440.
Problem.
AuxStateHandler.createStatePredicatechecks thetoof a non-void method by renamingreturnto_and declaring_with the method's return type. That declaration (and thethisvariables) went into the current context, outside any scope, and only when_didn't exist yet. So the first non-void method with atofixed the type ofreturnfor every spec checked after it. A laterto = "!return && ..."on abooleanmethod then crashed withExpr cannot be cast to BoolExpr(orIntExpr ...when the earlier method returnedint). Which specs crash depends on the order the packages are checked in.Change. Declare these variables in their own scope (
enterContext/exitContextin afinally), and always declare_with this method's return type. An inner declaration shadows an outer one in the SMT translation.Test.
testSuite/classes/state_return_type_scope_correct: aVectorspec whosesetreturnsE, checked before anUndoManagerspec with!returnincanUndo. It fails onmainwith the crash and passes with this change.mvn testpasses.Also checked on a six-exercise study project (Vector, UndoManager, ImageWriteParam, JFrame, Random, Socket specs in one source folder): before the change, the UndoManager exercise's real error turned into this crash. After it, all six report their intended error lines.
🤖 Generated with Claude Code