Well, is this a know issue? or should I file a tic...
# webassembly
a
Well, is this a know issue? or should I file a ticket??
Copy code
val res = try {
     10 / 0
 } catch (_: Throwable) {
    0
 }
 res==0 // true
Fails in
wasmJs
and
wasmWasi
but passes in all other platforms (tested on jvm,js,linux). Funny thing is, changing it to
Copy code
val res = try {
     throw ArithmeticException("No can't do")
 } catch (_: Throwable) {
    0
 }
 res==0 // true
Works on all. Should I file a ticker??
r
There are other types of errors, which are not caught by try/catch with
Throwable
.
e.g.
arrayOf(1)[3]
fails
a
How does one approach errors that can't be caught by try/catch?? the old c way??
r
I think it's a bug.
Just not specific to division by zero but to try/catch in general.
s
I would call this a bug. This behaviour was intentionally implemented as a trap instead of an exception, in order to benchmark performance of the “happy path”, hoping that a special Wasm support will be available to avoid duplicate checks (one in the engine and one in the Wasm code). Now that Kotlin/Wasm is released for more than just benchmarking, I’m thinking it should throw a normal exception by default, and maybe have a flag to do the optimised trapping version.
a
Is the filed ticket enough? Or should I file another one?
s
One is enough 🙂
🙏 1