Files
kotlin-fork/compiler/testData/debug/localVariables/catchClause.kt
T
Alexander Korepanov 79d378f2bd [JS IR] Perform optimizations on the generated JS code
The patch adopts and reuses the optimizations from the legacy backend.

The optimizations remove useless temporary variables,
statements and simplify generated JS code.

The optimizations can be disabled by `-Xoptimize-generated-js=false`.

Related to KT-51139
2023-04-18 12:49:33 +00:00

30 lines
720 B
Kotlin
Vendored

// FILE: test.kt
fun box() {
try {
var a = 1
a --
a /= a
throw ArithmeticException() // Division by 0 doesn't throw in JS, so throw explicitly
} catch(e : Throwable) {
e.printStackTrace()
}
}
// EXPECTATIONS JVM JVM_IR
// test.kt:3 box:
// test.kt:4 box:
// test.kt:5 box: a:int=1:int
// test.kt:6 box: a:int=0:int
// test.kt:8 box:
// test.kt:9 box: e:java.lang.Throwable=java.lang.ArithmeticException
// test.kt:11 box:
// EXPECTATIONS JS_IR
// test.kt:4 box:
// test.kt:5 box: a=1:number
// test.kt:6 box: a=0:number
// test.kt:7 box: a=0:number
// test.kt:8 box: a=0:number
// test.kt:8 box: a=0:number
// test.kt:9 box: a=0:number, e=kotlin.ArithmeticException