scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.79k stars 1.04k forks source link

Method calling typeCheckErrors fails to compile when error is invoked #13871

Closed Lasering closed 2 years ago

Lasering commented 2 years ago

Compiler version

3.1.0

Minimized code

import scala.compiletime.{error, codeOf}
import scala.compiletime.testing.*

inline def testError(inline typeName: Any): String = error("Got error " + codeOf(typeName))

transparent inline def compileErrors(inline code: String): List[Error] = typeCheckErrors(code)

typeCheckErrors("""testError("string")""")
compileErrors("""testError("string")""")

Scastie Link

Output

-- Error:
9 |compileErrors("""testError("string")""")
  |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |Got error "string"

Expectation

Code should compile.

Related to https://github.com/scalameta/munit/issues/453

nicolasstucki commented 2 years ago

This currently compiles but fails -Ycheck