Skip to content

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

Description

@Liedtke

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions