Files
kotlin-fork/js/js.translator/testData/box/jsCode/break.kt
T
Svyatoslav Kuzmich cb3b1f8ae2 [JS IR] Fix referencing Kotin variables in inline JS code
Fixed by outlining JS code that uses Kotlin variables making usages of
these locals explicit and preventing bugs due to one-sided variable renaming.

This prevents using Kotlin variables as lvalue in JS code.
2021-01-25 19:18:44 +03:00

21 lines
307 B
Kotlin
Vendored

// IGNORE_BACKEND: JS_IR
// EXPECTED_REACHABLE_NODES: 1282
package foo
fun box(): String {
var c: Int = 0
js("""
for (var i = 0; i < 10; i++) {
c = i;
if (i === 3) {
break;
}
}
""")
assertEquals(3, c)
return "OK"
}