-
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
Towards polymorphic sorts #542
Conversation
The |
Currently, we have to explicitly write the generic Should we require this? (Without it, you get a weird crash later.) But OTOH we could plausibly automatically just "scrape" them from the actual sorts appearing in the #[flux::refined_by(<Tiger> { elems: Set<Tiger> })]
// #[flux::refined_by( elems: Set<Tiger> )] //~ ERROR unbound generic `Tiger`
pub struct RSet<Tiger> {
pub inner: std::collections::HashSet<Tiger>,
} |
Maybe for now, better to be explicit and throw a WF error if there is an unbound generic. |
I decided to go the other way -- I removed the explicit params and instead just |
@nilehmann - I think I'm done with this, ready for review. |
I'm going to take a look at this now |
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.
First batch of comments.
I've only looked until desugaring. Most comments are related to how we use the SortResolver
. I think we could reuse it instead of creating a new one every time.
Also as a general comment about SortResolver
. I think we never have a case where both generics
and sort_vars
are Some
so we could expose that as two construction methods (not sure about the names)
impl<'a> SortResolver<'a> {
fn with_sort_vars(sess: &'a FluxSession, sort_decls: &'a SortDecls, sort_vars: &[surface::Ident]) -> Self {
...
}
// we grab `sort_decls` from `genv` and fetch generics of `owner_id` inside
fn with_generics(genv: &'a GlobalEnv<'a, '_>, owner_id: DefId) -> Self {
...
}
}
edit: Just noticed that for qualifiers both generics
and sort_vars
are None
, but the SortResolver
for qualifier should morally be a SortResolver::with_sort_vars(sess, sort_decls, &[])
.
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 Another batch of comments. Looking better!
I still haven't gone through the changes in flux-fhir-analysis
and wf.
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.
Comments about fhir_analysis and wf
Co-authored-by: Nico Lehmann <[email protected]>
Co-authored-by: Nico Lehmann <[email protected]>
Co-authored-by: Nico Lehmann <[email protected]>
Co-authored-by: Nico Lehmann <[email protected]>
Ok I think I addressed the various comments; including representing the #[flux::refined_by(<K,V>{keys: Set<K>, vals: Map<K, V>})] instead of automatically finding the Not clear if we want to write this explicitly -- more the user has to write, the more opportunity for error! Any thoughts? |
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.
Ok, this looks good. There are still many details I'm not happy with, but I'm ok with merging so we can move forward.
About the syntax, as always, I'm not too worried about it, we can always change it later. I'm more concerned about having enough pieces of the puzzle in place.
That being said, I do think is a bit redundant to annotate the parameters. It also makes it that you need to check more things. For example, this line will crash if you don't use the same names.
Co-authored-by: Nico Lehmann <[email protected]>
Co-authored-by: Nico Lehmann <[email protected]>
Allow polymorphic sorts, see
rset.rs
,rmap.rs
andrmapk.rs
and clients.