-
Notifications
You must be signed in to change notification settings - Fork 67
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] DefaultValue needs updating #501
Comments
The JS-API default value function is slightly different than wasm's default value function. |
Fair enough, but it would still be preferable to handle only this special case here and then defer to the core spec for all regular cases. (Although personally I still think this special case is odd and instead it should only use undefined if explicitly given, not as default. There is precedence in JS for treating an absent parameter differently from explicit undefined, e.g., |
DefaultValue will return undefined for externref as before, but for other nullable reference types will return null. For non-nullable reference types, operations like grow and set should error if the value to set is missing. Also adds WPT tests for the error cases. This requires some updates to wasm-module-builder.js as well. Fixes issue WebAssembly#501
The DefaultValue algorithm needs updating to handle more general reference types. Moreover, it is partial now, so all use sites need to adapt to the possibility of it failing.
@takikawa
Also, this algorithm is unrelated to JS and in fact duplicates the respective definition in the core spec. It might be preferable to expose that in the core spec's embedding interface and call into that.
The text was updated successfully, but these errors were encountered: