-
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
Scala 3 does not take arbitrary id in pattern @ binding #15784
Comments
@odersky Do you think the change introduced to Scala2 was intended and should we port it to Scala 3? In my opinion, current behavior is an improvement as we typically expected capitalized names to be a constant value. |
The pre-dotty ticket was scala/bug#8044 The original use case was generated code, but the idea is that in Then Scala 2 also accepts backticked varid:
as opposed to
Test file at https://github.com/scala/scala/blob/2.13.x/test/files/pos/t8044.scala |
This was not intentional. We should keep the Scala 2 rules here. |
close scala#15784 Scala 2 allows backticked identifier and capital identifier in pattern match, but Scala 3 mistakenly prohibited them. For example, the following code is valid in Scala 2, ```scala List(42) match { case List(_, Rest @ _*) => Rest case List(_, `Rest` @ _*) => `Rest` _ => ??? } ``` whereas it resulted in `Not Found Rest` error in Scala 3. This is because the condition to detect wildcard pattern was so strict that it chose the wrong match arm; `case _ => ifExpr`.
close scala#15784 Scala 2 allows backticked identifier and capital identifier in pattern match, but Scala 3 mistakenly prohibited them. For example, the following code is valid in Scala 2, ```scala List(42) match { case List(_, Rest @ _*) => Rest case List(_, `Rest` @ _*) => `Rest` _ => ??? } ``` whereas it resulted in `Not Found Rest` error in Scala 3. This is because the condition to detect wildcard pattern was so strict that it chose the wrong match arm; `case _ => ifExpr`.
close #15784 Scala 2 allows backticked identifier and capital identifier in pattern match, but Scala 3 mistakenly prohibited them. For example, the following code is valid in Scala 2, ```scala List(42) match { case List(_, Rest @ _*) => Rest case List(_, `Rest` @ _*) => `Rest` _ => ??? } ``` whereas it resulted in `Not Found Rest` error in Scala 3. This is because the condition to detect wildcard pattern was so strict that it chose the wrong match arm; `case _ => ifExpr`. [Cherry-picked e236cdd]
Compiler version
3.1.3
Minimized code
Expectation
This syntax upgrade was introduced in scala/scala#4935
The text was updated successfully, but these errors were encountered: