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

Reflect.ownKeys: order with large integer "index" keys #1580

Merged
merged 1 commit into from
Jun 8, 2018

Conversation

rwaldron
Copy link
Contributor

No description provided.

@ChALkeR
Copy link

ChALkeR commented Jun 4, 2018

Is there any engine that implements it correctly per spec that way?
Perhaps s/integer index/array index/ in the spec for OwnPropertyKeys (and similar, if needed) would be easier?

@rwaldron
Copy link
Contributor Author

rwaldron commented Jun 4, 2018

Even if I spec change were made, we still need to have tests for the current specification.

@rwaldron rwaldron merged commit 3d15371 into master Jun 8, 2018
@ljharb ljharb deleted the reflect-keys-ordering branch June 8, 2018 02:01
@leobalter
Copy link
Member

This should also be covered at least by Object.getOwnPropertyNames and Object.keys.

@mathiasbynens
Copy link
Member

This test doesn't match reality:

Relatedly, I somewhat disagree with this statement:

Even if I spec change were made, we still need to have tests for the current specification.

Having tests is great! However, if it turns out all major engines fail a new test in exactly the same way, then updating the spec to match reality is preferred over merging the test, IMHO.

@rwaldron
Copy link
Contributor Author

@mathiasbynens there is presently a gap in coverage of the spec, which I'm filling. If there had been a test that caught this behavior, written in 2014-2015, it's likely that all implementations would've implemented it correctly (correctly could mean "as it is presently specified" or "according to some newly revised specification").

If there is sufficient support for changing the spec, then it would have to go through the "needs consensus" process. If that happens, we'll immediately update this test to reflect the expected behavior. In the meantime, runtimes are welcome to fix the bug or add this test to their respective "skip lists".

@mathiasbynens
Copy link
Member

@rwaldron I very much appreciate your work on increasing test coverage — in fact, it’s because of your efforts that this discrepancy was discovered in the first place!

If there had been a test that caught this behavior, written in 2014-2015, it's likely that all implementations would've implemented it correctly

I can tell you that at least V8 would not have implemented the currently spec’d behavior. JavaScript engines commonly store array elements (i.e. values mapped to array indices) separately from other properties (such as integer indices outside of the array index range). As such, using array indices in some parts of the spec but then suddenly using the much wider integer index range elsewhere would greatly complicate the implementation. The current spec cannot be implemented in existing engines without major changes, and it would incur a significant performance cost.

In general, if all engines violate the spec in exactly the same way, I’d like the assumption to be “let’s fix the spec to match reality” rather than “let’s merge this test, expect all engines to investigate it individually, add it to their skip lists, and then hopefully update their implementations to match the spec”. Doing it the other way around causes unnecessary churn for Test262 contributors such as yourself as well as for JS engine developers.

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

Successfully merging this pull request may close these issues.

4 participants