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

WIP fix(pass-style,marshal): -0 should round trip distinct from 0 #1626

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/marshal/src/encodePassable.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const CanonicalNaNBits = 'fff8000000000000';
*/
const encodeBinary64 = n => {
// Normalize -0 to 0 and NaN to a canonical encoding
// TODO https://github.com/endojs/endo/issues/1602
if (is(n, -0)) {
n = 0;
} else if (is(n, NaN)) {
Expand Down
1 change: 1 addition & 0 deletions packages/marshal/src/encodeToCapData.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const makeEncodeToCapData = (encodeOptions = {}) => {
return { [QCLASS]: '-Infinity' };
}
// Pass through everything else, replacing -0 with 0.
// TODO https://github.com/endojs/endo/issues/1602
return is(passable, -0) ? 0 : passable;
}
case 'bigint': {
Expand Down
1 change: 1 addition & 0 deletions packages/marshal/src/encodeToSmallcaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export const makeEncodeToSmallcaps = (encodeOptions = {}) => {
return '#-Infinity';
}
// Pass through everything else, replacing -0 with 0.
// TODO https://github.com/endojs/endo/issues/1602
return is(passable, -0) ? 0 : passable;
}
case 'bigint': {
Expand Down
2 changes: 2 additions & 0 deletions packages/marshal/src/rankOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const { entries, fromEntries, setPrototypeOf, is } = Object;
* abstractions, where NaN is the same as NaN and -0 is the same as
* 0. Marshal serializes -0 as zero, so the semantics of our distributed
* object system does not distinguish 0 from -0.
* TODO https://github.com/endojs/endo/issues/1602
* and revise above comment.
*
* `sameValueZero` is the EcmaScript spec name for this equality comparison,
* but TODO we need a better name for the API.
Expand Down