-
Notifications
You must be signed in to change notification settings - Fork 23
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
Beef up infer-mut-hack #904
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[flux::sig(fn (xs: &mut { [i32][@n] | n > 1}))] | ||
fn lib1(_xs: &mut [i32]) {} | ||
|
||
#[flux::sig(fn (xs: { &mut [i32][@n] | n > 1}))] | ||
fn lib2(_xs: &mut [i32]) {} | ||
|
||
fn boo() -> &'static mut [i32] { | ||
todo!() | ||
} | ||
|
||
fn test() { | ||
let ys = boo(); | ||
lib1(ys); //~ ERROR: refinement type | ||
lib2(ys); //~ ERROR: refinement type | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#[flux::sig(fn (xs: &mut { [i32][@n] | n > 1}))] | ||
fn lib1(_xs: &mut [i32]) {} | ||
|
||
#[flux::sig(fn (xs: {&mut [i32][@n] | n > 1}))] | ||
fn lib2(_xs: &mut [i32]) {} | ||
|
||
#[flux::sig(fn () -> &mut [i32][10])] | ||
fn boo() -> &'static mut [i32] { | ||
todo!() | ||
} | ||
|
||
fn test() { | ||
let ys = boo(); | ||
lib2(ys); | ||
lib1(ys); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@ranjitjhala
We already have Ty::unconstr which is a more general version of this.
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.
Interesting -- didn't know about it!
But, not really, replacing
with
Doesn't seem to work -- looks like
unconstr
is not "deep": it expects theConstr
at the very top?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.
Looks like
unconstr
just peels away all the "topmost"Constr
-- the moment it hits something else it stops.So it won't work with
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.
You first need to match on the
&mut T
and thenunconstr
theT
I wonder though if there's a clean way to handle this during canonicalization (the thing
unpack
is implementing on top of). It is always safe to turn an&mut {T | p}
into{&mut T | p}
so we could get rid of it duringunpack
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.
This is why I have two tests -- the other one flips the order which fails your method
But yes, if you had
canonicalized
presumablylib1
gets turned intolib2
?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.
ah yeah, you'd need to unconstr twice
I still think there has to be a nice way in which we can canonicalize types before pattern matching on them. The canonicalize infra is almost there...