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

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

bakkot opened this issue Sep 12, 2018 · 3 comments

Comments

@bakkot
Copy link

@bakkot 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 phoddie commented Sep 12, 2018

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

Loading

@bakkot
Copy link
Author

@bakkot 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).

Loading

@phoddie
Copy link
Collaborator

@phoddie phoddie commented Sep 12, 2018

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

Loading

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

Successfully merging a pull request may close this issue.

None yet
2 participants