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

Restore class field tests: public, private (+static) #1660

Merged
merged 40 commits into from
Aug 21, 2018

Conversation

rwaldron
Copy link
Contributor

@rwaldron rwaldron commented Jul 30, 2018

Most of this was removed previously, but can now be restored and updated.

This is a work in progress

I've tagged @leobalter and @spectranaut for review, but I'm not actually ready for review yet.

@rwaldron rwaldron requested review from leobalter and spectranaut and removed request for leobalter July 30, 2018 22:45
@rwaldron
Copy link
Contributor Author

rwaldron commented Aug 1, 2018

@anba If you have any opportunity to review, I always appreciate your time and efforts :)

@littledan littledan mentioned this pull request Aug 6, 2018
6 tasks
@rwaldron
Copy link
Contributor Author

rwaldron commented Aug 6, 2018

This now contains tests for grammar that's blocked by tc39/proposal-static-class-features#37

I just assume that the issue will be resolved and the syntax will match what is shown in the readme of the proposal.

@rwaldron rwaldron force-pushed the restore-spectranaut-tests branch from 1156999 to a24bba2 Compare August 6, 2018 18:23
@anba
Copy link
Contributor

anba commented Aug 8, 2018

@anba If you have any opportunity to review, I always appreciate your time and efforts :)

I haven't read any of the test files, but when executing them, I got the following errors. :-)

test/language/expressions/class/fields-after-same-line-gen-rs-static-method-privatename-identifier-alt.js
etc.

  • Assignment to #stored, but #stored is never defined.

test/language/expressions/class/fields-after-same-line-gen-static-private-methods.js
etc.

  • Declares static #y(){}, but then assigns to #y, which is not allowed, because private name methods are non-writable.
  • This means the test always throws a TypeError when executing this.#y = value;.

test/language/expressions/class/fields-computed-name-propname-constructor.js
test/language/expressions/class/fields-computed-name-static-propname-constructor.js
etc.

test/language/expressions/class/static-private-fields-proxy-default-handler-throws.js

  • Needs to invoke the method: C.x -> C.x().
  • And for the proxy: P.x -> P.x()

test/language/expressions/class/syntax-error-grammar-field-def-has-initializer-no-sc.js
etc.

  • Test expects x = [] is an early syntax error.
  • I assume "no-sc" means "no-super-call" (?), but no super-call is present in the test files.

test/language/expressions/class/syntax-error-grammar-field-no-initializer-with-method.js
etc.

  • Test expects x <newline> m(){} is an early syntax error.
  • No idea where this restriction is supposed to come from, unless ASI shouldn't apply at all for class fields?

test/language/expressions/class/syntax-error-grammar-fields.js
test/language/expressions/class/syntax-error-grammar-privatename.js
test/language/expressions/class/syntax-error-grammar-privatenames.js

  • Missing error flags in YAML block.

Complete errors with stacktraces -> https://gist.github.com/anba/9045b8ce023eabd9cb90920c4427923b

@rwaldron
Copy link
Contributor Author

@anba Thank! I'll check on these today :)

@rwaldron
Copy link
Contributor Author

  • Assignment to #stored, but #stored is never defined.

This was corrected in a recent push to the WIP branch.

  • Declares static #y(){}, but then assigns to #y, which is not allowed, because private name methods are non-writable.
  • This means the test always throws a TypeError when executing this.#y = value;.

This was corrected in a recent push to the WIP branch.

test/language/expressions/class/fields-computed-name-propname-constructor.js
test/language/expressions/class/fields-computed-name-static-propname-constructor.js
etc.

Dropped

test/language/expressions/class/static-private-fields-proxy-default-handler-throws.js

  • Needs to invoke the method: C.x -> C.x().
  • And for the proxy: P.x -> P.x()

Will be fixed in next push

test/language/expressions/class/syntax-error-grammar-field-def-has-initializer-no-sc.js
etc.

  • Test expects x = [] is an early syntax error.
  • I assume "no-sc" means "no-super-call" (?), but no super-call is present in the test files.

"no semi-colon" ;)

...But I'm seeing now that some of these are missing the offending ClassElement or FieldDefinition necessary for the syntax error exception. I'm going to work on those as well.

