Commit a2c7d0df authored by mdempsky's avatar mdempsky Committed by Commit bot

tools/gn: provide better error message for bogus binary expressions

BUG=472038

Review URL: https://codereview.chromium.org/1068623002

Cr-Commit-Position: refs/heads/master@{#324106}
parent 0f491331
...@@ -388,9 +388,10 @@ scoped_ptr<ParseNode> Parser::BinaryOperator(scoped_ptr<ParseNode> left, ...@@ -388,9 +388,10 @@ scoped_ptr<ParseNode> Parser::BinaryOperator(scoped_ptr<ParseNode> left,
scoped_ptr<ParseNode> right = scoped_ptr<ParseNode> right =
ParseExpression(expressions_[token.type()].precedence + 1); ParseExpression(expressions_[token.type()].precedence + 1);
if (!right) { if (!right) {
*err_ = if (!has_error()) {
Err(token, *err_ = Err(token, "Expected right hand side for '" +
"Expected right hand side for '" + token.value().as_string() + "'"); token.value().as_string() + "'");
}
return scoped_ptr<ParseNode>(); return scoped_ptr<ParseNode>();
} }
scoped_ptr<BinaryOpNode> binary_op(new BinaryOpNode); scoped_ptr<BinaryOpNode> binary_op(new BinaryOpNode);
......
...@@ -204,7 +204,7 @@ TEST(Parser, List) { ...@@ -204,7 +204,7 @@ TEST(Parser, List) {
" LITERAL(3)\n" " LITERAL(3)\n"
" LITERAL(4)\n"); " LITERAL(4)\n");
DoExpressionErrorTest("[a, 2+,]", 1, 6); DoExpressionErrorTest("[a, 2+,]", 1, 7);
DoExpressionErrorTest("[,]", 1, 2); DoExpressionErrorTest("[,]", 1, 2);
DoExpressionErrorTest("[a,,]", 1, 4); DoExpressionErrorTest("[a,,]", 1, 4);
} }
...@@ -243,6 +243,9 @@ TEST(Parser, Accessor) { ...@@ -243,6 +243,9 @@ TEST(Parser, Accessor) {
" LITERAL(2)\n"); " LITERAL(2)\n");
DoParserErrorTest("a = b.c.d", 1, 6); // Can't nest accessors (currently). DoParserErrorTest("a = b.c.d", 1, 6); // Can't nest accessors (currently).
DoParserErrorTest("a.b = 5", 1, 1); // Can't assign to accessors (currently). DoParserErrorTest("a.b = 5", 1, 1); // Can't assign to accessors (currently).
// Error at the bad dot in the RHS, not the + operator (crbug.com/472038).
DoParserErrorTest("foo(a + b.c.d)", 1, 10);
} }
TEST(Parser, Condition) { TEST(Parser, Condition) {
......
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