Index: tools/gn/parser_unittest.cc |
diff --git a/tools/gn/parser_unittest.cc b/tools/gn/parser_unittest.cc |
index 823a9830588948c535e831cc2a47c2efc5c28812..6216ee4d6b178a06a91092593be0896093f7a247 100644 |
--- a/tools/gn/parser_unittest.cc |
+++ b/tools/gn/parser_unittest.cc |
@@ -363,25 +363,6 @@ TEST(Parser, FunctionWithConditional) { |
DoParserPrintTest(input, expected); |
} |
-TEST(Parser, NestedBlocks) { |
- const char* input = "{cc_test(\"foo\") {{foo=1}\n{}}}"; |
- const char* expected = |
- "BLOCK\n" |
- " BLOCK\n" |
- " FUNCTION(cc_test)\n" |
- " LIST\n" |
- " LITERAL(\"foo\")\n" |
- " BLOCK\n" |
- " BLOCK\n" |
- " BINARY(=)\n" |
- " IDENTIFIER(foo)\n" |
- " LITERAL(1)\n" |
- " BLOCK\n"; |
- DoParserPrintTest(input, expected); |
- const char* input_with_newline = "{cc_test(\"foo\") {{foo=1}\n{}}}"; |
- DoParserPrintTest(input_with_newline, expected); |
-} |
- |
TEST(Parser, UnterminatedBlock) { |
DoParserErrorTest("stuff() {", 1, 9); |
} |
@@ -705,3 +686,18 @@ TEST(Parser, ConditionNoBracesElseIf) { |
" foreach(bar, []) {}\n", |
4, 3); |
} |
+ |
+// Disallow standalone {} for introducing new scopes. These are ambiguous with |
+// target declarations (e.g. is: |
+// foo("bar") {} |
+// a function with an associated block, or a standalone function with a |
+// freestanding block. |
+TEST(Parser, StandaloneBlock) { |
+ DoParserErrorTest( |
+ "if (true) {\n" |
+ "}\n" |
+ "{\n" |
+ " assert(false)\n" |
+ "}\n", |
+ 3, 1); |
+} |