test/language/expressions/class/syntax-error-grammar-field-no-initializer-with-method.js
etc.

  • Test expects x m(){} is an early syntax error.
  • No idea where this restriction is supposed to come from, unless ASI shouldn't apply at all for class fields?

This was corrected in a recent push to the WIP branch.

test/language/expressions/class/syntax-error-grammar-fields.js
test/language/expressions/class/syntax-error-grammar-privatename.js
test/language/expressions/class/syntax-error-grammar-privatenames.js

Missing error flags in YAML block.

These don't exist anymore, so I guess "problem solved!". I will check to make sure the missing YAML didn't surface in some other files.

@rwaldron rwaldron force-pushed the restore-spectranaut-tests branch from 83a999e to c0509ff Compare August 10, 2018 16:04
Copy link
Member

@leobalter leobalter left a comment

Choose a reason for hiding this comment

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

All the issues I'm finding are not blockers for moving on. The tests are looking correct.

\u{6F} = 3;
℘ = 4; // DO NOT CHANGE THE NAME OF THIS FIELD
ZW_‌_NJ = 5; // DO NOT CHANGE THE NAME OF THIS FIELD
ZW_‍_J = 6; // DO NOT CHANGE THE NAME OF THIS FIELD
Copy link
Member

Choose a reason for hiding this comment

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

the most lovable variable names in the world.

// This code is governed by the BSD license found in the LICENSE file.

/*---
desc: SyntaxError
Copy link
Member

Choose a reason for hiding this comment

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

I wish the description could be a bit longer here

// This code is governed by the BSD license found in the LICENSE file.

/*---
desc: No space allowed between sigial and IdentifierName
Copy link
Member

Choose a reason for hiding this comment

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

typo, sigial

var x = "string";
class C {
[x] = /*{ initializer }*/;
}
Copy link
Member

Choose a reason for hiding this comment

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

thanks for fixing this

---*/

//- fields
static async #$(value) {
Copy link
Member

Choose a reason for hiding this comment

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

It's so weird that we are matching proposals to have static private methods, but in any case, bring it on.


template: productions
flags: [async]
features: [class-static-methods-private]
Copy link
Member

Choose a reason for hiding this comment

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

I'm glad we have proper flags for these

@anba
Copy link
Contributor

anba commented Aug 17, 2018

Updated list of test failures: https://gist.github.com/anba/42051c5232bec1ac5bfde560995ac586

src/class-fields/rs-static-async-generator-method-privatename-identifier-alt.case

  • Uses async, but instead needs to use async* to declare async generator methods.

test/language/expressions/class/fields-after-same-line-gen-rs-static-generator-method-privatename-identifier-alt.js (multiple files with the same error)

  • Needs to use yield* if delegating yield semantics are intended.
  • (The test assumes (function*() { yield function*(){ yield 0; }()})() === 1 is true, which is obviously incorrect.)

test/language/expressions/class/fields-after-same-line-gen-static-private-methods.js (multiple files with the same error)

  • Has assignment to private name method, which is not allowed and throws a TypeError at runtime.

test/language/expressions/class/fields-after-same-line-static-async-gen-rs-static-async-generator-method-privatename-identifier.js (multiple files with the same error)

  • Calls $DONE() multiple times.

test/language/statements/class/syntax-invalid-grammar-field-def-has-initializer-no-sc-error.js (multiple files with the same error)

  • Test incorrectly assumes x = [] <line-break> y; is a SyntaxError.

@leobalter
Copy link
Member

Test incorrectly assumes x = [] y; is a SyntaxError.

That's a reading from @rwaldron of the proposed syntax:

  ClassElement :
    MethodDefinition
    static MethodDefinition
    FieldDefinition ;
    ;

where this reads the sc char in FieldDefinition ; as not optional. While I understand his PoV, I agree the grammar is beat by other parts like the do-while statement which has a sc in a point known for ASI.

That grammar formatting might need work, but this would be a side-tracking for this PR.

If you want to stick to the bikeshedding, we could think on possible alternatives for the trailing ; that is a clear signal for separating fields with ; if they are in the same line. The alternative I have in mind is ridiculously verbose, thou:

