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?
The algorithm ToWebAssemblyValue has the following specification for
i31:What does "v is equal to ToInt32(v)" exactly mean?
ToInt32(-0)is+0. Is+0equal to-0? JS would say yes (-0 === +0), however, it is an important property that if a parameter is typedexternreforanyref,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
-0in many cases (for clarity?), maybe this algorithm should do the same?