Add a ForIn node for a , move the error (#2387)

This is to keep the tree consistent with the error-free state. It also more precisely locates the error.
This commit is contained in:
Jon Ross-Perkins
2022-11-14 13:17:58 -08:00
committed by GitHub
parent f6c5298c15
commit b163aaaf74
2 changed files with 5 additions and 6 deletions
+1 -3
View File
@@ -1457,9 +1457,7 @@ auto Parser::HandleStatementForHeaderInState() -> void {
if (auto colon = ConsumeIf(TokenKind::Colon())) {
CARBON_DIAGNOSTIC(ExpectedIn, Error, "`:` should be replaced by `in`.");
emitter_.Emit(*colon, ExpectedIn);
// TODO: Should probably add a ForIn node for consistency in ParseTree
// structure, but doesn't for consistency with the old implementation.
state.has_error = true;
AddLeafNode(ParseNodeKind::ForIn(), *colon, /*has_error=*/true);
} else {
CARBON_DIAGNOSTIC(ExpectedIn, Error,
"Expected `in` after loop `var` declaration.");