Closed ddegazio closed 5 months ago
Yes, I think you are exactly right. v128
values can't currently be passed to JS, and there are various other places where we throw similar TypeErrors (e.g. the GetGlobalValue
algorithm, the parameter conversion steps of "call an Exported Function" and "run a host function") before we invoke ToJSValue. It might make sense to sink that check into ToJSValue
itself, but I haven't checked whether there are any places where e.g. we wouldn't be able to throw from there. But assuming we don't do that, then yeah, getArg
should have the check, and also the Exception
constructor (because ToWebAssemblyValue
has a similar assertion). I can make a fix for that.
Oh oops, it looks like this is the same issue as #295. Guess we just neglected to land the fix then.
Per the current spec, when we call
WebAssembly.Exception.getArg
, we get apayload
fromexn_read
, and invokeToJSValue
on an element of it.From the definition of
exn_read
, the returned element we use for the payload is the field tuple from the exception instance, which is just some number of ordinary WebAssembly valuesval*
.But, in
ToJSValue
, we start off with this assertion:Since
v128
is an ordinary WebAssembly value type, it seems valid currently for one to occur in the return tuple ofexn_read
. But then,getArg
funnels that value directly intoToJSValue
, violating its invariants. I might be overlooking something? Otherwise, it seems like there should probably be a check forv128
elements ingetArg
which throws aTypeError
.