From 0090c67a615c23c036c8aeaa17042efe71d2accf Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Mon, 23 Oct 2017 21:25:15 +0900 Subject: [PATCH] Fix: `super` is not PrimaryExpression --- src/expression.js | 14 ++++++++++++-- test/tests-harmony.js | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/expression.js b/src/expression.js index f8bb4cc7f..08e50386d 100644 --- a/src/expression.js +++ b/src/expression.js @@ -296,12 +296,22 @@ pp.parseExprAtom = function(refDestructuringErrors) { case tt._super: if (!this.inFunction) this.raise(this.start, "'super' outside of function or class") + node = this.startNode() + this.next() + // The `super` keyword can appear at below: + // SuperProperty: + // super [ Expression ] + // super . IdentifierName + // SuperCall: + // super Arguments + if (this.type !== tt.dot && this.type !== tt.bracketL && this.type !== tt.parenL) + this.unexpected() + return this.finishNode(node, "Super") case tt._this: - let type = this.type === tt._this ? "ThisExpression" : "Super" node = this.startNode() this.next() - return this.finishNode(node, type) + return this.finishNode(node, "ThisExpression") case tt.name: let startPos = this.start, startLoc = this.startLoc diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 34a59efae..906a4459f 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -15792,3 +15792,11 @@ test("1