WebAssembly / gc

Branch of the spec repo scoped to discussion of GC integration in WebAssembly
https://webassembly.github.io/gc/
Other
982 stars 70 forks source link

[js-api][test] Refine DefaultValue for new reference types #522

Closed takikawa closed 6 months ago

takikawa commented 6 months ago

This PR addresses issue #501 and adjust DefaultValue in the JS API so that it delegates to a embedder API function in the core spec, with a special case for externref to use undefined.

Note that for anyref and other non-externref types it will use null as the default value. For non-null types, it produces error and that is thrown as a TypeError for WebAssembly.Table.prototype.set and WebAssembly.Table.prototype.grow.

Rendered spec change for the core spec:

image

Rendered change for DefaultValue (there are changes to use sites too, not shown):

image

The PR also adds a new WPT test for the error cases specifically. Both Firefox and Chrome passed the test when I tried it out.

takikawa commented 6 months ago

Thanks for the suggestions! Should be updated now:

image image