JS: fix bug in temporary variable eliminator
The problem was in considering `a` as trivial in following case: ``` var a = b; ``` However, that's wrong assumption, since `b` can be temporary variable itself which is further substituted by a non-trivial expression.
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1002
|
||||
var log = ""
|
||||
|
||||
fun bar(): A {
|
||||
log += "foo;"
|
||||
return A()
|
||||
}
|
||||
|
||||
class A {
|
||||
fun f() {
|
||||
log += "f;"
|
||||
}
|
||||
|
||||
fun g() {
|
||||
log += "g;"
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> with(x: T, a: T.() -> Unit) = x.a()
|
||||
|
||||
fun box(): String {
|
||||
with(bar()) {
|
||||
f()
|
||||
g()
|
||||
}
|
||||
|
||||
if (log != "foo;f;g;") return "fail: $log"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user