Skip to content

Commit

Permalink
fix: throw an error before assigning ErrorType when expanding constVa…
Browse files Browse the repository at this point in the history
…lue (#21364)

fixes #21359
  • Loading branch information
jchyb authored Sep 12, 2024
2 parents 4891858 + e66860b commit e9d4831
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/inlines/Inlines.scala
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ object Inlines:
val constVal = tryConstValue(tpe)
if constVal.isEmpty then
val msg = NotConstant("cannot take constValue", tpe)
report.error(msg, callTypeArgs.head.srcPos)
ref(defn.Predef_undefined).withSpan(callTypeArgs.head.span).withType(ErrorType(msg))
else
constVal
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i21359.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import scala.compiletime.constValueTuple
import scala.deriving.Mirror

case class Hello(a: Int)
val mirror = summon[Mirror.Of[Hello]]
val test = constValueTuple[mirror.MirroredElemTypes] // error

0 comments on commit e9d4831

Please sign in to comment.