forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We compute the pattern using `Expr[pt]` of the prototype `pt` of the splice, but this is not enough to reject non-matching patterns. The quoted splices are encoded away before we get to the pattern matching phase where we could potentially detect that they will not match. Instead we check that all quote patterns are `Expr[..]` when typing the pattern. Fixes scala#19941
- Loading branch information
1 parent
4859415
commit 676b250
Showing
4 changed files
with
15 additions
and
2 deletions.
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,4 @@ | ||
-- Error: tests/neg-macros/i19941.scala:7:14 --------------------------------------------------------------------------- | ||
7 | case '{ ${hd *: tl} : *:[Int, EmptyTuple] } => '{ ??? } // error | ||
| ^^^^^^^^ | ||
| Spice pattern must match an Expr[...] |
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,7 @@ | ||
import scala.quoted.* | ||
|
||
inline def expandMacro(inline from: Tuple): Any = ${ expandMacroImpl } | ||
|
||
def expandMacroImpl(using Quotes): Expr[?] = | ||
'{ 1 *: EmptyTuple } match | ||
case '{ ${hd *: tl} : *:[Int, EmptyTuple] } => '{ ??? } // error |
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