Skip to content

Quote pattern not matching on *: #19947

Closed
@nicolasstucki

Description

@nicolasstucki

Compiler version

3.4.0

Minimized code

import scala.quoted.*

inline def expandMacro(inline from: Tuple): Any =
  ${ expandMacroImpl }

def expandMacroImpl(using Quotes): Expr[?] =
  '{ 1 *: EmptyTuple } match
    case '{ type t <: Tuple; ($hd: h) *: ($tl: t) } => '{ ??? }
    case x => throw new MatchError(x.show)
def test: Any = expandMacro

Output

-- Error: t/Test2.scala:1:16 ---------------------------------------------------
1 |def test: Any = expandMacro
  |                ^^^^^^^^^^^
  |Exception occurred while executing macro expansion.
  |scala.MatchError: scala.Tuple$package.EmptyTuple.*:[scala.Int, scala.Tuple$package.EmptyTuple.type](1) (of class java.lang.String)
  |     at Test$package$.expandMacroImpl(Test.scala:9)
  |
  |-----------------------------------------------------------------------------
  |Inline stack trace
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |This location contains code that was inlined from Test.scala:4
4 |  ${ expandMacroImpl }
  |  ^^^^^^^^^^^^^^^^^^^^
   -----------------------------------------------------------------------------

Expectation

Should match

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions