gn: test and fix for swapped -= operator
[email protected]
Review URL: https://chromiumcodereview.appspot.com/23484029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222619 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/tools/gn/parser.cc b/tools/gn/parser.cc
index e507dfb8..649d4cf 100644
--- a/tools/gn/parser.cc
+++ b/tools/gn/parser.cc
@@ -194,6 +194,8 @@
}
scoped_ptr<ParseNode> left = (this->*prefix)(token);
+ if (has_error())
+ return left.Pass();
while (!at_end() && !IsStatementBreak(cur_token().type()) &&
precedence <= expressions_[cur_token().type()].precedence) {
diff --git a/tools/gn/parser_unittest.cc b/tools/gn/parser_unittest.cc
index 06464a2..7ef5ff6 100644
--- a/tools/gn/parser_unittest.cc
+++ b/tools/gn/parser_unittest.cc
@@ -475,3 +475,7 @@
TEST(Parser, HangingIf) {
DoParserErrorTest("if", 1, 1);
}
+
+TEST(Parser, NegatingList) {
+ DoParserErrorTest("executable(\"wee\") { sources =- [ \"foo.cc\" ] }", 1, 30);
+}