-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix #10747: Raise type error on unreducible match type #12768
Conversation
957de6d
to
d268725
Compare
note that: #12974 might be a good example of a test to add. I hope this PR could fix that issue as well. |
0ec2252
to
60947af
Compare
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.
Nice work! Sorry for taking so long to review.
Needs a rebase. |
60947af
to
6549e1c
Compare
Don't consider types to be fullyInstanciated when containing a TypeParamRef.
The previous check was too conservative, is we have a proof that A and B are disjoint, then A and B in Inv[A] and Inv[B] are clearly different types, and Inv[A] and Inv[B] are disjoint. Also the isSameType() && fullyInstantiated check is quite primitive, it can still be useful in some cases.
686c65f
to
11a2082
Compare
Rebased. Given that this PR changes the semantics of match types, should we still merge it directly on master or should it go to another branch? |
I'd say either we should make an exception and get this in 3.1.0-RC2 or wait for 3.2 |
I'm really happy this has been fixed. I hope it goes in sooner than later to minimize the amount of broken code that might be written before the fix is out. Currently there is very little code in the wild using match types. The longer we wait the less true that is. |
Assigned to @anatoliykmetyuk for merging and backporting. |
#13519 is the backport. |
The second commit is needed to that we don't unnecessarily try to reduce a match type right-hand side when that's not required. One example where thing go wrong otherwise is tuple's Elem type:
Given a concrete instantiation of
X
, trying to reduce the right-hand side of this type results in a type error becauseElem[Unit, n1]
is a match error. Obviously, we could circumvent that issue by adding acase _ => Nothing
, but getting a type error leads to better type safety. Furthermore, it matches the match expression "execution model" where a right-hand side is only executed if the overall expression reduces to that case.