Repository navigation
[subtype-exprs] Fix shared constraints on unreachable RefEqs #9279
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -456,6 +456,7 @@ template<typename Self> struct Noter { | |
| Self& self() { return *static_cast<Self*>(this); } | ||
|
|
||
| void noteSubtype(HeapType sub, HeapType super) { | ||
| assert(HeapType::isSubType(sub, super)); | ||
| // Bottom types are uninteresting, but other basic heap types can be | ||
| // interesting because of their interactions with casts. | ||
| if (sub == super || sub.isBottom()) { | ||
|
|
@@ -701,6 +702,7 @@ struct Unsubtyping : Pass, Noter<Unsubtyping> { | |
| } | ||
|
|
||
| void noteNonFlowSubtype(Expression* sub, Type super) { | ||
| assert(Type::isSubType(sub->type, super)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these added? They don't look specific to this pass?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, if these make sense, why not put them in the general utility so they apply to all passes?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're added because there's no way to add an unsubtyping regression test otherwise. Unsubtyping takes the early return just below this. Adding the assertions to the general utility makes sense, though. I'll do that.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, the assertions cannot be simply moved to the shared utility because the shared utility is doing CRTP calls out to subtypes for these functions. We could have the CRTP utility call a chokepoint function that does the assertion and then calls the subtype, but that would be a much larger change and doesn't seem worth it to me.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, fair enough. |
||
| // This expression's type must be a subtype of |super|, but the value | ||
| // does not flow anywhere - this is a static constraint. As the value | ||
| // does not flow, it cannot reach anywhere else, which means we need | ||
|
|
||
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.
For my understanding, the only way that
isShareddoesn't match between the two arguments is if one argument is unreachable, is that right?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.
Yes, that's correct for valid IR (which all users of this utility should be assuming we have).