| Summary: | ES6 Classes: Extends should accept an expression without parenthesis | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Joseph Pecoraro <joepeck> | ||||||
| Component: | JavaScriptCore | Assignee: | Joseph Pecoraro <joepeck> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | ggaren, joepeck, rniwa | ||||||
| Priority: | P2 | ||||||||
| Version: | 528+ (Nightly build) | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Bug Depends on: | |||||||||
| Bug Blocks: | 140491 | ||||||||
| Attachments: |
|
||||||||
I'll take a quick look. The spec says AssignmentExpression and the Parser is doing a PrimaryExpression. Actually, this is a LeftHandSideExpression, according to the latest spec:
ClassHeritage[Yield] :
extends LeftHandSideExpression[?Yield]
Created attachment 248972 [details] [PATCH] Proposed Fix Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-class-definitions Comment on attachment 248972 [details]
[PATCH] Proposed Fix
Oops, I forgot to include expected results.
Created attachment 248973 [details]
[PATCH] Proposed Fix
Comment on attachment 248973 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=248973&action=review > LayoutTests/js/script-tests/class-syntax-extends.js:42 > +shouldThrow('x = 1; c = class extends ++x { };'); Could you add an empty constructor here and the rest of test cases so that this test doesn't depend on the support for default constructor? (In reply to comment #6) > Comment on attachment 248973 [details] > [PATCH] Proposed Fix > > View in context: > https://bugs.webkit.org/attachment.cgi?id=248973&action=review > > > LayoutTests/js/script-tests/class-syntax-extends.js:42 > > +shouldThrow('x = 1; c = class extends ++x { };'); > > Could you add an empty constructor here and the rest of test cases so that > this test doesn't depend on the support for default constructor? I did this for all the tests, and added a few that had the default constructor as well, to test all cases. |
* TEST: var namespace = {}; namespace.A = class A { constructor() { console.log("a"); } }; namespace.B = class B extends namespace.A { constructor() { super(); console.log("b"); } }; new namespace.B(); * EXPECTED Logs for "a" and "b" * ACTUAL SyntaxError: Unexpected token '.'. Expected opening '{' at the start of a class body. * NOTES - Workaround: "class B extends (namespace.A) { ... }" - Works in Chrome 43. I don't know how to test Firefox with Classes.