You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ordinary stub of a proof_for_contract or stub_verified target fails with an internal error #5206
Stubbing a function with an ordinary stub while the same function is also the target of #[kani::proof_for_contract] or #[kani::stub_verified] fails with an internal compiler error instead of a diagnostic.
Reproduce
#[kani::requires(x < 100)]#[kani::ensures(|r:&u32| *r == x + 1)]fnf(x:u32) -> u32{ x + 1}fng(x:u32) -> u32{ x.wrapping_add(1)}fncaller(x:u32) -> u32{f(x)}/// Stub the function under verification.#[kani::proof_for_contract(f)]#[kani::stub(f, g)]fncheck_target_stubbed(){let x = kani::any();let _ = f(x);}/// Stub a function that is also replaced by its contract.#[kani::proof]#[kani::stub_verified(f)]#[kani::stub(f, g)]fnverified_and_stubbed(){let x:u32 = kani::any_where(|x| *x < 100);let _ = caller(x);}
error: Failed to find contract closure `__kani_recursion_check_f` in function `main::f`
The stubbing pass replaces f's body with g's, and the contract pass then looks for f's generated closures in that body. This happens on main and with #5204. That PR fixes the ordinary case (#[kani::stub(f, g)] alone, #4591) but intentionally leaves these two combinations unchanged.
Expected
Both combinations are configuration mistakes: the first stubs the function under verification, the second stubs a function that is replaced by its contract. Kani should reject them with an error that names the conflicting attributes, e.g. "f cannot be both the target of proof_for_contract/stub_verified and replaced by #[kani::stub(f, g)]".
Activity
Reject ordinary stubs of contract targets (model-checking#5211)