Supporting const
sorts that are not integers
#935
Replies: 2 comments 2 replies
-
Something else to consider is that we probably want to keep the behavior we already have for integers where we evaluate and then map the bytes, so the reflection strategy needs to change depending on the type. Also, a couple of pointers:
|
Beta Was this translation helpful? Give feedback.
-
Moving discussion in #932 (comment) here @ranjitjhala it's silly that we didn't anticipate this but if we write #[flux_rs::constant(bv_int_to_bv32(0x4567))]
pub const START: BV32 = BV32::new(0x4567); we need to make sure we give Right now we lower concretely, the following should work #[flux::opaque]
#[flux::refined_by(val: bitvec<32>)]
pub struct BV32(u32);
impl BV32 {
#[flux::trusted]
#[flux::sig(fn (x:u32) -> BV32[bv_int_to_bv32(x)])]
const fn new(val: u32) -> Self {
BV32(val)
}
}
#[flux_rs::constant(bv_int_to_bv32(0x4567))]
pub const START: BV32 = BV32::new(0x4567);
#[flux_rs::sig(fn () -> BV32[START])]
pub fn test1() -> BV32 {
START
} |
Beta Was this translation helpful? Give feedback.
-
Specifically, related to #886 and @vrindisbacher's #932
Summarizing the discussion on slack with @nilehmann to support the following
It sounds to me like there are three distinct things we need.
STEP 1. Use the signature of a
const
in other specifications (which is #932)STEP 2. Check the signature of a
const
against its own (MIR) definitionSTEP 3. Synthesize the signature of a
const
from its definition (which is #886)For (1) we need to
rustc_middle::ty::Ty
we can use to avoid circularitiesBLAH
into the refinement logic i.e. replace occurrences ofBLAH
in refinements withint_to_bv32(0x4567)
?Specifically, get the below working
Beta Was this translation helpful? Give feedback.
All reactions