Files
kotlin/compiler/testData/codegen/box/binaryOp/divisionByZero.kt
Natalia Ukhorskaya 9108d87a57 Add warning for division by zero:
#KT-5529 fixed
2015-05-07 15:41:37 +03:00

12 lines
454 B
Kotlin
Vendored

fun box(): String {
val a1 = 0
val a2 = try { 1 / 0 } catch(e: ArithmeticException) { 0 }
val a3 = try { 1 / a1 } catch(e: ArithmeticException) { 0 }
val a4 = try { 1 / a2 } catch(e: ArithmeticException) { 0 }
val a5 = try { 2 * (1 / 0) } catch(e: ArithmeticException) { 0 }
val a6 = try { 2 * 1 / 0 } catch(e: ArithmeticException) { 0 }
try { val s1 = "${2 * (1 / 0) }" } catch(e: ArithmeticException) { }
return "OK"
}