scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Wrong interaction between compiletime.error and inline values

Open Iltotore opened this issue 1 year ago • 0 comments

Compiler version

Scala 3.1.3

Minimized code & Output

Inline val (error)

inline val str = "test"
compiletime.error(str)
A literal string is expected as an argument to `compiletime.error`. Got str

Inline def (error)

inline def str = "test"
compiletime.error(str)
A literal string is expected as an argument to `compiletime.error`. Got "test":String

Note: this sample works as expected when explicitly specifying the type : "test":

inline def str: "test" = "test"
compiletime.error(str)

Transparent inline def (working)

transparent inline def str = "test"
compiletime.error(str)
test

Expectation

I am not sure this is the expected behaviour since using a FromExpr (or Expr#value) inside a macro works for both inline val and def.

If it is actually expected, then I think the error message should be more explenatory. The error message difference between the two first samples (inline val/def) is also unclear to me.

Iltotore avatar Aug 06 '22 10:08 Iltotore