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

Add more static class property ordering tests #3013

Merged
merged 1 commit into from
Jul 16, 2021

Conversation

TimothyGu
Copy link
Member

Since tc39/ecma262#1490, the "length" and "name" properties of a class are defined before any static methods. This is tested by #2057, in test/language/computed-property-names of all places.

At the same time, static methods with "name" as the name would overwrite the original property, but retain the original property enumeration order. This was not previously tested. In fact, the overwriting behavior was not tested at all for the "length" property.

This commit mends both holes in test coverage.

@TimothyGu
Copy link
Member Author

TimothyGu commented Jun 20, 2021

XS and engine262 pass both tests. ChakraCore, GraalJS, JSC, SpiderMonkey, and V8 fail.

Edit: V8 passes after https://chromium-review.googlesource.com/c/v8/v8/+/2974772

$ERROR('Static method should not be executed during definition');
}
static length() {
$ERROR('Static method should not be executed during definition');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use $ERROR like this. throw new Test262Error(...) (This is clearly stated in the contributing docs https://github.com/tc39/test262/blob/main/CONTRIBUTING.md#test-environment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is primarily copied from the existing fn-name-static-precedence.js test, which explains the existence of $ERROR. I can fix it up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the follow up. I just finished eliminating $ERROR from every test file in the project 🤣

@rwaldron
Copy link
Contributor

FWIW, I've updated the linter to check for $ERROR uses.

@rwaldron
Copy link
Contributor

@TimothyGu please @ mention me when you're ready for another review.

Since tc39/ecma262#1490, the "length" and "name"
properties of a class are defined before any static methods. This is
tested by tc39#2057, in test/language/computed-property-names of all places.

At the same time, static methods with "name" as the name would overwrite
the original property, but retain the original property enumeration
order. This was not previously tested. In fact, the overwriting behavior
was not tested at all for the "length" property.

This commit mends both holes in test coverage.
@TimothyGu
Copy link
Member Author

@rwaldron This is ready for another look.

@TimothyGu TimothyGu requested a review from rwaldron July 2, 2021 20:47
@rwaldron rwaldron merged commit 6319cb1 into tc39:main Jul 16, 2021
@TimothyGu TimothyGu deleted the name-length-order branch July 16, 2021 20:24
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.

2 participants