Skip to content

Contract fails due to promoted constants being havocked #3228

@zhassan-aws

Description

@zhassan-aws

I tried this code:

extern crate kani;

#[derive(PartialEq, Eq)]
pub enum Foo {
    A,
    B,
}

#[kani::ensures(result == Foo::A)]
pub fn a() -> Foo {
    Foo::A
}

#[kani::proof_for_contract(a)]
fn check() {
    let _ = a();
}

using the following command line invocation:

kani enum_ensures_bug.rs -Zfunction-contracts

with Kani version: 7bf23a2

I expected to see this happen: Verification succeeds

Instead, this happened:

SUMMARY:
 ** 1 of 1336 failed
Failed Checks: result == Foo::A
 File: "enum_ensures_bug.rs", line 9, in a_check_7b31b

VERIFICATION:- FAILED
Verification Time: 1.9666983s

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-High PriorityTag issues that have high priority[C] BugThis is a bug. Something isn't working.[F] Spurious FailureIssues that cause Kani verification to fail despite the code being correct.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions