decl_name_stack.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/check/decl_name_stack.h"
  5. #include <utility>
  6. #include "toolchain/base/kind_switch.h"
  7. #include "toolchain/check/context.h"
  8. #include "toolchain/check/diagnostic_helpers.h"
  9. #include "toolchain/check/generic.h"
  10. #include "toolchain/check/merge.h"
  11. #include "toolchain/check/name_component.h"
  12. #include "toolchain/check/name_lookup.h"
  13. #include "toolchain/check/type_completion.h"
  14. #include "toolchain/check/unused.h"
  15. #include "toolchain/diagnostics/diagnostic.h"
  16. #include "toolchain/sem_ir/ids.h"
  17. #include "toolchain/sem_ir/name_scope.h"
  18. #include "toolchain/sem_ir/typed_insts.h"
  19. namespace Carbon::Check {
  20. auto DeclNameStack::NameContext::prev_inst_id() const -> SemIR::InstId {
  21. switch (state) {
  22. case NameContext::State::Error:
  23. // The name is malformed and a diagnostic has already been emitted.
  24. return SemIR::InstId::None;
  25. case NameContext::State::Empty:
  26. CARBON_FATAL(
  27. "Name is missing, not expected to call existing_inst_id (but that "
  28. "may change based on error handling).");
  29. case NameContext::State::Resolved:
  30. return resolved_inst_id;
  31. case NameContext::State::Unresolved:
  32. return SemIR::InstId::None;
  33. case NameContext::State::Poisoned:
  34. CARBON_FATAL("Poisoned state should not call prev_inst_id()");
  35. case NameContext::State::Finished:
  36. CARBON_FATAL("Finished state should only be used internally");
  37. }
  38. }
  39. auto DeclNameStack::MakeEmptyNameContext() -> NameContext {
  40. return NameContext{
  41. .initial_scope_index = context_->scope_stack().PeekIndex(),
  42. .parent_scope_id = context_->scope_stack().PeekNameScopeId()};
  43. }
  44. auto DeclNameStack::MakeUnqualifiedName(SemIR::LocId loc_id,
  45. SemIR::NameId name_id) -> NameContext {
  46. NameContext context = MakeEmptyNameContext();
  47. ApplyAndLookupName(context, loc_id, name_id);
  48. return context;
  49. }
  50. auto DeclNameStack::PushScopeAndStartName() -> void {
  51. decl_name_stack_.push_back(MakeEmptyNameContext());
  52. // Create a scope for any parameters introduced in this name.
  53. context_->scope_stack().PushForDeclName();
  54. }
  55. auto DeclNameStack::FinishName(const NameComponent& name) -> NameContext {
  56. CARBON_CHECK(decl_name_stack_.back().state != NameContext::State::Finished,
  57. "Finished name twice");
  58. ApplyAndLookupName(decl_name_stack_.back(), name.name_loc_id, name.name_id);
  59. NameContext result = decl_name_stack_.back();
  60. decl_name_stack_.back().state = NameContext::State::Finished;
  61. return result;
  62. }
  63. auto DeclNameStack::FinishImplName() -> NameContext {
  64. CARBON_CHECK(decl_name_stack_.back().state == NameContext::State::Empty,
  65. "Impl has a name");
  66. NameContext result = decl_name_stack_.back();
  67. decl_name_stack_.back().state = NameContext::State::Finished;
  68. return result;
  69. }
  70. auto DeclNameStack::PopScope(bool check_unused) -> void {
  71. CARBON_CHECK(decl_name_stack_.back().state == NameContext::State::Finished,
  72. "Missing call to FinishName before PopScope");
  73. context_->scope_stack().PopTo(decl_name_stack_.back().initial_scope_index,
  74. check_unused);
  75. decl_name_stack_.pop_back();
  76. }
  77. auto DeclNameStack::Suspend() -> SuspendedName {
  78. CARBON_CHECK(decl_name_stack_.back().state == NameContext::State::Finished,
  79. "Missing call to FinishName before Suspend");
  80. SuspendedName result = {.name_context = decl_name_stack_.pop_back_val(),
  81. .scopes = {}};
  82. auto scope_index = result.name_context.initial_scope_index;
  83. auto& scope_stack = context_->scope_stack();
  84. while (scope_stack.PeekIndex() > scope_index) {
  85. result.scopes.push_back(scope_stack.Suspend());
  86. }
  87. CARBON_CHECK(scope_stack.PeekIndex() == scope_index,
  88. "Scope index {0} does not enclose the current scope {1}",
  89. scope_index, scope_stack.PeekIndex());
  90. return result;
  91. }
  92. auto DeclNameStack::Restore(SuspendedName&& sus) -> void {
  93. // The parent state must be the same when a name is restored.
  94. CARBON_CHECK(context_->scope_stack().PeekIndex() ==
  95. sus.name_context.initial_scope_index,
  96. "Name restored at the wrong position in the name stack.");
  97. // clang-tidy warns that the `std::move` below has no effect. While that's
  98. // true, this `move` defends against `NameContext` growing more state later.
  99. // NOLINTNEXTLINE(performance-move-const-arg)
  100. decl_name_stack_.push_back(std::move(sus.name_context));
  101. for (auto& suspended_scope : llvm::reverse(sus.scopes)) {
  102. // Reattempt to resolve the definition of the specific. The generic might
  103. // have been defined after we suspended this scope.
  104. if (suspended_scope.entry.specific_id.has_value()) {
  105. ResolveSpecificDefinition(*context_, sus.name_context.loc_id,
  106. suspended_scope.entry.specific_id);
  107. }
  108. context_->scope_stack().Restore(std::move(suspended_scope));
  109. }
  110. }
  111. auto DeclNameStack::AddName(NameContext name_context, SemIR::InstId target_id,
  112. SemIR::AccessKind access_kind) -> void {
  113. switch (name_context.state) {
  114. case NameContext::State::Error:
  115. return;
  116. case NameContext::State::Unresolved:
  117. if (!name_context.parent_scope_id.has_value()) {
  118. AddNameToLookup(*context_, name_context.name_id, target_id,
  119. name_context.initial_scope_index);
  120. } else {
  121. auto& name_scope =
  122. context_->name_scopes().Get(name_context.parent_scope_id);
  123. if (name_context.has_qualifiers) {
  124. auto inst = context_->insts().Get(name_scope.inst_id());
  125. if (!inst.Is<SemIR::Namespace>()) {
  126. // TODO: Point at the declaration for the scoped entity.
  127. CARBON_DIAGNOSTIC(
  128. QualifiedDeclOutsideScopeEntity, Error,
  129. "out-of-line declaration requires a declaration in "
  130. "scoped entity");
  131. context_->emitter().Emit(name_context.loc_id,
  132. QualifiedDeclOutsideScopeEntity);
  133. }
  134. }
  135. // Exports are only tracked when the declaration is at the file-level
  136. // scope. Otherwise, it's in some other entity, such as a class.
  137. if (access_kind == SemIR::AccessKind::Public &&
  138. name_context.initial_scope_index == ScopeIndex::Package) {
  139. context_->exports().push_back(target_id);
  140. }
  141. name_scope.AddRequired({.name_id = name_context.name_id,
  142. .result = SemIR::ScopeLookupResult::MakeFound(
  143. target_id, access_kind)});
  144. }
  145. break;
  146. default:
  147. CARBON_FATAL("Should not be calling AddName");
  148. break;
  149. }
  150. }
  151. auto DeclNameStack::AddNameOrDiagnose(NameContext name_context,
  152. SemIR::InstId target_id,
  153. SemIR::AccessKind access_kind) -> void {
  154. if (name_context.state == DeclNameStack::NameContext::State::Poisoned) {
  155. DiagnosePoisonedName(*context_, name_context.name_id_for_new_inst(),
  156. name_context.poisoning_loc_id, name_context.loc_id);
  157. } else if (auto id = name_context.prev_inst_id(); id.has_value()) {
  158. DiagnoseDuplicateName(*context_, name_context.name_id, name_context.loc_id,
  159. SemIR::LocId(id));
  160. } else {
  161. AddName(name_context, target_id, access_kind);
  162. }
  163. }
  164. auto DeclNameStack::LookupOrAddName(NameContext name_context,
  165. SemIR::InstId target_id,
  166. SemIR::AccessKind access_kind)
  167. -> SemIR::ScopeLookupResult {
  168. if (name_context.state == NameContext::State::Poisoned) {
  169. return SemIR::ScopeLookupResult::MakePoisoned(
  170. name_context.poisoning_loc_id);
  171. }
  172. if (auto id = name_context.prev_inst_id(); id.has_value()) {
  173. return SemIR::ScopeLookupResult::MakeFound(id, access_kind);
  174. }
  175. AddName(name_context, target_id, access_kind);
  176. return SemIR::ScopeLookupResult::MakeNotFound();
  177. }
  178. // Get the name scope and generic to use for associated entities in `scope`.
  179. // Typically this is None, in which case the input scope should be used, but
  180. // some entities have a separate generic and inner scope used for associated
  181. // entities.
  182. static auto GetAssociatedEntityScope(Context& context,
  183. const SemIR::NameScope& scope)
  184. -> std::pair<SemIR::NameScopeId, SemIR::GenericId> {
  185. auto scope_inst = context.insts().Get(scope.inst_id());
  186. CARBON_KIND_SWITCH(scope_inst) {
  187. case CARBON_KIND(SemIR::InterfaceDecl interface_decl): {
  188. const auto& interface =
  189. context.interfaces().Get(interface_decl.interface_id);
  190. return {interface.scope_with_self_id, interface.generic_with_self_id};
  191. }
  192. case CARBON_KIND(SemIR::InterfaceWithSelfDecl _): {
  193. CARBON_FATAL("Expected InterfaceDecl as qualifier scope");
  194. }
  195. case CARBON_KIND(SemIR::NamedConstraintDecl _): {
  196. // ResolveAsScope() does not allow named constraints as a scope qualifier.
  197. CARBON_FATAL(
  198. "Did not expect to find named constraint as scope qualifier");
  199. }
  200. case CARBON_KIND(SemIR::NamedConstraintWithSelfDecl _): {
  201. CARBON_FATAL("Expected NamedConstraintDecl as qualifier scope");
  202. }
  203. default:
  204. return {SemIR::NameScopeId::None, SemIR::GenericId::None};
  205. }
  206. }
  207. // Push a scope corresponding to a name qualifier. For example, for
  208. // `fn Class(T:! type).F(n: i32)` we will push the scope for `Class(T:! type)`
  209. // between the scope containing the declaration of `T` and the scope
  210. // containing the declaration of `n`.
  211. //
  212. // Returns the NameScopeId to use as the parent scope of the next name.
  213. static auto PushNameQualifierScope(Context& context, SemIR::LocId loc_id,
  214. SemIR::NameScopeId scope_id,
  215. SemIR::GenericId generic_id,
  216. bool has_error = false)
  217. -> SemIR::NameScopeId {
  218. // If the qualifier has no parameters, we don't need to keep around a
  219. // parameter scope.
  220. context.scope_stack().PopIfEmpty(/*check_unused=*/true);
  221. auto self_specific_id = SemIR::SpecificId::None;
  222. if (generic_id.has_value()) {
  223. self_specific_id = context.generics().GetSelfSpecific(generic_id);
  224. // When declaring a member of a generic, resolve the self specific.
  225. ResolveSpecificDefinition(context, loc_id, self_specific_id);
  226. }
  227. // Close the generic stack scope and open a new one for whatever comes after
  228. // the qualifier. As this is a qualifier it must not be the initial
  229. // declaration of the entity, so we treat it as a redeclaration.
  230. FinishGenericRedecl(context, generic_id);
  231. // What follows the qualifier will be a declaration. The signature of an
  232. // entity is also a declaration even if it is followed by curly braces
  233. // providing the definition.
  234. StartGenericDecl(context);
  235. const auto& scope = context.name_scopes().Get(scope_id);
  236. context.scope_stack().PushForEntity(scope.inst_id(), scope_id,
  237. self_specific_id, has_error);
  238. auto [assoc_entity_scope_id, assoc_entity_generic_id] =
  239. GetAssociatedEntityScope(context, scope);
  240. if (assoc_entity_scope_id.has_value()) {
  241. const auto& assoc_entity_scope =
  242. context.name_scopes().Get(assoc_entity_scope_id);
  243. // InterfaceDecl is the only inst that can be a scope qualifier and that has
  244. // an associated entity scope, the InterfaceWithSelfDecl.
  245. auto interface_decl = context.insts().GetAs<SemIR::InterfaceWithSelfDecl>(
  246. assoc_entity_scope.inst_id());
  247. auto& interface = context.interfaces().Get(interface_decl.interface_id);
  248. // An interface also introduces its 'Self' parameter into the associated
  249. // entity scope, despite it not being redeclared as part of the qualifier.
  250. context.scope_stack().AddCompileTimeBinding();
  251. context.scope_stack().PushCompileTimeBinding(interface.self_param_id);
  252. // Move into the interface-with-self scope.
  253. context.scope_stack().PushForEntity(
  254. assoc_entity_scope.inst_id(), assoc_entity_scope_id,
  255. context.generics().GetSelfSpecific(assoc_entity_generic_id), has_error);
  256. }
  257. // Enter a parameter scope in case the qualified name itself has parameters.
  258. context.scope_stack().PushForSameRegion();
  259. return assoc_entity_scope_id.has_value() ? assoc_entity_scope_id : scope_id;
  260. }
  261. auto DeclNameStack::ApplyNameQualifier(const NameComponent& name) -> void {
  262. auto& name_context = decl_name_stack_.back();
  263. ApplyAndLookupName(name_context, name.name_loc_id, name.name_id);
  264. name_context.has_qualifiers = true;
  265. // Resolve the qualifier as a scope and enter the new scope.
  266. auto [scope_id, generic_id] = ResolveAsScope(name_context, name);
  267. if (scope_id.has_value()) {
  268. name_context.parent_scope_id = PushNameQualifierScope(
  269. *context_, name_context.loc_id, scope_id, generic_id,
  270. context_->name_scopes().Get(scope_id).has_error());
  271. } else {
  272. name_context.state = NameContext::State::Error;
  273. }
  274. }
  275. auto DeclNameStack::ApplyAndLookupName(NameContext& name_context,
  276. SemIR::LocId loc_id,
  277. SemIR::NameId name_id) -> void {
  278. // Update the final name component.
  279. name_context.loc_id = loc_id;
  280. name_context.name_id = name_id;
  281. // Don't perform any more lookups after we hit an error. We still track the
  282. // final name, though.
  283. if (name_context.state == NameContext::State::Error) {
  284. return;
  285. }
  286. // For identifier nodes, we need to perform a lookup on the identifier.
  287. auto lookup_result = LookupNameInDecl(*context_, name_context.loc_id, name_id,
  288. name_context.parent_scope_id,
  289. name_context.initial_scope_index);
  290. if (lookup_result.is_poisoned()) {
  291. name_context.poisoning_loc_id = lookup_result.poisoning_loc_id();
  292. name_context.state = NameContext::State::Poisoned;
  293. } else if (!lookup_result.is_found()) {
  294. // Invalid indicates an unresolved name. Store it and return.
  295. name_context.state = NameContext::State::Unresolved;
  296. } else {
  297. // Store the resolved instruction and continue for the target scope
  298. // update.
  299. name_context.resolved_inst_id = lookup_result.target_inst_id();
  300. name_context.state = NameContext::State::Resolved;
  301. }
  302. }
  303. // Checks and returns whether name_context, which is used as a name qualifier,
  304. // was successfully resolved. Issues a suitable diagnostic if not.
  305. static auto CheckQualifierIsResolved(
  306. Context& context, const DeclNameStack::NameContext& name_context) -> bool {
  307. switch (name_context.state) {
  308. case DeclNameStack::NameContext::State::Empty:
  309. CARBON_FATAL("No qualifier to resolve");
  310. case DeclNameStack::NameContext::State::Resolved:
  311. return true;
  312. case DeclNameStack::NameContext::State::Poisoned:
  313. case DeclNameStack::NameContext::State::Unresolved:
  314. // Because more qualifiers were found, we diagnose that the earlier
  315. // qualifier failed to resolve.
  316. DiagnoseNameNotFound(context, name_context.loc_id, name_context.name_id);
  317. return false;
  318. case DeclNameStack::NameContext::State::Finished:
  319. CARBON_FATAL("Added a qualifier after calling FinishName");
  320. case DeclNameStack::NameContext::State::Error:
  321. // Already in an error state, so return without examining.
  322. return false;
  323. }
  324. }
  325. // Diagnose that a qualified declaration name specifies an incomplete class as
  326. // its scope.
  327. static auto DiagnoseQualifiedDeclInIncompleteClassScope(Context& context,
  328. SemIR::LocId loc_id,
  329. SemIR::ClassId class_id)
  330. -> void {
  331. Diagnostics::ContextScope diagnostic_context(
  332. &context.emitter(), [&](auto& builder) {
  333. CARBON_DIAGNOSTIC(QualifiedDeclInIncompleteClassScope, Context,
  334. "cannot declare a member of incomplete class {0}",
  335. SemIR::TypeId);
  336. builder.Context(loc_id, QualifiedDeclInIncompleteClassScope,
  337. context.classes().Get(class_id).self_type_id);
  338. });
  339. DiagnoseIncompleteClass(context, class_id);
  340. }
  341. // Diagnose that a qualified declaration name specifies an undefined interface
  342. // as its scope.
  343. static auto DiagnoseQualifiedDeclInUndefinedInterfaceScope(
  344. Context& context, SemIR::LocId loc_id, SemIR::InterfaceId interface_id,
  345. SemIR::InstId interface_inst_id) -> void {
  346. Diagnostics::ContextScope diagnostic_context(
  347. &context.emitter(), [&](auto& builder) {
  348. CARBON_DIAGNOSTIC(QualifiedDeclInUndefinedInterfaceScope, Context,
  349. "cannot declare a member of undefined interface {0}",
  350. InstIdAsType);
  351. builder.Context(loc_id, QualifiedDeclInUndefinedInterfaceScope,
  352. interface_inst_id);
  353. });
  354. DiagnoseIncompleteInterface(context, interface_id);
  355. }
  356. // Diagnose that a qualified declaration name specifies a different package as
  357. // its scope.
  358. static auto DiagnoseQualifiedDeclInImportedPackage(Context& context,
  359. SemIR::LocId use_loc_id,
  360. SemIR::LocId import_loc_id)
  361. -> void {
  362. CARBON_DIAGNOSTIC(QualifiedDeclOutsidePackage, Error,
  363. "imported packages cannot be used for declarations");
  364. CARBON_DIAGNOSTIC(QualifiedDeclOutsidePackageSource, Note,
  365. "package imported here");
  366. context.emitter()
  367. .Build(use_loc_id, QualifiedDeclOutsidePackage)
  368. .Note(import_loc_id, QualifiedDeclOutsidePackageSource)
  369. .Emit();
  370. }
  371. // Diagnose that a qualified declaration name specifies a non-scope entity as
  372. // its scope.
  373. static auto DiagnoseQualifiedDeclInNonScope(
  374. Context& context, SemIR::LocId use_loc_id,
  375. SemIR::LocId non_scope_entity_loc_id) -> void {
  376. CARBON_DIAGNOSTIC(QualifiedNameInNonScope, Error,
  377. "name qualifiers are only allowed for entities that "
  378. "provide a scope");
  379. CARBON_DIAGNOSTIC(QualifiedNameNonScopeEntity, Note,
  380. "referenced non-scope entity declared here");
  381. context.emitter()
  382. .Build(use_loc_id, QualifiedNameInNonScope)
  383. .Note(non_scope_entity_loc_id, QualifiedNameNonScopeEntity)
  384. .Emit();
  385. }
  386. auto DeclNameStack::ResolveAsScope(const NameContext& name_context,
  387. const NameComponent& name) const
  388. -> std::pair<SemIR::NameScopeId, SemIR::GenericId> {
  389. constexpr std::pair<SemIR::NameScopeId, SemIR::GenericId> InvalidResult = {
  390. SemIR::NameScopeId::None, SemIR::GenericId::None};
  391. if (!CheckQualifierIsResolved(*context_, name_context)) {
  392. return InvalidResult;
  393. }
  394. if (name_context.state == NameContext::State::Poisoned) {
  395. return InvalidResult;
  396. }
  397. auto new_params = DeclParams(
  398. name.name_loc_id, name.first_param_node_id, name.last_param_node_id,
  399. name.implicit_param_patterns_id, name.param_patterns_id);
  400. // Find the scope corresponding to the resolved instruction.
  401. // TODO: When diagnosing qualifiers on names, print a diagnostic that talks
  402. // about qualifiers instead of redeclarations. Maybe also rename
  403. // CheckRedeclParamsMatch.
  404. CARBON_KIND_SWITCH(context_->insts().Get(name_context.resolved_inst_id)) {
  405. case CARBON_KIND(SemIR::ClassDecl class_decl): {
  406. const auto& class_info = context_->classes().Get(class_decl.class_id);
  407. if (!CheckRedeclParamsMatch(*context_, new_params,
  408. DeclParams(class_info))) {
  409. return InvalidResult;
  410. }
  411. if (!class_info.is_complete()) {
  412. DiagnoseQualifiedDeclInIncompleteClassScope(
  413. *context_, name_context.loc_id, class_decl.class_id);
  414. return InvalidResult;
  415. }
  416. return {class_info.scope_id, class_info.generic_id};
  417. }
  418. case CARBON_KIND(SemIR::InterfaceDecl interface_decl): {
  419. const auto& interface_info =
  420. context_->interfaces().Get(interface_decl.interface_id);
  421. if (!CheckRedeclParamsMatch(*context_, new_params,
  422. DeclParams(interface_info))) {
  423. return InvalidResult;
  424. }
  425. if (!interface_info.is_complete()) {
  426. DiagnoseQualifiedDeclInUndefinedInterfaceScope(
  427. *context_, name_context.loc_id, interface_decl.interface_id,
  428. name_context.resolved_inst_id);
  429. return InvalidResult;
  430. }
  431. // The scope and generic of an `I(T:! type)` is the outer
  432. // interface-without-self. That is the generic where parameters appear.
  433. // However when moving to the next qualifier, we need to move to the
  434. // interface-with-self for the associated entity name.
  435. return {interface_info.scope_without_self_id, interface_info.generic_id};
  436. }
  437. case CARBON_KIND(SemIR::Namespace resolved_inst): {
  438. auto scope_id = resolved_inst.name_scope_id;
  439. auto& scope = context_->name_scopes().Get(scope_id);
  440. // This is specifically for qualified name handling.
  441. if (!CheckRedeclParamsMatch(
  442. *context_, new_params,
  443. DeclParams(SemIR::LocId(name_context.resolved_inst_id),
  444. Parse::NodeId::None, Parse::NodeId::None,
  445. SemIR::InstBlockId::None, SemIR::InstBlockId::None))) {
  446. return InvalidResult;
  447. }
  448. if (scope.is_closed_import()) {
  449. DiagnoseQualifiedDeclInImportedPackage(*context_, name_context.loc_id,
  450. SemIR::LocId(scope.inst_id()));
  451. // Only error once per package. Recover by allowing this package name to
  452. // be used as a name qualifier.
  453. scope.set_is_closed_import(false);
  454. }
  455. return {scope_id, SemIR::GenericId::None};
  456. }
  457. default: {
  458. DiagnoseQualifiedDeclInNonScope(
  459. *context_, name_context.loc_id,
  460. SemIR::LocId(name_context.resolved_inst_id));
  461. return InvalidResult;
  462. }
  463. }
  464. }
  465. } // namespace Carbon::Check