mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 22:02:51 +01:00
Unify more invalid declaration recovery. (#3942)
When we expect a semicolon, we should be able to provide more standard
recovery.
Note this affects a test of `base`, but it looks like a partial
improvement (the prior line was moving too far). Still, it looks like
recovery isn't handling `{}` quite right. I'm not trying to address that
here though -- leaving a TODO.
This commit is contained in:
@@ -42,20 +42,9 @@ auto HandleAliasAfterName(Context& context) -> void {
|
||||
auto HandleAliasFinish(Context& context) -> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
if (state.has_error) {
|
||||
context.RecoverFromDeclError(state, NodeKind::Alias,
|
||||
/*skip_past_likely_end=*/true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto semi = context.ConsumeIf(Lex::TokenKind::Semi)) {
|
||||
context.AddNode(NodeKind::Alias, *semi, state.subtree_start,
|
||||
state.has_error);
|
||||
} else {
|
||||
context.DiagnoseExpectedDeclSemi(Lex::TokenKind::Alias);
|
||||
context.RecoverFromDeclError(state, NodeKind::Alias,
|
||||
/*skip_past_likely_end=*/true);
|
||||
}
|
||||
context.AddNodeExpectingDeclSemi(state, NodeKind::Alias,
|
||||
Lex::TokenKind::Alias,
|
||||
/*is_def_allowed=*/false);
|
||||
}
|
||||
|
||||
} // namespace Carbon::Parse
|
||||
|
||||
Reference in New Issue
Block a user