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

Numeric keys larger than 2**24 - 2*20 + 1 are given as the empty string #87

Closed
bakkot opened this issue Sep 12, 2018 · 3 comments
Closed

Comments

@bakkot
Copy link

bakkot commented Sep 12, 2018

Consider the following program:

let obj = {
  [2**24 - 2**20]: 0,
};

let obj2 = {
  [2**24 - 2**20 + 1]: 0,
};


function isEmptyKey(thing) {
  let keys = Reflect.ownKeys(thing);
  if (keys.length !== 1) throw 'too many keys';
  console.log(keys[0] === '');
}

isEmptyKey(obj);
isEmptyKey(obj2);

This prints false, true. In every other engine, and per the spec, it should be false, false. (No one ever hits the error path; that's just for illustration.)

@phoddie
Copy link
Collaborator

phoddie commented Sep 12, 2018

That seems very obscure! Thanks for the report. We'll take a look.

@bakkot
Copy link
Author

bakkot commented Sep 12, 2018

Note that there's an open question about the order of ownKeys for large integer keys (> 2**32 - 2), though it's not all that closely related to this issue (it's just how I came across it).

@phoddie
Copy link
Collaborator

phoddie commented Sep 12, 2018

Patrick has a fix for this one. We'll push that to GitHub in the next couple days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants