Skip to content
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

Check that impl satisfies trait specs #592

Closed
ranjitjhala opened this issue Jan 4, 2024 · 3 comments · Fixed by #864
Closed

Check that impl satisfies trait specs #592

ranjitjhala opened this issue Jan 4, 2024 · 3 comments · Fixed by #864
Assignees
Labels
bug Something isn't working unsoundness

Comments

@ranjitjhala
Copy link
Contributor

Currently, flux happily verifies the below which seems dubious:

pub trait Silly {
    #[flux::sig(fn(&Self) -> i32{v:100 < v})]
    fn bloop(&self) -> i32;
}

impl Silly for i32 {
    fn bloop(&self) -> i32 {
        0
    }
}

Originally posted by @ranjitjhala in #589 (comment)

@ranjitjhala ranjitjhala added bug Something isn't working unsoundness labels Jan 4, 2024
@nilehmann
Copy link
Member

A blocker for this is that we rely on this unsoundness to have index syntax for RVec.

The impl is

impl<T> std::ops::Index<usize> for RVec<T> {
    type Output = T;

    #[flux::trusted]
    #[flux::sig(fn(&RVec<T>[@n], usize{v : v < n}) -> &T)]
    fn index(&self, index: usize) -> &T {
        self.get(index)
    }
}

The problem is flipped in this case: the signature for the impl is "more refined" than the trait declaration.

@ranjitjhala
Copy link
Contributor Author

hmm not clear why this is a blocker? [ as you point out, the issue in the RVec case is flipped? ] ?

@nilehmann
Copy link
Member

It's a blocker because fn(&RVec<T>[@n], usize{v : v < n}) -> &T (the impl) is not a subtype of fn(&RVec<T>, usize) -> &T (the trait). But when I wrote that we didn't have associated refinements which would make it a valid implementation, so it may be less of a blocker now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unsoundness
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants