Skip to content

The order of requires clauses is not respected #3575

@zhassan-aws

Description

@zhassan-aws

I tried this code:

#[kani::requires(x == 0)]
#[kani::requires(x * y < 10)]
fn foo(x: u8, y: u8) {}

#[kani::proof_for_contract(foo)]
fn check_foo() {
    foo(kani::any(), kani::any());
}

using the following command line invocation:

cargo kani -Zfunction-contracts

with Kani version: d2f5dbe

I expected to see this happen: Verification successful

Instead, this happened: the multiplication overflow check failed:

SUMMARY:
 ** 1 of 49 failed
Failed Checks: attempt to multiply with overflow
 File: "src/lib.rs", line 2, in foo::{closure#2}

VERIFICATION:- FAILED

I would expect it to succeed because of the previous requires clause.

Interestingly, if I flip the order of the requires clauses, verification succeeds:

#[kani::requires(x * y < 10)]
#[kani::requires(x == 0)]
fn foo(x: u8, y: u8) {}

#[kani::proof_for_contract(foo)]
fn check_foo() {
    foo(kani::any(), kani::any());
}
SUMMARY:
 ** 0 of 49 failed

VERIFICATION:- SUCCESSFUL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Z-ContractsIssue related to code contracts[C] BugThis is a bug. Something isn't working.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions