Add warning for division by zero:

#KT-5529 fixed
This commit is contained in:
Natalia Ukhorskaya
2015-04-24 12:40:11 +03:00
parent cb9c28e73f
commit 9108d87a57
15 changed files with 98 additions and 14 deletions
@@ -0,0 +1,12 @@
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"
}