-
Notifications
You must be signed in to change notification settings - Fork 17
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
Bug in Constraint Gen with Result? #271
Comments
Oh, this is annoying, but it's working as expected. We need to adjust subtyping to make it work. So, in
for the result type inside the if, where
Since For
Given the order in which the rules are applied we don't get to assume
We have a rule for unpacking existentials, but it is shallow:
We could generalize that to look inside boxes. |
More concretely, I'm saying that the following rule should be admissible
|
Hmm, I think I'm getting the general drift here -- in the The use of struct Bob();
#[flux::sig(fn (x:u32) -> Result<{Bob : x < 100}, bool>)]
pub fn foo(x: u32) -> Result<Bob, bool> {
if x >= 100 {
return Err(false);
}
Ok(Bob())
} Now,
Or do we need to have indexed |
For reference, this comes up here: // #[ensures(result.is_ok() ==> old(v_fd) < MAX_SBOX_FDS)]
#[flux::sig(fn (&FdMap, v_fd: SboxFd) -> Result<HostFd{v: v_fd < MAX_SBOX_FDS}, RuntimeError>)]
pub fn fd_to_native(&self, v_fd: SboxFd) -> Result<HostFd, RuntimeError> {
if v_fd >= MAX_SBOX_FDS {
return Err(Ebadf);
}
self.m[v_fd as usize]
} where #[derive(Clone, Copy, PartialEq, Eq)]
pub struct HostFd(usize); |
In fact, I'm a bit puzzled as to why |
Returning to the example -- I was expecting the thing to check precisely because of the |
Oh interesting. There's a difference between being unrefinable (e.g. an &T or a type parameter) and having zero indices (a struct without a That being said, it's a bit unsatisfying that the verification relies on generating an uninhabited type, e.g. it won't work for unrefinable types. |
The following code
produces an error
Drilling in, the constraint generated is:
Note that the
bar
variant -- which uses ani32
instead of aBox
does the right thing. Any ideas?The text was updated successfully, but these errors were encountered: