Skip to content

Quoted Patterns: Quote of Unquote is not identity but normalizes #9804

Closed
@b-studios

Description

@b-studios

Given the following function definition

def f[A: Type](e: Expr[A]): Expr[A] = e match {
  case '{ $e2 } => e2
}

we will be warned that

[warn] 35 |      case '{ $e2 } => e2
[warn]    |           ^^^^^^^^
[warn]    |Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ.

but this is not true. Performing pattern matching normalizes the scrutinee, which can be observable by user code (for instance using the reflection API).

We could remove the warning for pattern matching. While this improves the situation that the compiler no longer lies to us,
IMO it only defers the real problem: Non-normalized trees are observable by the user. I would thus prefer a solution that makes the equivalence statement hold, instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions