-
Notifications
You must be signed in to change notification settings - Fork 692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problematic JS BigInt coercion #1399
Comments
Spec context: https://webassembly.github.io/spec/js-api/#call-an-exported-function calls ToWebAssemblyValue → ToBigInt64 → ToBigInt which throws on
The |
Yes, in Wasm this would be an |
I guess better address this issue to this discussion: https://es.discourse.group/t/why-is-bigint-broken/567/18 |
I don't think that this issue is as specific as the issue OP implies: For example:
or for that matter,
|
Thanks for noting, I overlooked that, since in the specific use case I am describing the value does not matter, as it is only important that the call succeeds (the default value replaces what's is passed). I agree that there is more to think about here. Also, in #1402 (comment) it was noted that Wasm could allow duplicate exports, which seems like a preferable solution over what I suggested here, at least for that specific use case. With duplicate exports, I'd expect the JS/Wasm binding to pick the export with matching arity (not sure if that's a realistic expectation?), so the problem can be worked around fairly easily by exporting both a |
It has recently been reported to me that the JS API for BigInt integration can cause unexpected problems when omitting arguments. Say one has the following Wasm module
and wants to call
exports.test()
externally, with thea
argument omitted for some reason, then the call will fail withWithout some sort of bindings generation, the JS module does not know however that
a
is of typei64
and should be passed a0n
default value. Something similar also happens when the argument is0
, or anothernumber
:So I wonder: Would it be useful to define a coercion from
undefined
to0n
when calling Wasm exports, and perhaps also a coercion fromnumber
? I guess this is not a V8 bug?The text was updated successfully, but these errors were encountered: