syscall/js: zero Value is interpreted as NaN instead of Undefined #28174
Labels
arch-wasm
WebAssembly issues
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (same on
tip
)What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
What did you see instead?
Description
Currently,
ref
type codes of JS values inwasm
are arranged in a way that makes a zero value aNaN
number instead ofundefined
.This breaks established Go semantics where a zero pointer value of a type is assumed to have a
nil
value (JS default value isundefined
).To illustrate the difference, consider the case:
However, this code does not work in the current implementation:
Proposed solution
Remap JS value type enum to list
undefined
as a first type code (= 0
) and moveNaN
to a different type code.CC @neelance
The text was updated successfully, but these errors were encountered: