Closed
Description
Compiler version
3.4.0 and 3.3.3
Minimized code
new Array[Unit](1)
Original code that showed the bug
val arr = new Array[Unit](7)
var i: Int = 0
while (i < 7) {
arr(i) = ()
i += 1
}
arr
Output
[info] org.scalajs.linker.runtime.UndefinedBehaviorError: java.lang.ClassCastException: [V cannot be cast to Ljava.lang.Void;
[info] at $throwClassCastException(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:52:9)
[info] at $throwArrayCastException(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:58:3)
[info] at $asArrayOf_jl_Void(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:2774:70)
[info] at ScalaJSError.testFun$proxy1$1(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:105391:13)
[info] at {anonymous}()(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:105409:50)
[info] at scala.scalajs.runtime.AnonFunction0.apply(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:55040:43)
[info] at org.scalatest.Transformer.apply(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:73077:63)
[info] at org.scalatest.Transformer.apply(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:73099:15)
[info] at org.scalatest.funsuite.AnyFunSuiteLike$$anon$1.apply(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:62507:166)
[info] at org.scalatest.funsuite.AnyFunSuiteLike.invokeWithFixture$1(D:\DevProjects\Stable\perspective\dotty\derivation\.js\target\scala-3.3.3\perspective-derivation-test-fastopt\main.js:103960:15)
Expectation
It runs and creates the array