Improve error messages #387
Replies: 45 comments 33 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:
|
Beta Was this translation helpful? Give feedback.
-
Unfortunate error message for write to immutable variable. Reported by @jonhnet: |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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.
|
Beta Was this translation helpful? Give feedback.
-
cc @tjhance A type parameter on a struct made with |
Beta Was this translation helpful? Give feedback.
-
@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");
} |
Beta Was this translation helpful? Give feedback.
-
@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:
|
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
@jonhnet: Improve error message for exec-mode use of spec-mode builtin types Moved from: #505 This code:
gives this error message:
which confuses even people who should know better. It should instead tell us something like |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
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 |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
The following code:
gives the following error, and I'm not sure what it means:
One thing making it hard to understand is the reference to |
Beta Was this translation helpful? Give feedback.
-
Pointing out that a function is uninterpreted in |
Beta Was this translation helpful? Give feedback.
-
. @jonhnet would like we reported all precondition failures for a function call (I agree we should): https://play.verus-lang.org/?version=stable&mode=basic&edition=2021&gist=96d5fee8b3ba89a5fd796c509b072c6b |
Beta Was this translation helpful? Give feedback.
-
. @jonhnet prefers reporting assertion failures in (line number) order. The trade-off is that this would require delaying the first report (while we search for an earlier failure), but that (1-2 sec delay) is shorter than the time it takes the user to parse the out-of-order output. |
Beta Was this translation helpful? Give feedback.
-
Report by @jonhnet:
This error message is misleading. It'd be nice to catch the unneeded generic params before they cause an error. |
Beta Was this translation helpful? Give feedback.
-
spec fn foo(n: nat) -> bool;
fn bar()
ensures forall|n: nat| #![trigger] foo(n)
{ } results in this error message:
I accidentally used |
Beta Was this translation helpful? Give feedback.
-
@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). |
Beta Was this translation helpful? Give feedback.
-
use builtin_macros::*;
verus! {
fn foo() {
let x: usize = 0;
let _ = x << 1u64;
}
fn main() { }
}
This error message is confusing, since the |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
I'm relaying a feature request that someone else brought up: we could have |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
@matthias-brun recently noticed that we are now counting non-recursive spec functions as successful VCs, although nothing was verified for them:
produces:
|
Beta Was this translation helpful? Give feedback.
-
The error message "datatype is opaque here" is rather vague. Can we add the name of the datatype that's opaque and the subexpression(s) with that datatype? |
Beta Was this translation helpful? Give feedback.
-
This is intended to track confusing or misleading error messages.
Please add a new top-level comment for each error message.
Beta Was this translation helpful? Give feedback.
All reactions