Marc
09/12/2025, 11:41 AMfun main() {
ubyteArrayOf(
*listOf(ubyteArrayOf())[0]
)
}
results in:
Unhandled JavaScript exception: listOf(...).get_c1px32_k$(...).slice is not a function
https://pl.kotl.in/nEyBqjkBZ
The same code works just fine when replacing ubyteArrayOf with byteArrayOf or running it on JVM instead.Edoardo Luppi
09/12/2025, 12:28 PMUByteArray is just a Int8Array under the hood, just treated differently at runtime.
This works:
fun main() {
val array = listOf(UByteArray(16) { 0u })[0]
ubyteArrayOf(*array)
}
So to me it's a compiler bug.Marc
09/12/2025, 12:29 PMEdoardo Luppi
09/12/2025, 12:30 PMMarc
09/12/2025, 12:31 PMEdoardo Luppi
09/12/2025, 12:31 PMEdoardo Luppi
09/12/2025, 12:38 PMlistOf(new UByteArray(tmp$ret$0)).get_c1px32_k$(0).storage_1Edoardo Luppi
09/12/2025, 12:39 PMMarc
09/12/2025, 12:45 PMMarc
09/12/2025, 12:46 PMfun main() {
println(
ubyteArrayOf(
*UByteArray(16) { 0u },
*listOf(ubyteArrayOf())[0],
).joinToString(prefix = "[", postfix = "]")
)
}
The array is just empty when doing this. Without the extra array it throws the same issue as before.Edoardo Luppi
09/12/2025, 12:48 PMubyteArrayOf(*listOf(ubyteArrayOf())[0])Marc
09/12/2025, 12:49 PM