Commit f243c942 authored by Suraj Sharma's avatar Suraj Sharma Committed by Commit Bot

[parser] Updated the Error Message for Unparenthesized Exponentiation Expression

-5**2 now produces
SyntaxError: Unary operator used immediately before exponentiation expression.
Parenthesis must be used to disambiguate operator precedence.

Bug: v8:6894
Change-Id: I89dd034ff90ee1a49ba61e0c613da534fbf8b41b
Reviewed-on: https://chromium-review.googlesource.com/c/1418592Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Suraj Sharma <surshar@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#59011}
parent 8ac88b6a
......@@ -481,6 +481,9 @@ namespace internal {
T(UnexpectedNewTarget, "new.target expression is not allowed here") \
T(UnexpectedTemplateString, "Unexpected template string") \
T(UnexpectedToken, "Unexpected token %") \
T(UnexpectedTokenUnaryExponentiation, \
"Unary operator used immediately before exponentiation expression. " \
"Parenthesis must be used to disambiguate operator precedence") \
T(UnexpectedTokenIdentifier, "Unexpected identifier") \
T(UnexpectedTokenNumber, "Unexpected number") \
T(UnexpectedTokenString, "Unexpected string") \
......
......@@ -2856,7 +2856,9 @@ ParserBase<Impl>::ParseUnaryOrPrefixExpression() {
}
if (peek() == Token::EXP) {
ReportUnexpectedToken(Next());
impl()->ReportMessageAt(
Scanner::Location(pos, peek_end_position()),
MessageTemplate::kUnexpectedTokenUnaryExponentiation);
return impl()->FailureExpression();
}
......
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
-5**2
*%(basename)s:7: SyntaxError: Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence
-5**2
^^^^
SyntaxError: Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment