Skip to content

Add Missing this Binding + Method Checking Ordering#190

Open
rcosta358 wants to merge 3 commits intomainfrom
codex-issue-78
Open

Add Missing this Binding + Method Checking Ordering#190
rcosta358 wants to merge 3 commits intomainfrom
codex-issue-78

Conversation

@rcosta358
Copy link
Copy Markdown
Collaborator

@rcosta358 rcosta358 commented Mar 24, 2026

Closes #78.

Add Missing this Binding

Fixes the error Variable 'this' not found when a method combined a state refinement with a parameter refinement that referenced this. Fixed this by adding this to the context in AuxStateHandler.createStatePredicate.

Method Checking Ordering

This PR also fixes invocation parameter refinement checking to use the receiver’s pre-call state instead of its post-call state, which means the order of checking a parameter is now check pre-conditions -> check parameter refinements -> update with post-conditions. This keeps the existing state transition behavior, but delays applying it until after parameter validation.

Why?

In the following example, in the update method, the parameter refinement percentage > progress(this) should be checked against the receiver's state before the call. Instead, the verifier was applying the receiver state transition first and only then validating the parameter refinement, which meant the condition was always false (x > x => false ).

@Ghost("int progress")
@StateSet({"created", "downloading", "completed"})
public class Downloader {

    @StateRefinement(to="created(this) && progress(this) == 0")
    public Downloader() {}

    @StateRefinement(from="created(this) && progress(this) == 0", to="downloading(this) && progress(this) == 0")
    public void start() {}

    @StateRefinement(from="downloading(this)", to="downloading(this) && progress(this) == percentage")
    public void update(@Refinement("percentage > progress(this)") int percentage) {}

    @StateRefinement(from="downloading(this) && progress(this) == 100", to="completed(this)")
    public void finish() {}
}

@rcosta358 rcosta358 self-assigned this Mar 24, 2026
@rcosta358 rcosta358 added the bug Something isn't working label Mar 24, 2026
Copy link
Copy Markdown
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

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

Let's just add some tests that actually exercise the state, along with the ghost just to check, that verification actually supports this

@rcosta358 rcosta358 changed the title Add Missing this Binding Add Missing this Binding + Method Checking Ordering Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected Error When Combining Refinement and StateRefinement

2 participants