-
Notifications
You must be signed in to change notification settings - Fork 454
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
js-api tests for externref #1620
Comments
There's also a test case here for default JS-API values for globals:
My reading of the JS-API spec is that the default value of externref is 'undefined' because that's what omitted parameters in JS give, and that's a valid non-null externref value. So I'd expect in both of these test cases that the default value would be undefined, not null. However Chrome/Firefox/Safari currently give different results:
|
Let's look at the spec: both Global and Table have:
DefaultValue:
and ToWebAssemblyValue returns a non-null externref for Unless there's a compelling reason to change, I'd say this seems fine and the bugs in implementation should be fixed. I'm surprised to see there's no tests for either case; they should be in |
I'd argue this definition of DefaultValue is a bug, because it doesn't match what the core spec defines as default value. |
Oh, I recalled one good reason to keep the current behavior - the following are defined to be equivalent in IDL: const table = new WebAssembly.Table(argument);
const table = new WebAssembly.Table(argument, undefined); so if you treated |
Yes, that's why the |
The default value of This is very strange and inconsistent behavior. @Ms2ger's point about the second param being implicitly For example, this gist produces this output. Hopefully the results in each section are self-explanatory.
Key things to note:
If |
I'm trying to find (and add?) tests for init arguments for Table/Global constructors/methods that were introduced by reference-types proposal.
The https://webassembly.github.io/spec/js-api/index.html#dom-table-table defines the initial ref value to be
ToWebAssemblyValue(undefined, externref)
, which is resolved to someref.extern
(notnull
).Is this a mistake and the above default value has to be
null
? If it is not a mistake, what the following test must produce?The text was updated successfully, but these errors were encountered: