Skip to content

Commit

Permalink
CARBON_FATAL/CARBON_CHECK for cases that are (for now) unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
dwblaikie committed Dec 17, 2024
1 parent 55afe8d commit 9f5bb2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
10 changes: 4 additions & 6 deletions toolchain/check/handle_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,17 @@ auto HandleParseNode(Context& context, Parse::IdentifierNameId node_id)
-> bool {
// The parent is responsible for binding the name.
auto name_id = GetIdentifierAsName(context, node_id);
if (!name_id) {
return context.TODO(node_id, "Error recovery from keyword name.");
}
CARBON_CHECK(name_id,
"Unreachable until we support checking error parse nodes");
context.node_stack().Push(node_id, *name_id);
return true;
}

auto HandleParseNode(Context& context, Parse::IdentifierNameExprId node_id)
-> bool {
auto name_id = GetIdentifierAsName(context, node_id);
if (!name_id) {
return context.TODO(node_id, "Error recovery from keyword name.");
}
CARBON_CHECK(name_id,
"Unreachable until we support checking error parse nodes");
context.node_stack().Push(node_id,
HandleNameAsExpr(context, node_id, *name_id));
return true;
Expand Down
17 changes: 9 additions & 8 deletions toolchain/check/handle_noop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ auto HandleParseNode(Context& /*context*/, Parse::EmptyDeclId /*node_id*/)
return true;
}

auto HandleParseNode(Context& context, Parse::InvalidParseId node_id) -> bool {
return context.TODO(node_id, "HandleInvalidParse");
auto HandleParseNode(Context& /*context*/, Parse::InvalidParseId /*node_id*/)
-> bool {
CARBON_FATAL("Unreachable until we support checking error parse nodes");
}

auto HandleParseNode(Context& context, Parse::InvalidParseStartId node_id)
-> bool {
return context.TODO(node_id, "HandleInvalidParseStart");
auto HandleParseNode(Context& /*context*/,
Parse::InvalidParseStartId /*node_id*/) -> bool {
CARBON_FATAL("Unreachable until we support checking error parse nodes");
}

auto HandleParseNode(Context& context, Parse::InvalidParseSubtreeId node_id)
-> bool {
return context.TODO(node_id, "HandleInvalidParseSubtree");
auto HandleParseNode(Context& /*context*/,
Parse::InvalidParseSubtreeId /*node_id*/) -> bool {
CARBON_FATAL("Unreachable until we support checking error parse nodes");
}

auto HandleParseNode(Context& /*context*/, Parse::PlaceholderId /*node_id*/)
Expand Down

0 comments on commit 9f5bb2c

Please sign in to comment.