Skip to content

Respect explicit stubs when detecting contract-generation cycles - #5008

Open
Kieran-Hulsman wants to merge 2 commits into
model-checking:mainfrom
Kieran-Hulsman:kieran/contract-stub-cycle-fix
Open

Kieran-Hulsman wants to merge 2 commits into
model-checking:mainfrom
Kieran-Hulsman:kieran/contract-stub-cycle-fix

Conversation

@Kieran-Hulsman

Copy link
Copy Markdown

Resolves #5007


Kani reports a recursion error when a verified stub’s return type has an Arbitrary implementation that calls the stubbed function, even if an explicit replacement breaks that cycle.

Make the cycle detector follow the configured replacements rather than the original function bodies. Genuine cycles remain rejected.


Added tests for:

  • Replacing Arbitrary::any to break a cycle.
  • Breaking a cycle by replacing a helper further down the call chain.
  • Using a generic replacement with both u8 and u64.
  • Rejecting a replacement that introduces a cycle.

Confirmed the error occurs on main and is resolved by this change. Deliberately incorrect assertions fail verification as expected.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-CompilerBenchCI Tag a PR to run benchmark CI Z-EndToEndBenchCI Tag a PR to run benchmark CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False recursion diagnostic despite an explicit Arbitrary replacement

1 participant