Changeset 199927 in webkit


Ignore:
Timestamp:
Apr 22, 2016 4:04:55 PM (8 years ago)
Author:
ggaren@apple.com
Message:

super should be available in object literals
https://bugs.webkit.org/show_bug.cgi?id=156933

Reviewed by Saam Barati.

Source/JavaScriptCore:

When we originally implemented classes, super seemed to be a class-only
feature. But the final spec says it's available in object literals too.

  • bytecompiler/NodesCodegen.cpp:

(JSC::PropertyListNode::emitBytecode): Having 'super' and being a class
property are no longer synonymous, so we track two separate variables.

(JSC::PropertyListNode::emitPutConstantProperty): Being inside the super
branch no longer guarantees that you're a class property, so we decide
our attributes and our function name dynamically.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createArrowFunctionExpr):
(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createArguments):
(JSC::ASTBuilder::createArgumentsList):
(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::createPropertyList): Pass through state to indicate
whether we're a class property, since we can't infer it from 'super'
anymore.

  • parser/NodeConstructors.h:

(JSC::PropertyNode::PropertyNode): See ASTBuilder.h.

  • parser/Nodes.h:

(JSC::PropertyNode::expressionName):
(JSC::PropertyNode::name):
(JSC::PropertyNode::type):
(JSC::PropertyNode::needsSuperBinding):
(JSC::PropertyNode::isClassProperty):
(JSC::PropertyNode::putType): See ASTBuilder.h.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parsePropertyMethod):
(JSC::Parser<LexerType>::parseGetterSetter):
(JSC::Parser<LexerType>::parseMemberExpression): I made these error
messages generic because it is no longer practical to say concise things
about the list of places you can use super.

  • parser/Parser.h:
  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createArgumentsList):
(JSC::SyntaxChecker::createProperty):
(JSC::SyntaxChecker::appendExportSpecifier):
(JSC::SyntaxChecker::appendConstDecl):
(JSC::SyntaxChecker::createGetterOrSetterProperty): Updated for
interface change.

  • tests/stress/generator-with-super.js:

(test):

  • tests/stress/modules-syntax-error.js:
  • tests/stress/super-in-lexical-scope.js:

(testSyntaxError):
(testSyntaxError.test):

  • tests/stress/tagged-templates-syntax.js: Updated for error message

changes. See Parser.cpp.

LayoutTests:

Updated expected results and added a few new tests.

  • js/arrowfunction-syntax-errors-expected.txt:
  • js/class-syntax-super-expected.txt:
  • js/object-literal-methods-expected.txt:
  • js/script-tests/arrowfunction-syntax-errors.js:
  • js/script-tests/class-syntax-super.js:
  • js/script-tests/object-literal-methods.js:
Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r199907 r199927  
     12016-04-22  Geoffrey Garen  <ggaren@apple.com>
     2
     3        super should be available in object literals
     4        https://bugs.webkit.org/show_bug.cgi?id=156933
     5
     6        Reviewed by Saam Barati.
     7
     8        Updated expected results and added a few new tests.
     9
     10        * js/arrowfunction-syntax-errors-expected.txt:
     11        * js/class-syntax-super-expected.txt:
     12        * js/object-literal-methods-expected.txt:
     13        * js/script-tests/arrowfunction-syntax-errors.js:
     14        * js/script-tests/class-syntax-super.js:
     15        * js/script-tests/object-literal-methods.js:
     16
    1172016-04-22  Ryan Haddad  <ryanhaddad@apple.com>
    218
  • trunk/LayoutTests/js/arrowfunction-syntax-errors-expected.txt

    r197554 r199927  
    132132PASS var arr3 = {c:a,d:b} => a + b; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
    133133PASS var arr3 = {c:b,d:a} => a + b; threw exception SyntaxError: Unexpected token '=>'. Expected ';' after variable declaration..
    134 PASS var arr4 = () => { super(); }; threw exception SyntaxError: Cannot call super() outside of a class constructor..
    135 PASS var arr4 = () => { super; }; threw exception SyntaxError: Cannot reference super..
    136 PASS var arr5 = () => { super.getValue(); }; threw exception SyntaxError: super can only be used in a method of a derived class..
    137 PASS var arr6 = () =>  super(); threw exception SyntaxError: Cannot call super() outside of a class constructor..
    138 PASS var arr7 = () =>  super; threw exception SyntaxError: Cannot reference super..
    139 PASS var arr8 = () =>  super.getValue(); threw exception SyntaxError: super can only be used in a method of a derived class..
    140 PASS class A { constructor() { function a () { return () => { super(); };}} threw exception SyntaxError: Cannot call super() outside of a class constructor..
    141 PASS class B { constructor() { function b () { return () => { super; }; }; }} threw exception SyntaxError: Cannot reference super..
    142 PASS class C { constructor() { function c () { return () => { super.getValue(); };}} threw exception SyntaxError: super can only be used in a method of a derived class..
    143 PASS class D { constructor() { function a () { return () => super(); }} threw exception SyntaxError: Cannot call super() outside of a class constructor..
    144 PASS class E { constructor() { function b () { return () => super; }; }} threw exception SyntaxError: Cannot reference super..
    145 PASS class F { constructor() { function c () { return () => super.getValue(); }} threw exception SyntaxError: super can only be used in a method of a derived class..
    146 PASS class G {}; class G2 extends G { getValue() { function c () { return () => super.getValue(); }} threw exception SyntaxError: super can only be used in a method of a derived class..
    147 PASS class H {}; class H2 extends H { method() { function *gen() { let arr = () => super.getValue(); arr(); } } } threw exception SyntaxError: super can only be used in a method of a derived class..
     134PASS var arr4 = () => { super(); }; threw exception SyntaxError: super is not valid in this context..
     135PASS var arr4 = () => { super; }; threw exception SyntaxError: super is not valid in this context..
     136PASS var arr5 = () => { super.getValue(); }; threw exception SyntaxError: super is not valid in this context..
     137PASS var arr6 = () =>  super(); threw exception SyntaxError: super is not valid in this context..
     138PASS var arr7 = () =>  super; threw exception SyntaxError: super is not valid in this context..
     139PASS var arr8 = () =>  super.getValue(); threw exception SyntaxError: super is not valid in this context..
     140PASS class A { constructor() { function a () { return () => { super(); };}} threw exception SyntaxError: super is not valid in this context..
     141PASS class B { constructor() { function b () { return () => { super; }; }; }} threw exception SyntaxError: super is not valid in this context..
     142PASS class C { constructor() { function c () { return () => { super.getValue(); };}} threw exception SyntaxError: super is not valid in this context..
     143PASS class D { constructor() { function a () { return () => super(); }} threw exception SyntaxError: super is not valid in this context..
     144PASS class E { constructor() { function b () { return () => super; }; }} threw exception SyntaxError: super is not valid in this context..
     145PASS class F { constructor() { function c () { return () => super.getValue(); }} threw exception SyntaxError: super is not valid in this context..
     146PASS class G {}; class G2 extends G { getValue() { function c () { return () => super.getValue(); }} threw exception SyntaxError: super is not valid in this context..
     147PASS class H {}; class H2 extends H { method() { function *gen() { let arr = () => super.getValue(); arr(); } } } threw exception SyntaxError: super is not valid in this context..
    148148PASS successfullyParsed is true
    149149
  • trunk/LayoutTests/js/class-syntax-super-expected.txt

    r199724 r199927  
    1717PASS (new SecondDerived).chainMethod().toString():::["base", "derived", "secondDerived"].toString()
    1818PASS x = class extends Base { constructor() { super(); } super() {} }
    19 PASS x = class extends Base { constructor() { super(); } method() { super() } }:::SyntaxError: Cannot call super() outside of a class constructor.
    20 PASS x = class extends Base { constructor() { super(); } method() { super } }:::SyntaxError: Cannot reference super.
     19PASS x = class extends Base { constructor() { super(); } method() { super() } }:::SyntaxError: super is not valid in this context.
     20PASS x = class extends Base { constructor() { super(); } method() { super } }:::SyntaxError: super is not valid in this context.
    2121PASS x = class extends Base { constructor() { super(); } method() { return new super } }:::SyntaxError: Cannot use new with super.
    2222PASS x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } }
     
    3838PASS new (class extends null { constructor() { return 1; } }):::TypeError: Cannot return a non-object type in the constructor of a derived class.
    3939PASS new (class extends null { constructor() { super() } }):::TypeError: function is not a constructor (evaluating 'super()')
    40 PASS new (class { constructor() { super() } }):::SyntaxError: Cannot call super() in a base class constructor.
    41 PASS function x() { super(); }:::SyntaxError: Cannot call super() outside of a class constructor.
    42 PASS new (class extends Object { constructor() { function x() { super() } } }):::SyntaxError: Cannot call super() outside of a class constructor.
    43 PASS new (class extends Object { constructor() { function x() { super.method } } }):::SyntaxError: super can only be used in a method of a derived class.
    44 PASS function x() { super.method(); }:::SyntaxError: super can only be used in a method of a derived class.
    45 PASS function x() { super(); }:::SyntaxError: Cannot call super() outside of a class constructor.
    46 PASS eval("super.method()"):::SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.
    47 PASS eval("super()"):::SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.
    48 PASS (function () { eval("super.method()");})():::SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.
    49 PASS (function () { eval("super()");})():::SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.
    50 PASS new (class { constructor() { (function () { eval("super()");})(); } }):::SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.
    51 PASS (new (class { method() { (function () { eval("super.method()");})(); }})).method():::SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.
     40PASS new (class { constructor() { super() } }):::SyntaxError: super is not valid in this context.
     41PASS function x() { super(); }:::SyntaxError: super is not valid in this context.
     42PASS new (class extends Object { constructor() { function x() { super() } } }):::SyntaxError: super is not valid in this context.
     43PASS new (class extends Object { constructor() { function x() { super.method } } }):::SyntaxError: super is not valid in this context.
     44PASS function x() { super.method(); }:::SyntaxError: super is not valid in this context.
     45PASS function x() { super(); }:::SyntaxError: super is not valid in this context.
     46PASS eval("super.method()"):::SyntaxError: super is not valid in this context.
     47PASS eval("super()"):::SyntaxError: super is not valid in this context.
     48PASS (function () { eval("super.method()");})():::SyntaxError: super is not valid in this context.
     49PASS (function () { eval("super()");})():::SyntaxError: super is not valid in this context.
     50PASS new (class { constructor() { (function () { eval("super()");})(); } }):::SyntaxError: super is not valid in this context.
     51PASS (new (class { method() { (function () { eval("super.method()");})(); }})).method():::SyntaxError: super is not valid in this context.
    5252PASS successfullyParsed
    5353
  • trunk/LayoutTests/js/object-literal-methods-expected.txt

    r181901 r199927  
    6969PASS ({__proto__(){}}) instanceof Function is false
    7070PASS ({__proto__(){}}).__proto__ instanceof Function is true
     71PASS { f() { return super.f(); } }.f() threw exception SyntaxError: Unexpected token '{'.
     72PASS new ({ f() { return super(); }.f) threw exception SyntaxError: super is not valid in this context..
     73PASS o = { f() { } }; new ({ __proto__: o, f() { return super(); } }).f threw exception SyntaxError: super is not valid in this context..
     74PASS ({ f() { return (() => super.f())(); } }).f() threw exception TypeError: super.f is not a function. (In 'super.f()', 'super.f' is undefined).
     75PASS o = { f() { return true; } }; ({ __proto__: o, f() { return super.f(); } }).f() is true
     76PASS o = { get p() { return true; } }; ({ __proto__: o, get p() { return super.p; } }).p is true
     77PASS o = { set p(p2) { } }; ({ __proto__: o, set p(p2) { super.p = p2; } }).p = true is true
     78PASS o = { f() { return true; } }; ({ __proto__: o, f() { return (() => super.f())(); } }).f() is true
    7179PASS successfullyParsed is true
    7280
  • trunk/LayoutTests/js/script-tests/arrowfunction-syntax-errors.js

    r197554 r199927  
    4949shouldThrow('var arr3 = {c:b,d:a} => a + b;');
    5050
    51 shouldThrow('var arr4 = () => { super(); };', '"SyntaxError: Cannot call super() outside of a class constructor."');
    52 shouldThrow('var arr4 = () => { super; };', '"SyntaxError: Cannot reference super."');
    53 shouldThrow('var arr5 = () => { super.getValue(); };', '"SyntaxError: super can only be used in a method of a derived class."');
     51shouldThrow('var arr4 = () => { super(); };', '"SyntaxError: super is not valid in this context."');
     52shouldThrow('var arr4 = () => { super; };', '"SyntaxError: super is not valid in this context."');
     53shouldThrow('var arr5 = () => { super.getValue(); };', '"SyntaxError: super is not valid in this context."');
    5454
    55 shouldThrow('var arr6 = () =>  super();', '"SyntaxError: Cannot call super() outside of a class constructor."');
    56 shouldThrow('var arr7 = () =>  super;', '"SyntaxError: Cannot reference super."');
    57 shouldThrow('var arr8 = () =>  super.getValue();', '"SyntaxError: super can only be used in a method of a derived class."');
     55shouldThrow('var arr6 = () =>  super();', '"SyntaxError: super is not valid in this context."');
     56shouldThrow('var arr7 = () =>  super;', '"SyntaxError: super is not valid in this context."');
     57shouldThrow('var arr8 = () =>  super.getValue();', '"SyntaxError: super is not valid in this context."');
    5858
    59 shouldThrow('class A { constructor() { function a () { return () => { super(); };}}', '"SyntaxError: Cannot call super() outside of a class constructor."');
    60 shouldThrow('class B { constructor() { function b () { return () => { super; }; }; }}', '"SyntaxError: Cannot reference super."');
    61 shouldThrow('class C { constructor() { function c () { return () => { super.getValue(); };}}', '"SyntaxError: super can only be used in a method of a derived class."');
     59shouldThrow('class A { constructor() { function a () { return () => { super(); };}}', '"SyntaxError: super is not valid in this context."');
     60shouldThrow('class B { constructor() { function b () { return () => { super; }; }; }}', '"SyntaxError: super is not valid in this context."');
     61shouldThrow('class C { constructor() { function c () { return () => { super.getValue(); };}}', '"SyntaxError: super is not valid in this context."');
    6262
    63 shouldThrow('class D { constructor() { function a () { return () => super(); }}', '"SyntaxError: Cannot call super() outside of a class constructor."');
    64 shouldThrow('class E { constructor() { function b () { return () => super; }; }}', '"SyntaxError: Cannot reference super."');
    65 shouldThrow('class F { constructor() { function c () { return () => super.getValue(); }}', '"SyntaxError: super can only be used in a method of a derived class."');
    66 shouldThrow('class G {}; class G2 extends G { getValue() { function c () { return () => super.getValue(); }}', '"SyntaxError: super can only be used in a method of a derived class."');
    67 shouldThrow('class H {}; class H2 extends H { method() { function *gen() { let arr = () => super.getValue(); arr(); } } }', '"SyntaxError: super can only be used in a method of a derived class."');
     63shouldThrow('class D { constructor() { function a () { return () => super(); }}', '"SyntaxError: super is not valid in this context."');
     64shouldThrow('class E { constructor() { function b () { return () => super; }; }}', '"SyntaxError: super is not valid in this context."');
     65shouldThrow('class F { constructor() { function c () { return () => super.getValue(); }}', '"SyntaxError: super is not valid in this context."');
     66shouldThrow('class G {}; class G2 extends G { getValue() { function c () { return () => super.getValue(); }}', '"SyntaxError: super is not valid in this context."');
     67shouldThrow('class H {}; class H2 extends H { method() { function *gen() { let arr = () => super.getValue(); arr(); } } }', '"SyntaxError: super is not valid in this context."');
    6868
    6969var successfullyParsed = true;
  • trunk/LayoutTests/js/script-tests/class-syntax-super.js

    r199724 r199927  
    100100shouldNotThrow('x = class extends Base { constructor() { super(); } super() {} }');
    101101shouldThrow('x = class extends Base { constructor() { super(); } method() { super() } }',
    102     '"SyntaxError: Cannot call super() outside of a class constructor."');
    103 shouldThrow('x = class extends Base { constructor() { super(); } method() { super } }', '"SyntaxError: Cannot reference super."');
     102    '"SyntaxError: super is not valid in this context."');
     103shouldThrow('x = class extends Base { constructor() { super(); } method() { super } }', '"SyntaxError: super is not valid in this context."');
    104104shouldThrow('x = class extends Base { constructor() { super(); } method() { return new super } }', '"SyntaxError: Cannot use new with super."');
    105105shouldNotThrow('x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } }');
     
    121121shouldThrow('new (class extends null { constructor() { return 1; } })', '"TypeError: Cannot return a non-object type in the constructor of a derived class."');
    122122shouldThrow('new (class extends null { constructor() { super() } })', '"TypeError: function is not a constructor (evaluating \'super()\')"');
    123 shouldThrow('new (class { constructor() { super() } })', '"SyntaxError: Cannot call super() in a base class constructor."');
    124 shouldThrow('function x() { super(); }', '"SyntaxError: Cannot call super() outside of a class constructor."');
    125 shouldThrow('new (class extends Object { constructor() { function x() { super() } } })', '"SyntaxError: Cannot call super() outside of a class constructor."');
    126 shouldThrow('new (class extends Object { constructor() { function x() { super.method } } })', '"SyntaxError: super can only be used in a method of a derived class."');
    127 shouldThrow('function x() { super.method(); }', '"SyntaxError: super can only be used in a method of a derived class."');
    128 shouldThrow('function x() { super(); }', '"SyntaxError: Cannot call super() outside of a class constructor."');
    129 shouldThrow('eval("super.method()")', '"SyntaxError: \'super\' is only valid inside a function or an \'eval\' inside a function."');
    130 shouldThrow('eval("super()")', '"SyntaxError: \'super\' is only valid inside a function or an \'eval\' inside a function."');
     123shouldThrow('new (class { constructor() { super() } })', '"SyntaxError: super is not valid in this context."');
     124shouldThrow('function x() { super(); }', '"SyntaxError: super is not valid in this context."');
     125shouldThrow('new (class extends Object { constructor() { function x() { super() } } })', '"SyntaxError: super is not valid in this context."');
     126shouldThrow('new (class extends Object { constructor() { function x() { super.method } } })', '"SyntaxError: super is not valid in this context."');
     127shouldThrow('function x() { super.method(); }', '"SyntaxError: super is not valid in this context."');
     128shouldThrow('function x() { super(); }', '"SyntaxError: super is not valid in this context."');
     129shouldThrow('eval("super.method()")', '"SyntaxError: super is not valid in this context."');
     130shouldThrow('eval("super()")', '"SyntaxError: super is not valid in this context."');
    131131
    132 shouldThrow('(function () { eval("super.method()");})()', '"SyntaxError: \'super\' is only valid inside a function or an \'eval\' inside a function."');
    133 shouldThrow('(function () { eval("super()");})()', '"SyntaxError: \'super\' is only valid inside a function or an \'eval\' inside a function."');
     132shouldThrow('(function () { eval("super.method()");})()', '"SyntaxError: super is not valid in this context."');
     133shouldThrow('(function () { eval("super()");})()', '"SyntaxError: super is not valid in this context."');
    134134
    135 shouldThrow('new (class { constructor() { (function () { eval("super()");})(); } })', '"SyntaxError: \'super\' is only valid inside a function or an \'eval\' inside a function."');
    136 shouldThrow('(new (class { method() { (function () { eval("super.method()");})(); }})).method()', '"SyntaxError: \'super\' is only valid inside a function or an \'eval\' inside a function."');
     135shouldThrow('new (class { constructor() { (function () { eval("super()");})(); } })', '"SyntaxError: super is not valid in this context."');
     136shouldThrow('(new (class { method() { (function () { eval("super.method()");})(); }})).method()', '"SyntaxError: super is not valid in this context."');
    137137
    138138var successfullyParsed = true;
  • trunk/LayoutTests/js/script-tests/object-literal-methods.js

    r181183 r199927  
    8383shouldBeFalse("({__proto__(){}}) instanceof Function");
    8484shouldBeTrue("({__proto__(){}}).__proto__ instanceof Function");
     85
     86shouldThrow("{ f() { return super.f(); } }.f()");
     87shouldThrow("new ({ f() { return super(); }.f)");
     88shouldThrow("o = { f() { } }; new ({ __proto__: o, f() { return super(); } }).f");
     89shouldThrow("({ f() { return (() => super.f())(); } }).f()");
     90shouldBeTrue("o = { f() { return true; } }; ({ __proto__: o, f() { return super.f(); } }).f()");
     91shouldBeTrue("o = { get p() { return true; } }; ({ __proto__: o, get p() { return super.p; } }).p");
     92shouldBeTrue("o = { set p(p2) { } }; ({ __proto__: o, set p(p2) { super.p = p2; } }).p = true");
     93shouldBeTrue("o = { f() { return true; } }; ({ __proto__: o, f() { return (() => super.f())(); } }).f()");
  • trunk/LayoutTests/sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.27-expected.txt

    r198472 r199927  
    1 CONSOLE MESSAGE: line 76: SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.
     1CONSOLE MESSAGE: line 76: SyntaxError: super is not valid in this context.
    22S7.5.3_A1.27
    33
  • trunk/Source/JavaScriptCore/ChangeLog

    r199918 r199927  
     12016-04-22  Geoffrey Garen  <ggaren@apple.com>
     2
     3        super should be available in object literals
     4        https://bugs.webkit.org/show_bug.cgi?id=156933
     5
     6        Reviewed by Saam Barati.
     7
     8        When we originally implemented classes, super seemed to be a class-only
     9        feature. But the final spec says it's available in object literals too.
     10
     11        * bytecompiler/NodesCodegen.cpp:
     12        (JSC::PropertyListNode::emitBytecode): Having 'super' and being a class
     13        property are no longer synonymous, so we track two separate variables.
     14
     15        (JSC::PropertyListNode::emitPutConstantProperty): Being inside the super
     16        branch no longer guarantees that you're a class property, so we decide
     17        our attributes and our function name dynamically.
     18
     19        * parser/ASTBuilder.h:
     20        (JSC::ASTBuilder::createArrowFunctionExpr):
     21        (JSC::ASTBuilder::createGetterOrSetterProperty):
     22        (JSC::ASTBuilder::createArguments):
     23        (JSC::ASTBuilder::createArgumentsList):
     24        (JSC::ASTBuilder::createProperty):
     25        (JSC::ASTBuilder::createPropertyList): Pass through state to indicate
     26        whether we're a class property, since we can't infer it from 'super'
     27        anymore.
     28
     29        * parser/NodeConstructors.h:
     30        (JSC::PropertyNode::PropertyNode): See ASTBuilder.h.
     31
     32        * parser/Nodes.h:
     33        (JSC::PropertyNode::expressionName):
     34        (JSC::PropertyNode::name):
     35        (JSC::PropertyNode::type):
     36        (JSC::PropertyNode::needsSuperBinding):
     37        (JSC::PropertyNode::isClassProperty):
     38        (JSC::PropertyNode::putType): See ASTBuilder.h.
     39
     40        * parser/Parser.cpp:
     41        (JSC::Parser<LexerType>::parseFunctionInfo):
     42        (JSC::Parser<LexerType>::parseClass):
     43        (JSC::Parser<LexerType>::parseProperty):
     44        (JSC::Parser<LexerType>::parsePropertyMethod):
     45        (JSC::Parser<LexerType>::parseGetterSetter):
     46        (JSC::Parser<LexerType>::parseMemberExpression): I made these error
     47        messages generic because it is no longer practical to say concise things
     48        about the list of places you can use super.
     49
     50        * parser/Parser.h:
     51
     52        * parser/SyntaxChecker.h:
     53        (JSC::SyntaxChecker::createArgumentsList):
     54        (JSC::SyntaxChecker::createProperty):
     55        (JSC::SyntaxChecker::appendExportSpecifier):
     56        (JSC::SyntaxChecker::appendConstDecl):
     57        (JSC::SyntaxChecker::createGetterOrSetterProperty): Updated for
     58        interface change.
     59
     60        * tests/stress/generator-with-super.js:
     61        (test):
     62        * tests/stress/modules-syntax-error.js:
     63        * tests/stress/super-in-lexical-scope.js:
     64        (testSyntaxError):
     65        (testSyntaxError.test):
     66        * tests/stress/tagged-templates-syntax.js: Updated for error message
     67        changes. See Parser.cpp.
     68
    1692016-04-22  Filip Pizlo  <fpizlo@apple.com>
    270
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r199724 r199927  
    499499
    500500            RefPtr<RegisterID> value = generator.emitNode(node->m_assign);
    501             bool isClassProperty = node->needsSuperBinding();
    502             if (isClassProperty)
     501            bool needsSuperBinding = node->needsSuperBinding();
     502            if (needsSuperBinding)
    503503                emitPutHomeObject(generator, value.get(), dst);
    504             unsigned attribute = isClassProperty ? (Accessor | DontEnum) : Accessor;
     504
     505            unsigned attributes = node->isClassProperty() ? (Accessor | DontEnum) : Accessor;
    505506
    506507            ASSERT(node->m_type & (PropertyNode::Getter | PropertyNode::Setter));
     
    513514                    generator.emitSetFunctionNameIfNeeded(node->m_assign, value.get(), propertyName.get());
    514515                    if (node->m_type & PropertyNode::Getter)
    515                         generator.emitPutGetterByVal(dst, propertyName.get(), attribute, value.get());
     516                        generator.emitPutGetterByVal(dst, propertyName.get(), attributes, value.get());
    516517                    else
    517                         generator.emitPutSetterByVal(dst, propertyName.get(), attribute, value.get());
     518                        generator.emitPutSetterByVal(dst, propertyName.get(), attributes, value.get());
    518519                    continue;
    519520                }
    520521
    521522                if (node->m_type & PropertyNode::Getter)
    522                     generator.emitPutGetterById(dst, *node->name(), attribute, value.get());
     523                    generator.emitPutGetterById(dst, *node->name(), attributes, value.get());
    523524                else
    524                     generator.emitPutSetterById(dst, *node->name(), attribute, value.get());
     525                    generator.emitPutSetterById(dst, *node->name(), attributes, value.get());
    525526                continue;
    526527            }
     
    563564            }
    564565
    565             ASSERT(!pair.second || isClassProperty == pair.second->needsSuperBinding());
    566             if (isClassProperty && pair.second)
     566            ASSERT(!pair.second || needsSuperBinding == pair.second->needsSuperBinding());
     567            if (needsSuperBinding && pair.second)
    567568                emitPutHomeObject(generator, secondReg, dst);
    568569
    569             generator.emitPutGetterSetter(dst, *node->name(), attribute, getterReg.get(), setterReg.get());
     570            generator.emitPutGetterSetter(dst, *node->name(), attributes, getterReg.get(), setterReg.get());
    570571        }
    571572    }
     
    586587            propertyNameRegister = generator.emitNode(node.m_expression);
    587588
     589        unsigned attributes = BytecodeGenerator::PropertyConfigurable | BytecodeGenerator::PropertyWritable;
     590        if (!node.isClassProperty())
     591            attributes |= BytecodeGenerator::PropertyEnumerable;
     592        generator.emitSetFunctionNameIfNeeded(node.m_assign, value.get(), propertyNameRegister.get());
    588593        generator.emitCallDefineProperty(newObj, propertyNameRegister.get(),
    589             value.get(), nullptr, nullptr, BytecodeGenerator::PropertyConfigurable | BytecodeGenerator::PropertyWritable, m_position);
     594            value.get(), nullptr, nullptr, attributes, m_position);
    590595        return;
    591596    }
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r198332 r199927  
    411411
    412412    NEVER_INLINE PropertyNode* createGetterOrSetterProperty(const JSTokenLocation& location, PropertyNode::Type type, bool,
    413         const Identifier* name, const ParserFunctionInfo<ASTBuilder>& functionInfo, SuperBinding superBinding)
     413        const Identifier* name, const ParserFunctionInfo<ASTBuilder>& functionInfo, bool isClassProperty)
    414414    {
    415415        ASSERT(name);
     
    419419        SourceCode source = m_sourceCode->subExpression(functionInfo.startOffset, functionInfo.endOffset, functionInfo.startLine, functionInfo.bodyStartColumn);
    420420        MethodDefinitionNode* methodDef = new (m_parserArena) MethodDefinitionNode(location, m_vm->propertyNames->nullIdentifier, functionInfo.body, source);
    421         return new (m_parserArena) PropertyNode(*name, methodDef, type, PropertyNode::Unknown, superBinding);
     421        return new (m_parserArena) PropertyNode(*name, methodDef, type, PropertyNode::Unknown, SuperBinding::Needed, isClassProperty);
    422422    }
    423423
    424424    NEVER_INLINE PropertyNode* createGetterOrSetterProperty(const JSTokenLocation& location, PropertyNode::Type type, bool,
    425         ExpressionNode* name, const ParserFunctionInfo<ASTBuilder>& functionInfo, SuperBinding superBinding)
     425        ExpressionNode* name, const ParserFunctionInfo<ASTBuilder>& functionInfo, bool isClassProperty)
    426426    {
    427427        ASSERT(name);
     
    429429        SourceCode source = m_sourceCode->subExpression(functionInfo.startOffset, functionInfo.endOffset, functionInfo.startLine, functionInfo.bodyStartColumn);
    430430        MethodDefinitionNode* methodDef = new (m_parserArena) MethodDefinitionNode(location, m_vm->propertyNames->nullIdentifier, functionInfo.body, source);
    431         return new (m_parserArena) PropertyNode(name, methodDef, type, PropertyNode::Unknown, superBinding);
     431        return new (m_parserArena) PropertyNode(name, methodDef, type, PropertyNode::Unknown, SuperBinding::Needed, isClassProperty);
    432432    }
    433433
    434434    NEVER_INLINE PropertyNode* createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation& location, PropertyNode::Type type, bool,
    435         double name, const ParserFunctionInfo<ASTBuilder>& functionInfo, SuperBinding superBinding)
     435        double name, const ParserFunctionInfo<ASTBuilder>& functionInfo, bool isClassProperty)
    436436    {
    437437        functionInfo.body->setLoc(functionInfo.startLine, functionInfo.endLine, location.startOffset, location.lineStartOffset);
     
    439439        SourceCode source = m_sourceCode->subExpression(functionInfo.startOffset, functionInfo.endOffset, functionInfo.startLine, functionInfo.bodyStartColumn);
    440440        MethodDefinitionNode* methodDef = new (m_parserArena) MethodDefinitionNode(location, vm->propertyNames->nullIdentifier, functionInfo.body, source);
    441         return new (m_parserArena) PropertyNode(ident, methodDef, type, PropertyNode::Unknown, superBinding);
     441        return new (m_parserArena) PropertyNode(ident, methodDef, type, PropertyNode::Unknown, SuperBinding::Needed, isClassProperty);
    442442    }
    443443
     
    447447    ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ArgumentListNode* args, ExpressionNode* arg) { return new (m_parserArena) ArgumentListNode(location, args, arg); }
    448448
    449     PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding = SuperBinding::NotNeeded)
     449    PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding, bool isClassProperty)
    450450    {
    451451        if (node->isFuncExprNode()) {
     
    455455        } else if (node->isClassExprNode())
    456456            static_cast<ClassExprNode*>(node)->setEcmaName(*propertyName);
    457         return new (m_parserArena) PropertyNode(*propertyName, node, type, putType, superBinding);
    458     }
    459     PropertyNode* createProperty(VM* vm, ParserArena& parserArena, double propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool)
    460     {
    461         return new (m_parserArena) PropertyNode(parserArena.identifierArena().makeNumericIdentifier(vm, propertyName), node, type, putType);
    462     }
    463     PropertyNode* createProperty(ExpressionNode* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding = SuperBinding::NotNeeded) { return new (m_parserArena) PropertyNode(propertyName, node, type, putType, superBinding); }
     457        return new (m_parserArena) PropertyNode(*propertyName, node, type, putType, superBinding, isClassProperty);
     458    }
     459    PropertyNode* createProperty(VM* vm, ParserArena& parserArena, double propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding, bool isClassProperty)
     460    {
     461        return new (m_parserArena) PropertyNode(parserArena.identifierArena().makeNumericIdentifier(vm, propertyName), node, type, putType, superBinding, isClassProperty);
     462    }
     463    PropertyNode* createProperty(ExpressionNode* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding, bool isClassProperty) { return new (m_parserArena) PropertyNode(propertyName, node, type, putType, superBinding, isClassProperty); }
    464464    PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property) { return new (m_parserArena) PropertyListNode(location, property); }
    465465    PropertyListNode* createPropertyList(const JSTokenLocation& location, PropertyNode* property, PropertyListNode* tail) { return new (m_parserArena) PropertyListNode(location, property, tail); }
  • trunk/Source/JavaScriptCore/parser/NodeConstructors.h

    r198349 r199927  
    221221    }
    222222
    223     inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding = SuperBinding::NotNeeded)
     223    inline PropertyNode::PropertyNode(const Identifier& name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding, bool isClassProperty)
    224224        : m_name(&name)
    225225        , m_assign(assign)
     
    227227        , m_needsSuperBinding(superBinding == SuperBinding::Needed)
    228228        , m_putType(putType)
    229     {
    230     }
    231 
    232     inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding = SuperBinding::NotNeeded)
     229        , m_isClassProperty(isClassProperty)
     230    {
     231    }
     232
     233    inline PropertyNode::PropertyNode(ExpressionNode* name, ExpressionNode* assign, Type type, PutType putType, SuperBinding superBinding, bool isClassProperty)
    233234        : m_name(0)
    234235        , m_expression(name)
     
    237238        , m_needsSuperBinding(superBinding == SuperBinding::Needed)
    238239        , m_putType(putType)
     240        , m_isClassProperty(isClassProperty)
    239241    {
    240242    }
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r199768 r199927  
    627627        enum PutType { Unknown, KnownDirect };
    628628
    629         PropertyNode(const Identifier&, ExpressionNode*, Type, PutType, SuperBinding);
    630         PropertyNode(ExpressionNode* propertyName, ExpressionNode*, Type, PutType, SuperBinding);
     629        PropertyNode(const Identifier&, ExpressionNode*, Type, PutType, SuperBinding, bool isClassProperty);
     630        PropertyNode(ExpressionNode* propertyName, ExpressionNode*, Type, PutType, SuperBinding, bool isClassProperty);
    631631
    632632        ExpressionNode* expressionName() const { return m_expression; }
     
    635635        Type type() const { return static_cast<Type>(m_type); }
    636636        bool needsSuperBinding() const { return m_needsSuperBinding; }
     637        bool isClassProperty() const { return m_isClassProperty; }
    637638        PutType putType() const { return static_cast<PutType>(m_putType); }
    638639
     
    645646        unsigned m_needsSuperBinding : 1;
    646647        unsigned m_putType : 1;
     648        unsigned m_isClassProperty: 1;
    647649    };
    648650
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r199845 r199927  
    20792079            functionScope->setStrictMode();
    20802080
    2081         semanticFailIfTrue(generatorBodyScope->hasDirectSuper(), "Cannot call super() outside of a class constructor");
     2081        semanticFailIfTrue(generatorBodyScope->hasDirectSuper(), "super is not valid in this context");
    20822082        if (generatorBodyScope->needsSuperBinding())
    2083             semanticFailIfTrue(expectedSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class");
     2083            semanticFailIfTrue(expectedSuperBinding == SuperBinding::NotNeeded, "super is not valid in this context");
    20842084
    20852085        popScope(generatorBodyScope, TreeBuilder::NeedsFreeVariableInfo);
     
    21042104                ? constructorKind
    21052105                : scopeRef->constructorKind();
    2106             semanticFailIfTrue(functionConstructorKind == ConstructorKind::None, "Cannot call super() outside of a class constructor");
    2107             semanticFailIfTrue(functionConstructorKind != ConstructorKind::Derived, "Cannot call super() in a base class constructor");
     2106            semanticFailIfTrue(functionConstructorKind == ConstructorKind::None, "super is not valid in this context");
     2107            semanticFailIfTrue(functionConstructorKind != ConstructorKind::Derived, "super is not valid in this context");
    21082108        }
    21092109        if (functionScope->needsSuperBinding()) {
     
    21122112                ? expectedSuperBinding
    21132113                : scopeRef->expectedSuperBinding();
    2114             semanticFailIfTrue(functionSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class");
     2114            semanticFailIfTrue(functionSuperBinding == SuperBinding::NotNeeded, "super is not valid in this context");
    21152115        }
    21162116    }
     
    23362336        const bool alwaysStrictInsideClass = true;
    23372337        if (isGetter || isSetter) {
     2338            bool isClassProperty = true;
    23382339            property = parseGetterSetter(context, alwaysStrictInsideClass, isGetter ? PropertyNode::Getter : PropertyNode::Setter, methodStart,
    2339                 ConstructorKind::None, SuperBinding::Needed);
     2340                ConstructorKind::None, isClassProperty);
    23402341            failIfFalse(property, "Cannot parse this method");
    23412342        } else {
     
    23622363            semanticFailIfTrue(isStaticMethod && methodInfo.name && *methodInfo.name == propertyNames.prototype,
    23632364                "Cannot declare a static method named 'prototype'");
     2365
     2366            bool isClassProperty = true;
    23642367            if (computedPropertyName) {
    23652368                property = context.createProperty(computedPropertyName, method, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Computed),
    2366                     PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed);
     2369                    PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, isClassProperty);
    23672370            } else
    2368                 property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed);
     2371                property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, isClassProperty);
    23692372        }
    23702373
     
    32583261    bool wasIdent = false;
    32593262    bool isGenerator = false;
     3263    bool isClassProperty = false;
    32603264#if ENABLE(ES6_GENERATORS)
    32613265    if (consume(TIMES))
     
    32803284            failIfFalse(node, "Cannot parse expression for property declaration");
    32813285            context.setEndOffset(node, m_lexer->currentOffset());
    3282             return context.createProperty(ident, node, PropertyNode::Constant, PropertyNode::Unknown, complete);
     3286            return context.createProperty(ident, node, PropertyNode::Constant, PropertyNode::Unknown, complete, SuperBinding::NotNeeded, isClassProperty);
    32833287        }
    32843288
     
    32863290            auto method = parsePropertyMethod(context, ident, isGenerator);
    32873291            propagateError();
    3288             return context.createProperty(ident, method, PropertyNode::Constant, PropertyNode::KnownDirect, complete);
     3292            return context.createProperty(ident, method, PropertyNode::Constant, PropertyNode::KnownDirect, complete, SuperBinding::Needed, isClassProperty);
    32893293        }
    32903294        failIfTrue(isGenerator, "Expected a parenthesis for argument list");
     
    32993303                currentScope()->setInnerArrowFunctionUsesEval();
    33003304            TreeExpression node = context.createResolve(location, *ident, start, lastTokenEndPosition());
    3301             return context.createProperty(ident, node, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Shorthand), PropertyNode::KnownDirect, complete);
     3305            return context.createProperty(ident, node, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Shorthand), PropertyNode::KnownDirect, complete, SuperBinding::NotNeeded, isClassProperty);
    33023306        }
    33033307
     
    33123316        else
    33133317            failWithMessage("Expected a ':' following the property name '", ident->impl(), "'");
    3314         return parseGetterSetter(context, complete, type, getterOrSetterStartOffset);
     3318        return parseGetterSetter(context, complete, type, getterOrSetterStartOffset, ConstructorKind::None, isClassProperty);
    33153319    }
    33163320    case DOUBLE:
     
    33233327            auto method = parsePropertyMethod(context, &ident, isGenerator);
    33243328            propagateError();
    3325             return context.createProperty(&ident, method, PropertyNode::Constant, PropertyNode::Unknown, complete);
     3329            return context.createProperty(&ident, method, PropertyNode::Constant, PropertyNode::Unknown, complete, SuperBinding::Needed, isClassProperty);
    33263330        }
    33273331        failIfTrue(isGenerator, "Expected a parenthesis for argument list");
     
    33313335        failIfFalse(node, "Cannot parse expression for property declaration");
    33323336        context.setEndOffset(node, m_lexer->currentOffset());
    3333         return context.createProperty(const_cast<VM*>(m_vm), m_parserArena, propertyName, node, PropertyNode::Constant, PropertyNode::Unknown, complete);
     3337        return context.createProperty(const_cast<VM*>(m_vm), m_parserArena, propertyName, node, PropertyNode::Constant, PropertyNode::Unknown, complete, SuperBinding::NotNeeded, isClassProperty);
    33343338    }
    33353339    case OPENBRACKET: {
     
    33423346            auto method = parsePropertyMethod(context, &m_vm->propertyNames->nullIdentifier, isGenerator);
    33433347            propagateError();
    3344             return context.createProperty(propertyName, method, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Computed), PropertyNode::KnownDirect, complete);
     3348            return context.createProperty(propertyName, method, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Computed), PropertyNode::KnownDirect, complete, SuperBinding::Needed, isClassProperty);
    33453349        }
    33463350        failIfTrue(isGenerator, "Expected a parenthesis for argument list");
     
    33503354        failIfFalse(node, "Cannot parse expression for property declaration");
    33513355        context.setEndOffset(node, m_lexer->currentOffset());
    3352         return context.createProperty(propertyName, node, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Computed), PropertyNode::Unknown, complete);
     3356        return context.createProperty(propertyName, node, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Computed), PropertyNode::Unknown, complete, SuperBinding::NotNeeded, isClassProperty);
    33533357    }
    33543358    default:
     
    33653369    ParserFunctionInfo<TreeBuilder> methodInfo;
    33663370    SourceParseMode parseMode = isGenerator ? SourceParseMode::GeneratorWrapperFunctionMode : SourceParseMode::MethodMode;
    3367     failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, parseMode, false, ConstructorKind::None, SuperBinding::NotNeeded, methodStart, methodInfo, FunctionDefinitionType::Method)), "Cannot parse this method");
     3371    failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, parseMode, false, ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, FunctionDefinitionType::Method)), "Cannot parse this method");
    33683372    methodInfo.name = methodName;
    33693373    return context.createMethodDefinition(methodLocation, methodInfo);
     
    33723376template <typename LexerType>
    33733377template <class TreeBuilder> TreeProperty Parser<LexerType>::parseGetterSetter(TreeBuilder& context, bool strict, PropertyNode::Type type, unsigned getterOrSetterStartOffset,
    3374     ConstructorKind constructorKind, SuperBinding superBinding)
     3378    ConstructorKind constructorKind, bool isClassProperty)
    33753379{
    33763380    const Identifier* stringPropertyName = 0;
     
    33823386    if (matchSpecIdentifier() || match(STRING) || m_token.m_type & KeywordTokenFlag) {
    33833387        stringPropertyName = m_token.m_data.ident;
    3384         semanticFailIfTrue(superBinding == SuperBinding::Needed && *stringPropertyName == m_vm->propertyNames->prototype,
     3388        semanticFailIfTrue(isClassProperty && *stringPropertyName == m_vm->propertyNames->prototype,
    33853389            "Cannot declare a static method named 'prototype'");
    3386         semanticFailIfTrue(superBinding == SuperBinding::Needed && *stringPropertyName == m_vm->propertyNames->constructor,
     3390        semanticFailIfTrue(isClassProperty && *stringPropertyName == m_vm->propertyNames->constructor,
    33873391            "Cannot declare a getter or setter named 'constructor'");
    33883392        next();
     
    34013405    if (type & PropertyNode::Getter) {
    34023406        failIfFalse(match(OPENPAREN), "Expected a parameter list for getter definition");
    3403         failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SourceParseMode::GetterMode, false, constructorKind, superBinding, getterOrSetterStartOffset, info, FunctionDefinitionType::Method)), "Cannot parse getter definition");
     3407        failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SourceParseMode::GetterMode, false, constructorKind, SuperBinding::Needed, getterOrSetterStartOffset, info, FunctionDefinitionType::Method)), "Cannot parse getter definition");
    34043408    } else {
    34053409        failIfFalse(match(OPENPAREN), "Expected a parameter list for setter definition");
    3406         failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SourceParseMode::SetterMode, false, constructorKind, superBinding, getterOrSetterStartOffset, info, FunctionDefinitionType::Method)), "Cannot parse setter definition");
     3410        failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SourceParseMode::SetterMode, false, constructorKind, SuperBinding::Needed, getterOrSetterStartOffset, info, FunctionDefinitionType::Method)), "Cannot parse setter definition");
    34073411    }
    34083412
    34093413    if (stringPropertyName)
    3410         return context.createGetterOrSetterProperty(location, type, strict, stringPropertyName, info, superBinding);
     3414        return context.createGetterOrSetterProperty(location, type, strict, stringPropertyName, info, isClassProperty);
    34113415
    34123416    if (computedPropertyName)
    3413         return context.createGetterOrSetterProperty(location, static_cast<PropertyNode::Type>(type | PropertyNode::Computed), strict, computedPropertyName, info, superBinding);
    3414 
    3415     return context.createGetterOrSetterProperty(const_cast<VM*>(m_vm), m_parserArena, location, type, strict, numericPropertyName, info, superBinding);
     3417        return context.createGetterOrSetterProperty(location, static_cast<PropertyNode::Type>(type | PropertyNode::Computed), strict, computedPropertyName, info, isClassProperty);
     3418
     3419    return context.createGetterOrSetterProperty(const_cast<VM*>(m_vm), m_parserArena, location, type, strict, numericPropertyName, info, isClassProperty);
    34163420}
    34173421
     
    38953899    if (baseIsSuper) {
    38963900        ScopeRef scopeRef = closestParentOrdinaryFunctionNonLexicalScope();
    3897         semanticFailIfFalse(currentScope()->isFunction() || (scopeRef->isEvalContext() && scopeRef->expectedSuperBinding() == SuperBinding::Needed), "'super' is only valid inside a function or an 'eval' inside a function");
     3901        semanticFailIfFalse(currentScope()->isFunction() || (scopeRef->isEvalContext() && scopeRef->expectedSuperBinding() == SuperBinding::Needed), "super is not valid in this context");
    38983902        base = context.createSuperExpr(location);
    38993903        next();
     
    39733977    }
    39743978endMemberExpression:
    3975     semanticFailIfTrue(baseIsSuper, "Cannot reference super");
     3979    semanticFailIfTrue(baseIsSuper, "super is not valid in this context");
    39763980    while (newCount--)
    39773981        base = context.createNewExpr(location, base, expressionStart, lastTokenEndPosition());
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r199845 r199927  
    13891389    template <class TreeBuilder> TreeProperty parseProperty(TreeBuilder&, bool strict);
    13901390    template <class TreeBuilder> TreeExpression parsePropertyMethod(TreeBuilder& context, const Identifier* methodName, bool isGenerator);
    1391     template <class TreeBuilder> TreeProperty parseGetterSetter(TreeBuilder&, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset, ConstructorKind = ConstructorKind::None, SuperBinding = SuperBinding::NotNeeded);
     1391    template <class TreeBuilder> TreeProperty parseGetterSetter(TreeBuilder&, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset, ConstructorKind, bool isClassProperty);
    13921392    template <class TreeBuilder> ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&, const JSTokenLocation&, int, int functionKeywordStart, int functionNameStart, int parametersStart, ConstructorKind, SuperBinding, FunctionBodyType, unsigned, SourceParseMode);
    13931393    template <class TreeBuilder> ALWAYS_INLINE bool parseFormalParameters(TreeBuilder&, TreeFormalParameterList, unsigned&);
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r199787 r199927  
    203203    int createArgumentsList(const JSTokenLocation&, int) { return ArgumentsListResult; }
    204204    int createArgumentsList(const JSTokenLocation&, int, int) { return ArgumentsListResult; }
    205     Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding = SuperBinding::NotNeeded)
     205    Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, bool)
    206206    {
    207207        if (!complete)
     
    210210        return Property(name, type);
    211211    }
    212     Property createProperty(VM* vm, ParserArena& parserArena, double name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete)
     212    Property createProperty(VM* vm, ParserArena& parserArena, double name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, bool)
    213213    {
    214214        if (!complete)
     
    216216        return Property(&parserArena.identifierArena().makeNumericIdentifier(vm, name), type);
    217217    }
    218     Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding = SuperBinding::NotNeeded)
     218    Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding, bool)
    219219    {
    220220        return Property(type);
     
    270270
    271271    int appendConstDecl(const JSTokenLocation&, int, const Identifier*, int) { return StatementResult; }
    272     Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
     272    Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, bool)
    273273    {
    274274        ASSERT(name);
     
    277277        return Property(name, type);
    278278    }
    279     Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool, int, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
     279    Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool, int, const ParserFunctionInfo<SyntaxChecker>&, bool)
    280280    {
    281281        return Property(type);
    282282    }
    283     Property createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
     283    Property createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, bool)
    284284    {
    285285        if (!strict)
  • trunk/Source/JavaScriptCore/tests/stress/generator-with-super.js

    r198472 r199927  
    2424    }
    2525
    26     shouldThrow(() => test(), "SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.");
     26    shouldThrow(() => test(), "SyntaxError: super is not valid in this context.");
    2727}());
    2828
  • trunk/Source/JavaScriptCore/tests/stress/modules-syntax-error.js

    r198472 r199927  
    308308checkModuleSyntaxError(String.raw`
    309309super();
    310 `, `SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.:2`);
     310`, `SyntaxError: super is not valid in this context.:2`);
    311311
    312312checkModuleSyntaxError(String.raw`
    313313super.test();
    314 `, `SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.:2`);
     314`, `SyntaxError: super is not valid in this context.:2`);
    315315
    316316checkModuleSyntaxError(String.raw`
    317317super.test = 20;
    318 `, `SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.:2`);
     318`, `SyntaxError: super is not valid in this context.:2`);
  • trunk/Source/JavaScriptCore/tests/stress/super-in-lexical-scope.js

    r198472 r199927  
    1919
    2020    if (String(error) !== message)
    21         throw new Error("Bad error: " + String(error));
     21        throw new Error("Bad error: " + String(error) + "(Expected: " + message + ")");
    2222}
    2323
    24 testSyntaxError(`super()`, `SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.`);
    25 testSyntaxError(`super.hello()`, `SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.`);
     24testSyntaxError(`super()`, `SyntaxError: super is not valid in this context.`);
     25testSyntaxError(`super.hello()`, `SyntaxError: super is not valid in this context.`);
    2626testSyntaxError(`
    2727{
    2828    super();
    2929}
    30 `, `SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.`);
     30`, `SyntaxError: super is not valid in this context.`);
    3131testSyntaxError(`
    3232{
    3333    super.hello();
    3434}
    35 `, `SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.`);
     35`, `SyntaxError: super is not valid in this context.`);
    3636testSyntaxError(`
    3737function test()
     
    3939    super();
    4040}
    41 `, `SyntaxError: Cannot call super() outside of a class constructor.`);
     41`, `SyntaxError: super is not valid in this context.`);
    4242testSyntaxError(`
    4343function test()
     
    4545    super.hello();
    4646}
    47 `, `SyntaxError: super can only be used in a method of a derived class.`);
     47`, `SyntaxError: super is not valid in this context.`);
    4848testSyntaxError(`
    4949function test()
     
    5353    }
    5454}
    55 `, `SyntaxError: Cannot call super() outside of a class constructor.`);
     55`, `SyntaxError: super is not valid in this context.`);
    5656testSyntaxError(`
    5757function test()
     
    6161    }
    6262}
    63 `, `SyntaxError: super can only be used in a method of a derived class.`);
     63`, `SyntaxError: super is not valid in this context.`);
  • trunk/Source/JavaScriptCore/tests/stress/tagged-templates-syntax.js

    r198472 r199927  
    6767testSyntax("(class extends Hello { constructor() { super()`${tag}${tag}` } })");
    6868
    69 testSyntaxError("super`Hello${tag}`", "SyntaxError: 'super' is only valid inside a function or an 'eval' inside a function.");
     69testSyntaxError("super`Hello${tag}`", "SyntaxError: super is not valid in this context.");
    7070testSyntaxError("(class { say() { super`Hello${tag}` } })", "SyntaxError: Cannot use super as tag for tagged templates.");
Note: See TracChangeset for help on using the changeset viewer.