Order of evaluation differs for JVM and Javascript backend --- is it a bug or a feature?


#1
var s = ""

fun a():String {
  s += "A"
  return ""
}

fun b():String {
  s += "B"
  return ""
}

fun c():String {
  s += "C"
  return ""
}


fun main(args : Array) {
  var res = (if(true) {a()} else "") + b() + (if (true) {c()} else "")
  println("s=${s}") // Java -> "ABC", Javascript -> "ACB"
}

Are their behavior well-defined somewhere in specification?


#2

Of Course it's bug.

Please file a bug to our tracker

Thanks!