ClassElement :
  MethodDefinition
  static MethodDefinition
  FieldDefinitionList
  ;

FieldDeclarationList :
  FieldDeclarationOthers_opt FieldDeclaration

FieldDeclarationOthers :
  FieldDeclarationList [no LineTerminator here ] ; [no LineTerminator here ] FieldDeclaration

I'm not sure if that really works as the idea is to prevent multiple fields on the same line without a separator, but that's also kind weird as we can stack multiple methods with a field in the same line: class C { m1() {} m2() {} }.

As I stated before, I wish the sc could have avoided as an element of ClassElement, but that's a battle lost since ES2015.

@leobalter
Copy link
Member

@anba I tried to fix all the parts you mentioned. Can you help me there with another review, please?

@leobalter leobalter changed the title WIP: Restore class field tests: public, private (+static) Restore class field tests: public, private (+static) Aug 20, 2018
@leobalter
Copy link
Member

If it helps, I ran the tests using es6draft and found no errors on the tests for this PR.

Valerie R Young and others added 11 commits August 20, 2018 16:38
# Conflicts:
#	src/class-fields/init-err-contains-super.case
# Conflicts:
#	src/class-fields/eval-err-contains-arguments.case
#	src/class-fields/eval-err-contains-supercall-1.case
#	src/class-fields/eval-err-contains-supercall-2.case
#	src/class-fields/eval-err-contains-supercall.case
#	src/class-fields/eval-err-contains-superproperty-1.case
#	src/class-fields/eval-err-contains-superproperty-2.case
# Conflicts:
#	src/class-fields/propname-constructor.case
#	src/class-fields/propname-error/cls-decl-computed-name.template
#	src/class-fields/propname-error/cls-decl-literal-name.template
#	src/class-fields/propname-error/cls-decl-string-name.template
#	src/class-fields/propname-error/cls-expr-computed-name.template
#	src/class-fields/propname-error/cls-expr-literal-name.template
#	src/class-fields/propname-error/cls-expr-string-name.template
# Conflicts:
#	src/class-fields/propname-error/cls-decl-variable-name.template
#	src/class-fields/propname-error/cls-expr-variable-name.template
# Conflicts:
#	src/class-fields/default/cls-decl-after-same-line-async-gen.template
#	src/class-fields/default/cls-decl-after-same-line-async-method.template
#	src/class-fields/default/cls-decl-after-same-line-gen.template
#	src/class-fields/default/cls-decl-after-same-line-method.template
#	src/class-fields/default/cls-decl-after-same-line-static-async-gen.template
#	src/class-fields/default/cls-decl-after-same-line-static-async-method.template
#	src/class-fields/default/cls-decl-after-same-line-static-gen.template
#	src/class-fields/default/cls-decl-after-same-line-static-method.template
#	src/class-fields/default/cls-decl-multiple-definitions.template
#	src/class-fields/default/cls-decl-multiple-stacked-definitions.template
#	src/class-fields/default/cls-decl-new-no-sc-line-method.template
#	src/class-fields/default/cls-decl-new-sc-line-generator.template
#	src/class-fields/default/cls-decl-new-sc-line-method.template
#	src/class-fields/default/cls-decl-regular-definitions.template
#	src/class-fields/default/cls-decl-same-line-generator.template
#	src/class-fields/default/cls-decl-same-line-method.template
#	src/class-fields/default/cls-decl-wrapped-in-sc.template
#	src/class-fields/default/cls-expr-after-same-line-async-gen.template
#	src/class-fields/default/cls-expr-after-same-line-async-method.template
#	src/class-fields/default/cls-expr-after-same-line-gen.template
#	src/class-fields/default/cls-expr-after-same-line-method.template
#	src/class-fields/default/cls-expr-after-same-line-static-async-gen.template
#	src/class-fields/default/cls-expr-after-same-line-static-async-method.template
#	src/class-fields/default/cls-expr-after-same-line-static-gen.template
#	src/class-fields/default/cls-expr-after-same-line-static-method.template
#	src/class-fields/default/cls-expr-multiple-definitions.template
#	src/class-fields/default/cls-expr-multiple-stacked-definitions.template
#	src/class-fields/default/cls-expr-new-no-sc-line-method.template
#	src/class-fields/default/cls-expr-new-sc-line-generator.template
#	src/class-fields/default/cls-expr-new-sc-line-method.template
#	src/class-fields/default/cls-expr-regular-definitions.template
#	src/class-fields/default/cls-expr-same-line-generator.template
#	src/class-fields/default/cls-expr-same-line-method.template
#	src/class-fields/default/cls-expr-wrapped-in-sc.template
#	src/class-fields/private-names.case
# Conflicts:
#	test/language/statements/class/classelementname-abrupt-completion.js
#	test/language/statements/class/fielddefinition-initializer-abrupt-completion.js
#	test/language/statements/class/super-fielddefinition-initializer-abrupt-completion.js
rwaldron and others added 8 commits August 20, 2018 16:38
- needs to use async* to declare async generator methods.
- Needs to use yield* if delegating yield semantics are intended.
- Has assignment to private name method, which is not allowed and throws a TypeError at runtime.
- handle multiple $DONE calls
- fix calls to private methods
@leobalter
Copy link
Member

