-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Issue with bounded recursive match types #18546
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
Comments
There is no GADT reasoning inside match types. So no, this does not compile. |
OK! But what is the GADT (or even ADT) in this example? It rather seems to me the issue is that there is no reasoning about the value of N in individual branch. |
GADT reasoning is the name for any subtyping constraints that are learnt from a match case (more rarely also referred to as "subtype reconstruction"). Here, it's recording that You can force this to compile by intersecting the type you wanted to return with the bound you have. So, in the minimisation, |
Great, thanks for the explanation! |
I guess we could close this as not planned? |
It seems that this minimisation should not compile. In the match case the constraint we get is N <: 0 but to type check the body the required constraint is 0 <: N, which we cannot prove anyway. WDYT? @dwijnand |
Hmm, perhaps. On the other hand 0 is a singleton (as well as Int being final), which I mention because those are criteria in |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.3.1
Minimized example
Output
Expectation
It seems like this should compile. I'm not sure if this is a bug or intended behaviour, but I found no reference to this situation. A real life scenario would have for example a trait A0 extending A[0].
The text was updated successfully, but these errors were encountered: