spec icon indicating copy to clipboard operation
spec copied to clipboard

Clarification regarding value parameter for WebAssembly.Global etc.

Open manoskouk opened this issue 2 years ago • 3 comments

Please confirm if the intended behavior for reference-typed WebAssembly.Global is the following:

  • new WebAssembly.Global({ "value": "anyfunc", "mutable": true}).value == null
  • new WebAssembly.Global({ "value": "anyfunc", "mutable": true}, undefined) throws TypeError
  • new WebAssembly.Global({ "value": "externref", "mutable": true}).value == undefined

and the omitted/undefined value behaves the same for table.new, table.set, table.grow.

manoskouk avatar Jun 02 '23 07:06 manoskouk

That is my understanding of WebAssembly.Global behavior. It's implied by the behavior of DefaultValue [1].

The Table JS-API methods also have this behavior as well.

[1] https://webassembly.github.io/spec/js-api/index.html#defaultvalue

eqrion avatar Jun 02 '23 14:06 eqrion

Hmm, as far as I can tell from https://webidl.spec.whatwg.org/#create-an-interface-object , the first two should be equivalent (ORA returns <WebAssembly.Global, [GlobalDescriptor { ... }, "missing"]>), but neither Chrome nor Firefox appears to implement that.

CC @annevk @domenic who might know where I misread.

Ms2ger avatar Jun 05 '23 12:06 Ms2ger

Might be further fallout from engines not actually using Web IDL?

annevk avatar Jun 05 '23 13:06 annevk