Fix exponential operator to behave according to spec (#75)
This commit is contained in:
@@ -188,7 +188,13 @@ pp.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
|
||||
node.left = left;
|
||||
node.operator = this.state.value;
|
||||
|
||||
if (node.operator === "**" && left.type === "UnaryExpression" && left.extra && !left.extra.parenthesizedArgument) {
|
||||
if (
|
||||
node.operator === "**" &&
|
||||
left.type === "UnaryExpression" &&
|
||||
left.extra &&
|
||||
!left.extra.parenthesizedArgument &&
|
||||
!left.extra.parenthesized
|
||||
) {
|
||||
this.raise(left.argument.start, "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.");
|
||||
}
|
||||
|
||||
@@ -217,9 +223,10 @@ pp.parseMaybeUnary = function (refShorthandDefaultPos) {
|
||||
this.next();
|
||||
|
||||
let argType = this.state.type;
|
||||
this.addExtra(node, "parenthesizedArgument", argType === tt.parenL);
|
||||
node.argument = this.parseMaybeUnary();
|
||||
|
||||
this.addExtra(node, "parenthesizedArgument", argType === tt.parenL && (!node.argument.extra || !node.argument.extra.parenthesized));
|
||||
|
||||
if (refShorthandDefaultPos && refShorthandDefaultPos.start) {
|
||||
this.unexpected(refShorthandDefaultPos.start);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user