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 recognize constants as an exec value across multi crates #1275

Open
rikosellic opened this issue Sep 20, 2024 · 1 comment
Open

cannot recognize constants as an exec value across multi crates #1275

rikosellic opened this issue Sep 20, 2024 · 1 comment

Comments

@rikosellic
Copy link
Contributor

rikosellic commented Sep 20, 2024

Verus does recognize constants defined in another verified crate in spec mode, but cannot recognize it as an exec value. For example, suppose I define constant ONE in the library crate mylibrary/lib.rs and compile it following the instructions in this Zulip conversation.

use vstd::prelude::*;
verus!
{
    pub const ONE: usize = 1;
}

Later when I want to use ONE as a spec value in my main crate mymain/lib.rs, everything works smoothly :

use mylibrary::ONE;
use vstd::prelude::*;

verus!{
    proof fn test() 
    {
        assert(ONE+ONE==2);
    }
}

But if I attempt to treat it as an exec value, like defining another constant:

verus!{
    pub const TWO : usize = ONE + ONE;
}

or using it as a return value:

verus!{
    fn f() -> usize
    {
        ONE
    }
}

verus will report an error indicating that it can not find a function:

error: cannot find function `f472_ONE` in this scope
  --> mylibrary\src\lib.rs:19:29
   |
19 |     pub const TWO : usize = ONE + ONE;
   |                             ^^^

error: cannot find function `f472_ONE` in this scope
  --> mylibrary\src\lib.rs:19:35
   |
19 |     pub const TWO : usize = ONE + ONE;
   |                                   ^^^

error: aborting due to 2 previous errors

note: This error was found in Verus pass: ownership checking of tracked code

It seems this problem is that the underlying representation of constants in exec mode is not passed between crates, is there a proper solution for this situation?

@rikosellic rikosellic changed the title cannot recognize constants across multi crates in const definitions cannot recognize constants as an exec value across multi crates Sep 20, 2024
@chrihop
Copy link

chrihop commented Sep 23, 2024

I've encountered this issue as well. Constants from imported crates do not appear as the corresponding function definitions in the crate-lifetime.rs file when logging is enabled, yet they are referenced in the function body of the callers.

// crate-lifetime.rs
...
fn main() {}



fn f31_main(
)
{
    let x24_x: u32 = f25_ONE();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants