From 9f5bb2ca23fef13550cf7d45245c13adf7a46a24 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 17 Dec 2024 23:07:09 +0000 Subject: [PATCH] CARBON_FATAL/CARBON_CHECK for cases that are (for now) unreachable --- toolchain/check/handle_name.cpp | 10 ++++------ toolchain/check/handle_noop.cpp | 17 +++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/toolchain/check/handle_name.cpp b/toolchain/check/handle_name.cpp index 7e17619501f23..81880fe14df69 100644 --- a/toolchain/check/handle_name.cpp +++ b/toolchain/check/handle_name.cpp @@ -127,9 +127,8 @@ 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; } @@ -137,9 +136,8 @@ auto HandleParseNode(Context& context, Parse::IdentifierNameId node_id) 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; diff --git a/toolchain/check/handle_noop.cpp b/toolchain/check/handle_noop.cpp index 251db60e7ab2f..b71f7b1d567de 100644 --- a/toolchain/check/handle_noop.cpp +++ b/toolchain/check/handle_noop.cpp @@ -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*/)