Recommends checking for get_* from #[is_variant] (report warnings when calling get_X_0() without is_X())
#321
marshtompsxd
started this conversation in
Language design
Replies: 3 comments 4 replies
|
Here's a concrete example where recommends checking isn't solving this problem (does #![allow(unused_imports)]
use builtin::*;
use builtin_macros::*;
verus! {
#[is_variant]
enum Foo {
A(u64),
B(bool),
}
spec fn user_get_A(f: Foo) -> u64
recommends f.is_A()
{
f.get_A_0()
}
fn take_a(f: Foo) -> u64
requires user_get_A(f) == 3
{
3
}
fn example() {
let f = Foo::B(false);
// GOOD: note that recommendation not met
assert(user_get_A(f) == 3);
// BAD: nothing about recommendation
assert(f.get_A_0() == 3);
// BAD: nothing about recommendation
take_a(f);
}
fn main(){}
} |
0 replies
|
I don't think we're checking recommends on |
0 replies
|
Thanks for creating the discussion! For this issue though, independently of |
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
We are using
#[is_variant]a lot and often need to writeIt would be great if Verus can report warnings when we call
get_X_0()without ensuringis_X()before that.All reactions