Fix handling of closing scopes in FindNextof (#977)

This commit is contained in:
Jon Meow
2021-12-09 08:10:36 -08:00
committed by GitHub
parent a562f872e7
commit 97ce1f5449
6 changed files with 20 additions and 2 deletions
+16
View File
@@ -1159,5 +1159,21 @@ TEST_F(ParseTreeTest, PrintingAsYAML) {
{"text", ""}}}));
}
TEST_F(ParseTreeTest, ParenMatchRegression) {
// A regression test that the search for the closing `)` doesn't end early on
// the closing `}` when it skips over the nested scope.
TokenizedBuffer tokens = GetTokenizedBuffer("var = (foo {})");
ParseTree tree = ParseTree::Parse(tokens, consumer);
EXPECT_TRUE(tree.HasErrors());
EXPECT_THAT(
tree, MatchParseTreeNodes(
{MatchVariableDeclaration(
HasError, MatchVariableInitializer(
"=", MatchParenExpression(
HasError, MatchNameReference("foo"),
MatchParenExpressionEnd()))),
MatchFileEnd()}));
}
} // namespace
} // namespace Carbon