JVM_IR: Fix stack underflow for unit coercion of when expressions.
Code such as ``` val b = getBoolean() if (b) 4 else if (b) 5 ``` didn't generate a value on the stack always and therefore would have control-flow paths leading to a pop instruction with nothing on the stack. Change-Id: I09d059f361e56a41880006e3f4e51e9acdbd167d
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
var result = "FAIL"
|
||||
val d = 0.0
|
||||
|
||||
fun test(arg: Int) {
|
||||
if (arg == 1) {
|
||||
result = "firstResult"
|
||||
d
|
||||
} else if (arg == 2) {
|
||||
result = "secondResult"
|
||||
arg
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(1)
|
||||
if (result != "firstResult")
|
||||
return "FAIL1"
|
||||
test(2)
|
||||
if (result != "secondResult")
|
||||
return "FAIL2"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user