Provide an error message on malformed lets. Fixes #807.
authorNico Weber <nicolasweber@gmx.de>
Thu, 4 Sep 2014 02:31:29 +0000 (19:31 -0700)
committerNico Weber <nicolasweber@gmx.de>
Thu, 4 Sep 2014 02:31:29 +0000 (19:31 -0700)
src/manifest_parser.cc
src/manifest_parser_test.cc

index 6fa4f7c..55d191f 100644 (file)
@@ -191,7 +191,7 @@ bool ManifestParser::ParseRule(string* err) {
 
 bool ManifestParser::ParseLet(string* key, EvalString* value, string* err) {
   if (!lexer_.ReadIdent(key))
-    return false;
+    return lexer_.Error("expected variable name", err);
   if (!ExpectToken(Lexer::EQUALS, err))
     return false;
   if (!lexer_.ReadVarValue(value, err))
index 152b965..5f4b30a 100644 (file)
@@ -553,6 +553,15 @@ TEST_F(ParserTest, Errors) {
     State state;
     ManifestParser parser(&state, NULL);
     string err;
+    EXPECT_FALSE(parser.ParseTest("rule cc\n  command = foo\n  && bar",
+                                  &err));
+    EXPECT_EQ("input:3: expected variable name\n", err);
+  }
+
+  {
+    State state;
+    ManifestParser parser(&state, NULL);
+    string err;
     EXPECT_FALSE(parser.ParseTest("rule cc\n  command = foo\n"
                                   "build $: cc bar.cc\n",
                                   &err));