mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-23 20:02:39 +00:00
Require that InvalidParse nodes must have an error (#4482)
Unifies some boilerplate AddLeafNode calls for InvalidParse, and checks has_error in AddNode.
This commit is contained in:
1 parent
26e58b4587
commit
2841e9a67e
10 files changed
+31
-34
No files matched your search
@@ -24,11 +24,9 @@ auto HandleIfExprFinishCondition(Context& context) -> void {
|
||||
if (!state.has_error) {
|
||||
context.emitter().Emit(*context.position(), ExpectedThenAfterIf);
|
||||
}
|
||||
// Add placeholders for `IfExprThen` and final `Expr`.
|
||||
context.AddLeafNode(NodeKind::InvalidParse, *context.position(),
|
||||
/*has_error=*/true);
|
||||
context.AddLeafNode(NodeKind::InvalidParse, *context.position(),
|
||||
/*has_error=*/true);
|
||||
// Add invalid nodes to substitute for `IfExprThen` and the final `Expr`.
|
||||
context.AddInvalidParse(*context.position());
|
||||
context.AddInvalidParse(*context.position());
|
||||
context.ReturnErrorOnState();
|
||||
}
|
||||
}
|
||||
@@ -49,9 +47,8 @@ auto HandleIfExprFinishThen(Context& context) -> void {
|
||||
if (!state.has_error) {
|
||||
context.emitter().Emit(*context.position(), ExpectedElseAfterIf);
|
||||
}
|
||||
// Add placeholder for the final `Expr`.
|
||||
context.AddLeafNode(NodeKind::InvalidParse, *context.position(),
|
||||
/*has_error=*/true);
|
||||
// Add an invalid node to substitute for the final `Expr`.
|
||||
context.AddInvalidParse(*context.position());
|
||||
context.ReturnErrorOnState();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user