Chained conjunction forces spec mode #1203
Replies: 3 comments
-
Definitely a confusing error message that should be fixed. I'm not really sure about supporting chained inequalities in exec code though. I think generally it's a good idea to leave exec code as 'normal rust' as much as possible. |
Beta Was this translation helpful? Give feedback.
-
While I acknowledge your point, I'd like to also remind us that |
Beta Was this translation helpful? Give feedback.
-
Given that Rust hasn't had chained comparison in a while (relevant thread that started in 2017: rust-lang/rfcs#2083), and our semantics of chained comparison (e.g., ((Click here for current rustc error message))$ rustc x.rs
error: comparison operators cannot be chained
--> x.rs:2:8
|
2 | if 1 < 2 < 3 {
| ^ ^
|
help: split the comparison into two
|
2 | if 1 < 2 && 2 < 3 {
| ++++
error: aborting due to 1 previous error Important things to keep in mind (esp in exec-mode), if we decide to include this:
|
Beta Was this translation helpful? Give feedback.
-
Run this with verus:
You'll get
error: condition must have mode exec
, which is quite confusing.A workaround is to replace the condition with
a <= b && b <= c
, so evidently operator chaining causes the expression to suddenly become a spec expression.Is there any reason we shouldn't allow chained expressions in exec text and desugar them to a collection of conjuncts?
Beta Was this translation helpful? Give feedback.
All reactions