I just learned about labeled returns in kotlin, and wrote this code example where I have a lambda passed to with, and there's another lambda passed to forEach and I tried to return out of with inside forEach, for some reason the compiler crashes, here's the code:
fun main(args: Array<String>) : Unit {
val l = listOf(listOf(1,2,3), listOf(4,5,6))
val t = label@ with(l) {
get(0).forEach {
return@label 2
}
}
println(t)
}
Should this be allowed in Kotlin at all? Is this a compiler bug?