Chiffon icon indicating copy to clipboard operation
Chiffon copied to clipboard

Accepts invalid Class syntax

Open ghost opened this issue 8 years ago • 1 comments

This one:

  • It is a Syntax Error if PropName of MethodDefinition is not "constructor" and HasDirectSuper of MethodDefinition is true.
class A {
    foo() {
        super()  // Invalid 'super()'.
    }
}

http://www.ecma-international.org/ecma-262/6.0/#sec-class-definitions-static-semantics-early-errors

And also this one

class A {
    static foo() {
        super()  // Invalid 'super()'.
    }

    static prototype() {  // Invalid method.
    }
}

For this bugs

  • It is a Syntax Error if FormalParameters Contains SuperProperty is true.
  • It is a Syntax Error if FunctionBody Contains SuperProperty is true.
  • It is a Syntax Error if FormalParameters Contains SuperCall is true.
  • It is a Syntax Error if FunctionBody Contains SuperCall is true.
//-
function foo() {
    super()  // Invalid `super`.
    super.foo()  // Invalid `super`.
}
var foo = function() {
    super()  // Invalid `super`.
    super.foo()  // Invalid `super`.
}

function wrap() {
    function foo(a = super(), b = super.foo()) {  // Invalid 'super'.
    }
}

ghost avatar Nov 17 '16 13:11 ghost

super is not support 100% ECMA-262 compatible yet. Thanks for your test!

polygonplanet avatar Nov 23 '16 22:11 polygonplanet