warning if the user attempts arithmetic with bounded int types in spec/proof #113
Replies: 6 comments
-
|
This may be controversial, but should we consider "reversing the polarity"; i.e., automatically casting bounded int types to |
Beta Was this translation helpful? Give feedback.
-
|
Though I'm not morally opposed - doing all those casts is really annoying - it's not technically obvious how to do it. The Rust typechecker runs before mode-checking, so a rule like "cast to int in spec code" can't be implemented easily. Also, since bit-vector arithmetic exists, we don't always want to cast up to an int. We really only want to do that in arithmetic settings instead of bit settings. It might be reasonable to have a rule "cast the arguments to (+, -, *, /) to an int". But that still runs into the problem above. One thing we might be able to do is abuse the fact that int only exists in spec code, and thus change the typechecking rules only in context where ints are expected; for example, in the following: #[spec] let a: u8 = 5;
#[spec] let b: u8 = 8;
#[spec] let x: int = a + b;Rust currently doesn't allow this (it infers that #[spec] let x: int = a as int + b as int;I don't know if it's an easy change, but it'd probably be a controversial one 😅 |
Beta Was this translation helpful? Give feedback.
-
|
I like We have some support for early mode analysis in Some people like What annotation should we use to say "I know what I'm doing, and I don't want to expand to an |
Beta Was this translation helpful? Give feedback.
-
They can always use Is there a case where someone might actually want the "clipped, but arbitrary" behavior? |
Beta Was this translation helpful? Give feedback.
-
|
I think |
Beta Was this translation helpful? Give feedback.
-
|
The new macros and syntax widen arithmetic in spec mode to int/nat. We may still want a way to request a non-coerced operation, as suggested by @tjhance and @parno. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is almost always a mistake - it's idiomatic to convert to an int first in spec code
Beta Was this translation helpful? Give feedback.
All reactions