-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bounded integers #642
Bounded integers #642
Conversation
4414031
to
4987cf4
Compare
4987cf4
to
15e6ad7
Compare
15e6ad7
to
f0b1251
Compare
f0b1251
to
08c1dc9
Compare
1ce7d17
to
16b1dc3
Compare
The CI is failing because of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to do changes here. But let's get something in and improve later when we know better what exactly we need.
This PR:
refine
(from the trait Refine, which is implemented by types for which refine types have been defined) intocheck
("check" is less "refinement-oriented" vocabulary and conveys the right intuition);invariant
method to theRefinement
trait, so that one can check whether a value satisfies a refinement;invariant
method to generate adebug_assert!
that ensures the refinement holds at runtime (in debug mode only);no_debug_runtime_check
option to disable that runtime check even in debug mode (useful since that check requires the refined type to implClone
);num_traits
that defines a small trait hierarchy for operations we want to support on machine integers;BoundedT
, for any machine integerT
, all of those types implement traits fromnum_traits
;chacha20
example usingBoundedUsize<0, 15>
instead of preconditions (that reformulation of chacha20 TC in F*).This PR builds on #643.
TODO:
hax-bounded-integers
;add bounded math integers (let's first merge Add support for math integers #629)this is not possible right now because we'd need adt_const_params;#[test]
;BoundedT
sFuture work:
MachineInt
for every primitive type?