Skip to content

Commit

Permalink
Move add invalid node. Follow up to carbon-language#3473. (carbon-lan…
Browse files Browse the repository at this point in the history
…guage#3491)

I think this matches expectations about how the parse code should be
structured better.
  • Loading branch information
josh11b committed Dec 11, 2023
1 parent 5f439b8 commit 1addf10
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions toolchain/parse/handle_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ auto HandleImplAfterIntroducer(Carbon::Parse::Context& context) -> void {
"Expected `[` after `forall` in `impl` declaration.");
context.emitter().Emit(*context.position(), ImplExpectedAfterForall);
context.ReturnErrorOnState();
// If we aren't producing a node from the PatternListAsImplicit state,
// we still need to create a node to be the child of the `ImplForall`
// token created in the `ImplAfterForall` state.
context.AddLeafNode(NodeKind::InvalidParse, *context.position(),
/*has_error=*/true);
}
} else {
// One of:
Expand All @@ -46,8 +51,6 @@ auto HandleImplAfterIntroducer(Carbon::Parse::Context& context) -> void {
auto HandleImplAfterForall(Carbon::Parse::Context& context) -> void {
auto state = context.PopState();
if (state.has_error) {
context.AddLeafNode(NodeKind::InvalidParse, *context.position(),
/*has_error=*/true);
context.ReturnErrorOnState();
}
context.AddNode(NodeKind::ImplForall, state.token, state.subtree_start,
Expand Down

0 comments on commit 1addf10

Please sign in to comment.