-
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
nested named irrefutable typetest pattern causes exhaustivity warning #10994
Comments
It seems Scala 2 syntax does not support this and it's not in the Scala 3 language specification. Maybe we can disallow it in Scala 3 as well. |
I have seen some code use a nested pattern in a type test in the wild but I'm not sure what made it necessary |
I'd also be in favour of (at least temporarily) disallowing this in Scala3, since it apparently causes extra difficulties in the compiler. It's always possible to define a "fork" pattern which allows simultaneously matching one value against two patterns, so there's no real loss of functionality from forbidding this syntax. |
In Scala 2, a typed pattern `p: T` restricts that `p` can only be a pattern variable. In Dotty, scala#6919 allows `p` to be any pattern, in order to support pattern matching on generic number literals. This PR aligns the syntax with Scala 2 by stipulating that in a typed pattern `p: T`, either - `p` is a pattern variable, or - `p` is a number literal
In Scala 2, a typed pattern `p: T` restricts that `p` can only be a pattern variable. In Dotty, scala#6919 allows `p` to be any pattern, in order to support pattern matching on generic number literals. This PR aligns the syntax with Scala 2 by stipulating that in a typed pattern `p: T`, either - `p` is a pattern variable, or - `p` is a number literal
Fix scala#9769 Fix scala#9833 Fix scala#10389 Fix scala#10897 Fix scala#11163 Fix scala#11556 Fix scala#12474 Fix scala#10994 Fix scala#11729
In Scala 2, a typed pattern `p: T` restricts that `p` can only be a pattern variable. In Dotty, scala#6919 allows `p` to be any pattern, in order to support pattern matching on generic number literals. This PR aligns the syntax with Scala 2 by stipulating that in a typed pattern `p: T`, either - `p` is a pattern variable, or - `p` is a number literal
In Scala 2, a typed pattern `p: T` restricts that `p` can only be a pattern variable. In Dotty, scala#6919 allows `p` to be any pattern, in order to support pattern matching on generic number literals. This PR aligns the syntax with Scala 2 by stipulating that in a typed pattern `p: T`, either - `p` is a pattern variable, or - `p` is a number literal
Minimized code
Output
Expectation
no warning.
the wildcard case produces no warning:
The text was updated successfully, but these errors were encountered: