Prevent JS optimizer from inserting duplicate variable declarations
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
package foo
|
||||
|
||||
// CHECK_VARS_COUNT: function=test_za3lpa$ count=2
|
||||
|
||||
inline fun if1(f: (Int) -> Int, a: Int, b: Int, c: Int): Int {
|
||||
val result = f(a)
|
||||
|
||||
if (result == b) {
|
||||
return f(a)
|
||||
}
|
||||
|
||||
return f(c)
|
||||
}
|
||||
|
||||
fun test(x: Int): Int {
|
||||
val test1 = if1({ it }, x, 2, 3)
|
||||
return test1
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = test(2)
|
||||
if (result != 2) return "fail1: $result"
|
||||
|
||||
result = test(100)
|
||||
if (result != 3) return "fail2: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user