-
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
Illegal MatchType Error reaches the backend #19434
Comments
Also, I am not sure why this program would be illegal. I guess it should not be. The problem seems to be that the match type is reduced only at erasure. At that time, opaque types are already eliminated, so |
Here's the stacktrace I see when I add a
|
Definitely a problem in erasure. During erasure, when trying to reduce the match type before erasing its bound, I observe a weird behavior. It sees as |
No, opaque type aliases are eliminated before erasure, at phase ElimOpaque. |
Oh. Well at least that explains it. It will make this tricky to fix, though. I'll have to think about it more. |
I just hit this in the wild with some test code using NamedTuples. |
I'm merging ElimOpaque into Erasure |
This is another case which used to result in an unreported `ErrorType` It is now detected only when enabling `-Yforce-sbt-phases -Xverify-signatures -Ycheck:all` The error comes from: ```scala type Names[X <: AnyNamedTuple] <: Tuple = X match case NamedTuple[n, _] => n ``` The `NamedTuple` pattern is legal as long as the type alias is opaque. Following elimOpaque however, it is beta-reduced (as normal applied type aliases in match type patterns) to a pattern which no longer contains an instance of the type capture `n`, making it an illegal pattern. This used to return an `ErrorType`, which happened not be reported as in the other cases. Also note this error could also be missed without the New footprint calculation scheme (scala#19639) Given the changes to the footprint calculation and failed reduction reporting, this is now the same issue as scala#19434.
Compiler version
3.4.0
Minimized example
Output
Expectation
A regular error, like this one:
I verified that that was the error that generated the illegal error type.
The text was updated successfully, but these errors were encountered: