forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(scala#15784): ident rule for pat match was too strict (scala#19501)
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`.
- Loading branch information
Showing
4 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- [E006] Not Found Error: tests/neg/i15784.scala:2:22 ----------------------------------------------------------------- | ||
2 | case List(_, Rest @ `a`) => Rest // error | ||
| ^^^ | ||
| Not found: a | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E006] Not Found Error: tests/neg/i15784.scala:3:22 ----------------------------------------------------------------- | ||
3 | case List(_, Rest @ A) => Rest // error | ||
| ^ | ||
| Not found: A | ||
| | ||
| longer explanation available when compiling with `-explain` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def i15784 = List(42) match | ||
case List(_, Rest @ `a`) => Rest // error | ||
case List(_, Rest @ A) => Rest // error | ||
case _ => ??? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
def i15784 = List(42) match | ||
case List(_, rest @ _*) => rest | ||
case List(_, Rest @ _*) => Rest | ||
case List(_, `Rest` @ _*) => Rest | ||
case _ => ??? | ||
|
||
def i15784_auxiliary = 42 match | ||
case `type` : Int => `type` |