leobalter commented Aug 20, 2018

Travis CI is getting me some weird results as it appears to be comparing with another commit. I'm rebasing this locally and rolling a force push to see if anything changes for Travis.

In any case, I have a local backup of the previous commits from this branch.

@leobalter leobalter force-pushed the restore-spectranaut-tests branch from bdd4cc5 to de1bbd6 Compare August 20, 2018 20:41
@leobalter
Copy link
Member

The last commits should fix the problem. I had templates using the same path value. Thanks @jugglinmike for helping me finding the bug.

@anba
Copy link
Contributor

anba commented Aug 21, 2018

If it helps, I ran the tests using es6draft and found no errors on the tests for this PR.

Hmm, the current version on GH is probably missing some fixes. With my local development version, I still get the following failures: https://gist.github.com/anba/25a51ad514b91870bdcb89f3ad478ed4

Most of the failures happen because rs-static-async-generator-method-privatename-identifier.case passes the value 1 to yield* (there's yield * await value with value = 1).

@leobalter
Copy link
Member

@anba I think 7ea8043 should fix this. Please let me know.

@anba
Copy link
Contributor

anba commented Aug 21, 2018

There seems to be a similar issue in rs-static-generator-method-privatename-identifier-alt.case and rs-static-generator-method-privatename-identifier.case (maybe more, I've stopped after those two files).

Additionally there are still some invalid property name tests:

  • test/language/expressions/class/fields-computed-name-static-propname-prototype.js
  • test/language/statements/class/fields-computed-name-propname-constructor.js
  • test/language/statements/class/fields-computed-name-static-computed-var-propname-constructor.js
  • test/language/statements/class/fields-computed-name-static-computed-var-propname-prototype.js
  • test/language/statements/class/fields-computed-name-static-propname-constructor.js
  • test/language/statements/class/fields-computed-name-static-propname-prototype.js
  • test/language/statements/class/privatefields-string-name-propname-constructor.js

@anba
Copy link
Contributor

anba commented Aug 21, 2018

I see only a single remaining failure (test/language/statements/class/privatefields-string-name-propname-constructor.js incorrectly assume ["#constructor"] is not valid). 👍

@leobalter
Copy link
Member

I see only a single remaining failure (test/language/statements/class/privatefields-string-name-propname-constructor.js incorrectly assume ["#constructor"] is not valid).

Thanks! I was still working on it, but I wanted to understand what that file was doing. In the process I even found a duplicate for checking privatenames of #constructor

@leobalter
Copy link
Member

@anba I believe this will be good to go for a final review. Thank you so much for all the support.

@anba
Copy link
Contributor

anba commented Aug 21, 2018

Zero failures with the latest commit!

@leobalter
Copy link
Member

leobalter commented Aug 21, 2018

I'm getting a pretty positive feedback from parts I can test from other engines, so I'm honestly assuming this is good to ship for now. I'd be happy to address any eventual bug if we find something.

@leobalter leobalter merged commit d296cc9 into tc39:master Aug 21, 2018
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.

3 participants