Skip to content

List the calls that reach an allowed state when the state is unknown - #413

Merged
CatarinaGamboa merged 1 commit into
feat/state-hints-dead-endsfrom
feat/state-hints-unknown
Oct 23, 2026
Merged

CatarinaGamboa merged 1 commit into
feat/state-hints-dead-endsfrom
feat/state-hints-unknown

Conversation

@CatarinaGamboa

Copy link
Copy Markdown
Collaborator

Stacked on #412.

Description

When nothing is known about the receiver's state (e.g. a parameter with no state refinement), the error used to say only that no state information is known. For classes with a state machine, it now lists the constructors and the calls that lead to a state allowing the failing call, each with the states it is called from.

Classes without a state machine keep the previous general hint.

Example

static void use(File f) {
    f.read(); // read() needs open
}
 --> The state of f is unknown here. To get it to open, use: f.open() (from created)

Type of change

  • New feature

Checklist

  • Added tests: ErrorStateHintUnknownState. TestStateHints also checks that a class without @StateSet keeps the general hint.
  • mvn test passes locally

🤖 Generated with Claude Code

@CatarinaGamboa
CatarinaGamboa added this pull request to stack #415 October 23, 2026 16:59
When nothing is known about the receiver's state, the error lists the
constructors and the calls, with the states they are made from, that
lead to a state allowing the failing call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CatarinaGamboa
CatarinaGamboa force-pushed the feat/state-hints-dead-ends branch from 0cf5598 to f34e6f6 Compare October 23, 2026 17:45
@CatarinaGamboa
CatarinaGamboa force-pushed the feat/state-hints-unknown branch from 3af49f3 to d1785aa Compare October 23, 2026 17:45
@CatarinaGamboa
CatarinaGamboa removed this pull request from stack #415 October 23, 2026 18:02
@CatarinaGamboa
CatarinaGamboa merged commit 8972a0a into feat/state-hints-dead-ends Oct 23, 2026
CatarinaGamboa added a commit that referenced this pull request Oct 24, 2026
Stacked on #413.

## Description
Building a state machine takes about 25 SMT checks for a small class,
and each check creates its own Z3 context. The machine only depends on
specifications, which are all registered in the first pass, so
`TypeChecker` now builds it on the first state error and reuses it for
every later error in the same checker. Finding the receiver's current
states still runs at each error.

Other options considered:
- **Eagerly, after the first pass, for every class with `@StateSet`:**
correct programs would pay the SMT cost too. Only worth it once
something needs machines without an error, e.g. the fsm diagram.
- **Once per run, cached in `Context`:** `Context` would depend on
`state_machine`, which depends on `context` (a package cycle). The other
way is a static cache that tracks when specifications change. Neither
seemed worth it for the extra hits across classes.

## Cost
Extra time of `TestExamples` on the 269 cases that exist on `main`
(summed per case, one run each; `main` takes 80.3 s):
- #413, without the cache: +29.5 s
- with this PR: +10.6 s, spread over the 54 files with state errors

## Type of change
- [x] Code refactoring

## Checklist
- [x] `mvn test` passes locally

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
CatarinaGamboa added a commit that referenced this pull request Oct 24, 2026
## Description
#412, #413 and #414 were merged into their stacked base branches instead
of `main`: once #411 was merged, their bases were never retargeted.
Their code is only on `feat/state-hints-unknown`.

This PR applies the three reviewed commits on top of `main`, unchanged:
- Explain dead ends in failing state transitions (#412)
- List the calls that reach an allowed state when the state is unknown
(#413)
- Build each class's state machine once per checker (#414)

The hint and state machine files are identical to
`feat/state-hints-unknown`. Rebase-merging keeps the three commits
separate.

## Checklist
- [x] `mvn test` passes locally on top of the current `main` (#408,
#409)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant