Changeset 183757 in webkit


Ignore:
Timestamp:
May 4, 2015 12:21:28 PM (9 years ago)
Author:
rniwa@webkit.org
Message:

new super should be a syntax error
https://bugs.webkit.org/show_bug.cgi?id=144282

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

Disallow "new super" as ES6 spec doesn't allow this.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseMemberExpression):

LayoutTests:

Rebaselined the test.

  • js/class-syntax-super-expected.txt:
  • js/script-tests/class-syntax-super.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183756 r183757  
     12015-05-04  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        new super should be a syntax error
     4        https://bugs.webkit.org/show_bug.cgi?id=144282
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Rebaselined the test.
     9
     10        * js/class-syntax-super-expected.txt:
     11        * js/script-tests/class-syntax-super.js:
     12
    1132015-05-04  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/LayoutTests/js/class-syntax-super-expected.txt

    r183709 r183757  
    1717PASS x = class extends Base { constructor() { super(); } method() { super() } } threw exception SyntaxError: Cannot call super() outside of a class constructor..
    1818PASS x = class extends Base { constructor() { super(); } method() { super } } threw exception SyntaxError: Cannot reference super..
    19 PASS x = class extends Base { constructor() { super(); } method() { return new super } } did not throw exception.
    20 PASS (new x).method() instanceof Base is true
    21 PASS (new x).method() instanceof x is false
     19PASS x = class extends Base { constructor() { super(); } method() { return new super } } threw exception SyntaxError: Cannot use new with super..
    2220PASS x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } } did not throw exception.
    2321PASS (new x).method1() threw exception ReferenceError: Cannot delete a super property.
  • trunk/LayoutTests/js/script-tests/class-syntax-super.js

    r183709 r183757  
    4242    '"SyntaxError: Cannot call super() outside of a class constructor."');
    4343shouldThrow('x = class extends Base { constructor() { super(); } method() { super } }', '"SyntaxError: Cannot reference super."');
    44 shouldNotThrow('x = class extends Base { constructor() { super(); } method() { return new super } }');
    45 shouldBeTrue('(new x).method() instanceof Base');
    46 shouldBeFalse('(new x).method() instanceof x');
     44shouldThrow('x = class extends Base { constructor() { super(); } method() { return new super } }', '"SyntaxError: Cannot use new with super."');
    4745shouldNotThrow('x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } }');
    4846shouldThrow('(new x).method1()', '"ReferenceError: Cannot delete a super property"');
  • trunk/Source/JavaScriptCore/ChangeLog

    r183754 r183757  
     12015-05-04  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        new super should be a syntax error
     4        https://bugs.webkit.org/show_bug.cgi?id=144282
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Disallow "new super" as ES6 spec doesn't allow this.
     9
     10        * parser/Parser.cpp:
     11        (JSC::Parser<LexerType>::parseMemberExpression):
     12
    1132015-05-04  Saam Barati  <saambarati1@gmail.com>
    214
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r183709 r183757  
    25252525#if ENABLE(ES6_CLASS_SYNTAX)
    25262526    bool baseIsSuper = match(SUPER);
     2527    semanticFailIfTrue(baseIsSuper && newCount, "Cannot use new with super");
    25272528#else
    25282529    bool baseIsSuper = false;
     
    25882589    }
    25892590endMemberExpression:
    2590     semanticFailIfTrue(baseIsSuper && !newCount, "Cannot reference super");
     2591    semanticFailIfTrue(baseIsSuper, "Cannot reference super");
    25912592    while (newCount--)
    25922593        base = context.createNewExpr(location, base, expressionStart, lastTokenEndPosition());
Note: See TracChangeset for help on using the changeset viewer.