Skip to content

Commit

Permalink
fix: throw an error before assigning ErrorType when expanding constValue
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperFKorban committed Aug 12, 2024
1 parent b981231 commit e66860b
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 e66860b

Please sign in to comment.