Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index df568ef1bbb5962a91c3c3c925da42eee04f2037..aa83969e99977ac61b9e12adc5427a74ff8c0851 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -3197,6 +3197,13 @@ Expression* Parser::ParseUnaryExpression(bool* ok) { |
factory()->NewNumberLiteral(1), |
position); |
} |
+ // The same idea for '-foo' => 'foo*(-1)'. |
+ if (op == Token::SUB) { |
+ return factory()->NewBinaryOperation(Token::MUL, |
+ expression, |
+ factory()->NewNumberLiteral(-1), |
+ position); |
+ } |
return factory()->NewUnaryOperation(op, expression, position); |