Improve error messages #387
Replies: 51 comments 43 replies
|
Reported by @jaylorch: A simple program a beginner may write: #[allow(unused_imports)]
use builtin_macros::*;
#[allow(unused_imports)]
use builtin::*;
#[allow(unused_attributes)]
mod pervasive;
verus! {
fn main() {
println!("Hello, world!");
}
} // verus!the verifier produced the following output: The guide pointed @jaylorch to
@Chris-Hawblitzel suggested that:
|
|
Unfortunate error message for write to immutable variable. Reported by @jonhnet: |
|
This code results in @tjhance notes: The issue is that the pub spec const RC_WIDTH: nat = 4 as nat;Perhaps we could have a nicer error message in the syntax macro, though. |
|
Postcondition failure on a match is reported with a misleading span #281 #[is_variant]
enum Enum {
A,
B,
}
fn test(a: u32) -> (res: Enum)
ensures (match res {
Enum::A => a <= 10,
Enum::B => a > 10, // FAILS
}) {
Enum::B
}results in this error message, which points to the wrong branch of the Originally found by @matthias-brun.
|
|
cc @tjhance A type parameter on a struct made with |
|
@tjhance: type errors related to verus_tmp are confusing this code: fn test() {
let ghost x = 0;
}gives a very cryptic error: error[E0282]: type annotations needed
--> test_gh.rs:12:1
|
12 | / verus!{
13 | |
14 | |
15 | | fn test() {
... |
23 | |
24 | | }
| |_^ consider giving `verus_tmp` a type
|
= note: this error originates in the macro `verus` (in Nightly builds, run with -Z macro-backtrace for more info)There are two things that can be fixed here.
fn test() {
#[verus::internal(spec)]
let mut verus_tmp;
#[verifier(proof_block)]
{ verus_tmp = ::builtin::spec_literal_integer("0") };
#[verus::internal(spec)]
let mut x;
#[verifier(proof_block)]
{
#[verus::internal(spec)]
let verus_tmp_x = verus_tmp;
x = verus_tmp_x;
};
}However, it should suffice to expand it to simply: #[verus::internal(spec)]
let mut x;
#[verifier(proof_block)]
{
x = ::builtin::spec_literal_integer("0");
} |
|
@jonhnet: bogus The file below produces, as its first attempt at helping me debug my assertion failures: However, that exact recommendation appears in an assert on the previous line (243), and that assert passes. Repro: |
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
|
I often accidentally write The error message would be less confusing if it got to the heart of the problem. That is, I think it should just say that An even better solution, of course, would be to allow All of the above applies to the other |
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
|
Rename |
spec fn foo(n: nat) -> bool;
fn bar()
ensures forall|n: nat| #![trigger] foo(n)
{ }results in this error message: I accidentally used |
|
@tenzinhl #873: Add a Warning/Error when using Currently when using the Would it be possible to add a compiler warning or error for this case? (I'd be interested in looking into this with some guidance). |
This comment has been hidden.
This comment has been hidden.
use vstd::prelude::*;
verus!{
fn main() { }
#[verifier(external_body)]
struct S { }
spec fn bar(s: &S) -> bool;
fn foo(s: &mut S)
requires bar(old(s))
{
}
}The problem here is that the |
This comment has been hidden.
This comment has been hidden.
It might be helpful to enhance this error message to identify one or more non-pub fields. Something like "struct Foo has non-pub fields x, y, z, ...". In the fullness of time, perhaps a Rust-like suggestion inserting 'pub' into the field declaration. |
use vstd::prelude::*;
verus! {
struct Concrete {
a: u64,
}
struct Abstract {
a: nat,
}
impl View for Concrete {
type V = Abstract;
fn view(&self) -> <Self as vstd::string::View>::V {
Abstract { a: self.a as nat }
}
}
} // verus!This should warn about |
|
@matthias-brun recently noticed that we are now counting non-recursive spec functions as successful VCs, although nothing was verified for them: produces:
|
This comment has been hidden.
This comment has been hidden.
|
Recently a student had written a 60-line spec function and received an error from Verus saying For reference, here's a self-contained reproduction of the issue: |
|
From a recent Zulip discussion: Verus reports: It was suggested we explicitly list the special cases (e.g., |
|
Hi, This is the program: And, the error message says: By the way, the Tutorial never said we cannot use constant variable inside bit_vector prover. |
This comment has been hidden.
This comment has been hidden.
|
This program has a small bug, but its error message is very confusing: The confusing error message is: I guess this is because the parser thinks the |
|
i am personally confused by use vstd::prelude::*;
verus! {
proof fn lemma_a(){
proof { assert(true); }
}
}this gives but it is proof code, not spec code? if the expected behavior is to reject |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This is intended to track confusing or misleading error messages.
Please add a new top-level comment for each error message.
All reactions