Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot verify a constant function if crate has effect feature enabled #3258

Closed
celinval opened this issue Jun 11, 2024 · 1 comment · Fixed by #3259
Closed

Cannot verify a constant function if crate has effect feature enabled #3258

celinval opened this issue Jun 11, 2024 · 1 comment · Fixed by #3259
Labels
[C] Bug This is a bug. Something isn't working.

Comments

@celinval
Copy link
Contributor

I tried this code:

#![feature(effects)]

#[kani::requires(kani::mem::can_dereference(arg))]
const unsafe fn dummy<T>(arg: *const T) -> T {
    std::ptr::read(arg)
}

#[kani::proof_for_contract(dummy)]
fn check() {
    unsafe { dummy(&kani::any::<u8>()) };
}

using the following command line invocation:

kani -Z function-contracts -Z mem-predicates contract.rs

with Kani version:

I expected to see this happen: Verification should pass;

Instead, this happened: Compilation fails

error: mismatch in the number of generic parameters: original function/method `dummy` takes 2 generic parameters(s), stub `dummy_recursion_wrapper_8b0f77` takes 1
  --> constant.rs:15:1
   |
15 | #[kani::proof_for_contract(dummy)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `kani::proof_for_contract` (in Nightly builds, run with -Z macro-backtrace for more info)
@celinval celinval added the [C] Bug This is a bug. Something isn't working. label Jun 11, 2024
@celinval
Copy link
Contributor Author

Note: For effects feature, the compiler inserts an extra constant parameter named "host". More implementation details here:

rust-lang/rust#113210
rust-lang/rust#118605

celinval added a commit that referenced this issue Jun 12, 2024
We now check if the host effect index is present. If so, remove it
before performing stub operation.

Resolves #3258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant