Skip to content

"Compiler bug" when using constValue inside an inline method #12417

Closed
@adamw

Description

@adamw

Compiler version

3.0.0-RC3

Minimized code

import scala.deriving.Mirror
import scala.compiletime.{constValue, error}
import scala.quoted.*

object TestMacro {
  inline def test1[CASE_CLASS <: Product](using m: Mirror.ProductOf[CASE_CLASS]): Unit = {
    error(s"Error: ${constValue[m.MirroredElemLabels]}.")
  }
}

object Test extends App {
  case class A(x: String, y: Int)
  TestMacro.test1[A]
}

This comes from an attempt to provide user-friendly error messages for inline derivations which use mirrors.

Output

[error] -- Error: Test.scala:14:2 
[error] 14 |  TestMacro.test1[A]
[error]    |  ^^^^^^^^^^^^^^^^^^
[error]    |  Compiler bug: `constValue` was not evaluated by the compiler
[error] -- Error: Test.scala:14:2 
[error] 14 |  TestMacro.test1[A]
[error]    |  ^^^^^^^^^^^^^^^^^^
[error]    |not a constant type: m$proxy1.MirroredElemLabels; cannot take constValue

Expectation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions