Skip to content
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

Type pattern example no longer works #20418

Open
j-mie6 opened this issue May 15, 2024 · 0 comments
Open

Type pattern example no longer works #20418

j-mie6 opened this issue May 15, 2024 · 0 comments
Labels

Comments

@j-mie6
Copy link

j-mie6 commented May 15, 2024

Compiler version

3.4.1 (note I am using -Ykind-projector:underscores, if that's relevant)

Minimized code

The example from https://docs.scala-lang.org/scala3/reference/metaprogramming/macros.html#type-patterns-1

import scala.quoted.*
def empty[T: Type](using Quotes): Expr[T] =
  Type.of[T] match
    case '[String] => '{ "" }
    case '[List[t]] => '{ List.empty[t] }
    case '[type t <: Option[Int]; List[t]] => '{ List.empty[t] }

Output

Each of the '{} produces a type error for "expected T, got {String, List[t]}" but the example in the docs seems to suggest that T is known to be String/List[t] in those paths!

Expectation

This should compile fine. Note that adding an asExprOf[T] makes it work, but is far from ideal.

@j-mie6 j-mie6 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 15, 2024
@Gedochao Gedochao added area:documentation area:metaprogramming:quotes Issues related to quotes and splices and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 17, 2024
@jchyb jchyb assigned jchyb and unassigned jchyb May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants