WebAssembly / WebAssembly/spec

[js-api] Unclear spec for `-0` in `ToWebAssemblyValue`?

Open
#1,984 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
3.5k
Forks
539
Avg merge
2d 1h
Merged PRs (30d)
13

Description

The algorithm ToWebAssemblyValue has the following specification for i31:

7.4. Else if v is a Number and v is equal to ? ToInt32(v) and (v) < 2^30 and (v) ⩾ -2^30,

What does "v is equal to ToInt32(v)" exactly mean? ToInt32(-0) is +0. Is +0 equal to -0? JS would say yes (-0 === +0), however, it is an important property that if a parameter is typed externref or anyref, ToWebAssemblyValue() should not have any observable side effects on JS values (especially when passing it back to JS).

The ECMAScript spec seems to explicitly list -0 in many cases (for clarity?), maybe this algorithm should do the same?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the ToWebAssemblyValue algorithm and the cited ECMAScript ToInt32 definition, focusing on how -0 is treated. Done means resolving and documenting the intended equality semantics in the specification; the payload names no file or test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, wasm
Domain
api, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.