Open guybedford opened 11 months ago
Here's my best shot at formal trap semantics:
WebAssembly.RuntimeError
the formal trap error, and update all bindgen-level validation functions to throw WebAssembly.RuntimeError
as opposed to generic Error
, TypeError
or RangeError
.WebAssembly.RuntimeError
if it is not already a WebAssembly.RuntimeError
(possibly with a cause
property pointing to the original JS error).WebAssembly.RuntimeError
. If it is, then we rethrow the runtime error as a trap error.WebAssembly.RuntimeError
as well.Even if we don't get to the full trap handling right now, at the very least we can start to formalize WebAssembly.RuntimeError
checks as the primary mechanism where traps are being initiated and caught already currently.
For now, all errors are now TypeError
and we added stricter error coercion in the most recent release where only result<_, string>
is permitted to coerce JS errors for called functions.
We should still ensure that all type validations are traps though (TypeError
at the very least), and working towards that being comprehensively done is an ongoing concern.
We should be stricter about traps in jco.
When a component traps it moves into a trapped state and is no longer callable, so this should be a flagged state of the component.
All call validation errors should also be traps as well, trickling up and setting the trapped flag on call calling components.
In the case or exported function validation errors, these do not need to trap as they happen before entering the component.