Prevent JS optimizer from inserting duplicate variable declarations

This commit is contained in:
Alexey Andreev
2016-03-18 15:45:31 +03:00
parent 4d7906fe44
commit 3571201e9c
4 changed files with 72 additions and 13 deletions
@@ -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"
}