Skip to content
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] ToWebAssemblyValue AO does not convert undefined to 0 #1861

Open
ADKaster opened this issue Dec 23, 2024 · 0 comments
Open

[js-api] ToWebAssemblyValue AO does not convert undefined to 0 #1861

ADKaster opened this issue Dec 23, 2024 · 0 comments

Comments

@ADKaster
Copy link

In https://wpt.fyi/results/wasm/jsapi/global/constructor.any.html?label=experimental&label=master&aligned

Each major browser passes the subtests Explicit value undefined for type {f32, f64, i64}, which expect that an undefined value for value for each of those types will become the value 0.

However, https://webassembly.github.io/spec/js-api/#dom-global-global step 5 says to call ToWebAssemblyValue if and only if the value is missing, not if it is undefined. Thus we should be expecting a different result for the test cases:

Given that every major implementation is treating missing the same as undefined, the spec should probably change.

Otherwise, we would expect

new WebAssembly.Global( { "value": "i64" }, undefined); --> throws TypeError
new WebAssembly.Global({ "value": "f32", undefined); --> NaN
new WebAssembly.Global({ "value": "f64, undefined); --> NaN

As ToWebAssemblyValue calls https://tc39.es/ecma262/multipage/abstract-operations.html#sec-tonumber and https://tc39.es/ecma262/multipage/abstract-operations.html#sec-tobigint64 directly. Neither of those AOs in ES normalize undefined to 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@ADKaster and others