handle_function.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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/base/kind_switch.h"
  5. #include "toolchain/check/context.h"
  6. #include "toolchain/check/convert.h"
  7. #include "toolchain/check/decl_introducer_state.h"
  8. #include "toolchain/check/decl_name_stack.h"
  9. #include "toolchain/check/function.h"
  10. #include "toolchain/check/generic.h"
  11. #include "toolchain/check/handle.h"
  12. #include "toolchain/check/import_ref.h"
  13. #include "toolchain/check/interface.h"
  14. #include "toolchain/check/merge.h"
  15. #include "toolchain/check/modifiers.h"
  16. #include "toolchain/check/name_component.h"
  17. #include "toolchain/sem_ir/builtin_function_kind.h"
  18. #include "toolchain/sem_ir/entry_point.h"
  19. #include "toolchain/sem_ir/function.h"
  20. #include "toolchain/sem_ir/ids.h"
  21. #include "toolchain/sem_ir/typed_insts.h"
  22. namespace Carbon::Check {
  23. auto HandleParseNode(Context& context, Parse::FunctionIntroducerId node_id)
  24. -> bool {
  25. // Create an instruction block to hold the instructions created as part of the
  26. // function signature, such as parameter and return types.
  27. context.inst_block_stack().Push();
  28. // Push the bracketing node.
  29. context.node_stack().Push(node_id);
  30. // Optional modifiers and the name follow.
  31. context.decl_introducer_state_stack().Push<Lex::TokenKind::Fn>();
  32. context.decl_name_stack().PushScopeAndStartName();
  33. // The function is potentially generic.
  34. StartGenericDecl(context);
  35. return true;
  36. }
  37. auto HandleParseNode(Context& context, Parse::ReturnTypeId node_id) -> bool {
  38. // Propagate the type expression.
  39. auto [type_node_id, type_inst_id] = context.node_stack().PopExprWithNodeId();
  40. auto type_id = ExprAsType(context, type_node_id, type_inst_id);
  41. // TODO: Use a dedicated instruction rather than VarStorage here.
  42. context.AddInstAndPush<SemIR::VarStorage>(
  43. node_id, {.type_id = type_id, .name_id = SemIR::NameId::ReturnSlot});
  44. return true;
  45. }
  46. static auto DiagnoseModifiers(Context& context, DeclIntroducerState& introducer,
  47. bool is_definition,
  48. SemIR::InstId parent_scope_inst_id,
  49. std::optional<SemIR::Inst> parent_scope_inst)
  50. -> void {
  51. CheckAccessModifiersOnDecl(context, introducer, parent_scope_inst);
  52. LimitModifiersOnDecl(context, introducer,
  53. KeywordModifierSet::Access | KeywordModifierSet::Extern |
  54. KeywordModifierSet::Method |
  55. KeywordModifierSet::Interface);
  56. RestrictExternModifierOnDecl(context, introducer, parent_scope_inst,
  57. is_definition);
  58. CheckMethodModifiersOnFunction(context, introducer, parent_scope_inst_id,
  59. parent_scope_inst);
  60. RequireDefaultFinalOnlyInInterfaces(context, introducer, parent_scope_inst);
  61. }
  62. // Checks that the parameter lists specified in a function declaration are
  63. // valid for a function declaration, and numbers the parameters.
  64. static auto CheckFunctionSignature(Context& context,
  65. const NameComponent& name_and_params)
  66. -> void {
  67. SemIR::RuntimeParamIndex next_index(0);
  68. for (auto param_id : llvm::concat<const SemIR::InstId>(
  69. context.inst_blocks().GetOrEmpty(name_and_params.implicit_params_id),
  70. context.inst_blocks().GetOrEmpty(name_and_params.params_id))) {
  71. auto param = context.insts().Get(param_id);
  72. // Find the parameter in the pattern.
  73. // TODO: This duplicates work done by Function::GetParamFromParamRefId.
  74. if (auto addr_pattern = param.TryAs<SemIR::AddrPattern>()) {
  75. param_id = addr_pattern->inner_id;
  76. param = context.insts().Get(param_id);
  77. }
  78. auto bind_name = param.TryAs<SemIR::AnyBindName>();
  79. if (bind_name) {
  80. param_id = bind_name->value_id;
  81. param = context.insts().Get(param_id);
  82. }
  83. auto param_inst = param.TryAs<SemIR::Param>();
  84. if (!param_inst) {
  85. // Once we support more generalized patterns we will need to diagnose
  86. // parameters with unsupported patterns.
  87. context.TODO(param_id, "unexpected syntax for parameter");
  88. // TODO: Also repair the param ID so downstream code doesn't need to deal
  89. // with this.
  90. continue;
  91. }
  92. // If this is a runtime parameter, number it.
  93. if (bind_name && bind_name->kind == SemIR::BindName::Kind) {
  94. param_inst->runtime_index = next_index;
  95. context.ReplaceInstBeforeConstantUse(param_id, *param_inst);
  96. ++next_index.index;
  97. }
  98. }
  99. // TODO: Also assign a parameter index to the return storage, if present.
  100. }
  101. // Tries to merge new_function into prev_function_id. Since new_function won't
  102. // have a definition even if one is upcoming, set is_definition to indicate the
  103. // planned result.
  104. //
  105. // If merging is successful, returns true and may update the previous function.
  106. // Otherwise, returns false. Prints a diagnostic when appropriate.
  107. static auto MergeFunctionRedecl(Context& context, SemIRLoc new_loc,
  108. SemIR::Function& new_function,
  109. bool new_is_import, bool new_is_definition,
  110. SemIR::FunctionId prev_function_id,
  111. SemIR::ImportIRId prev_import_ir_id) -> bool {
  112. auto& prev_function = context.functions().Get(prev_function_id);
  113. if (!CheckFunctionTypeMatches(context, new_function, prev_function)) {
  114. return false;
  115. }
  116. CheckIsAllowedRedecl(context, Lex::TokenKind::Fn, prev_function.name_id,
  117. RedeclInfo(new_function, new_loc, new_is_definition),
  118. RedeclInfo(prev_function, prev_function.latest_decl_id(),
  119. prev_function.definition_id.is_valid()),
  120. prev_import_ir_id);
  121. if (!prev_function.first_owning_decl_id.is_valid()) {
  122. prev_function.first_owning_decl_id = new_function.first_owning_decl_id;
  123. }
  124. if (new_is_definition) {
  125. // Track the signature from the definition, so that IDs in the body
  126. // match IDs in the signature.
  127. prev_function.MergeDefinition(new_function);
  128. prev_function.return_storage_id = new_function.return_storage_id;
  129. }
  130. if ((prev_import_ir_id.is_valid() && !new_is_import)) {
  131. ReplacePrevInstForMerge(context, new_function.parent_scope_id,
  132. prev_function.name_id,
  133. new_function.first_owning_decl_id);
  134. }
  135. return true;
  136. }
  137. // Check whether this is a redeclaration, merging if needed.
  138. static auto TryMergeRedecl(Context& context, Parse::AnyFunctionDeclId node_id,
  139. SemIR::InstId prev_id,
  140. SemIR::FunctionDecl& function_decl,
  141. SemIR::Function& function_info, bool is_definition)
  142. -> void {
  143. if (!prev_id.is_valid()) {
  144. return;
  145. }
  146. auto prev_function_id = SemIR::FunctionId::Invalid;
  147. auto prev_import_ir_id = SemIR::ImportIRId::Invalid;
  148. CARBON_KIND_SWITCH(context.insts().Get(prev_id)) {
  149. case CARBON_KIND(SemIR::FunctionDecl function_decl): {
  150. prev_function_id = function_decl.function_id;
  151. break;
  152. }
  153. case SemIR::ImportRefLoaded::Kind: {
  154. auto import_ir_inst =
  155. GetCanonicalImportIRInst(context, &context.sem_ir(), prev_id);
  156. // Verify the decl so that things like aliases are name conflicts.
  157. const auto* import_ir =
  158. context.import_irs().Get(import_ir_inst.ir_id).sem_ir;
  159. if (!import_ir->insts().Is<SemIR::FunctionDecl>(import_ir_inst.inst_id)) {
  160. break;
  161. }
  162. // Use the type to get the ID.
  163. if (auto struct_value = context.insts().TryGetAs<SemIR::StructValue>(
  164. context.constant_values().GetConstantInstId(prev_id))) {
  165. if (auto function_type = context.types().TryGetAs<SemIR::FunctionType>(
  166. struct_value->type_id)) {
  167. prev_function_id = function_type->function_id;
  168. prev_import_ir_id = import_ir_inst.ir_id;
  169. }
  170. }
  171. break;
  172. }
  173. default:
  174. break;
  175. }
  176. if (!prev_function_id.is_valid()) {
  177. context.DiagnoseDuplicateName(function_info.latest_decl_id(), prev_id);
  178. return;
  179. }
  180. if (MergeFunctionRedecl(context, node_id, function_info,
  181. /*new_is_import=*/false, is_definition,
  182. prev_function_id, prev_import_ir_id)) {
  183. // When merging, use the existing function rather than adding a new one.
  184. function_decl.function_id = prev_function_id;
  185. }
  186. }
  187. // Build a FunctionDecl describing the signature of a function. This
  188. // handles the common logic shared by function declaration syntax and function
  189. // definition syntax.
  190. static auto BuildFunctionDecl(Context& context,
  191. Parse::AnyFunctionDeclId node_id,
  192. bool is_definition)
  193. -> std::pair<SemIR::FunctionId, SemIR::InstId> {
  194. auto decl_block_id = context.inst_block_stack().Pop();
  195. auto return_storage_id = SemIR::InstId::Invalid;
  196. if (auto [return_node, maybe_return_storage_id] =
  197. context.node_stack().PopWithNodeIdIf<Parse::NodeKind::ReturnType>();
  198. maybe_return_storage_id) {
  199. return_storage_id = *maybe_return_storage_id;
  200. }
  201. auto name = PopNameComponent(context);
  202. if (!name.params_id.is_valid()) {
  203. context.TODO(node_id, "function with positional parameters");
  204. name.params_id = SemIR::InstBlockId::Empty;
  205. }
  206. // Check that the function signature is valid and number the parameters.
  207. CheckFunctionSignature(context, name);
  208. auto name_context = context.decl_name_stack().FinishName(name);
  209. context.node_stack()
  210. .PopAndDiscardSoloNodeId<Parse::NodeKind::FunctionIntroducer>();
  211. // Process modifiers.
  212. auto [parent_scope_inst_id, parent_scope_inst] =
  213. context.name_scopes().GetInstIfValid(name_context.parent_scope_id);
  214. auto introducer =
  215. context.decl_introducer_state_stack().Pop<Lex::TokenKind::Fn>();
  216. DiagnoseModifiers(context, introducer, is_definition, parent_scope_inst_id,
  217. parent_scope_inst);
  218. bool is_extern = introducer.modifier_set.HasAnyOf(KeywordModifierSet::Extern);
  219. auto virtual_modifier =
  220. introducer.modifier_set.ToEnum<SemIR::Function::VirtualModifier>()
  221. .Case(KeywordModifierSet::Virtual,
  222. SemIR::Function::VirtualModifier::Virtual)
  223. .Case(KeywordModifierSet::Abstract,
  224. SemIR::Function::VirtualModifier::Abstract)
  225. .Case(KeywordModifierSet::Impl,
  226. SemIR::Function::VirtualModifier::Impl)
  227. .Default(SemIR::Function::VirtualModifier::None);
  228. if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Interface)) {
  229. // TODO: Once we are saving the modifiers for a function, add check that
  230. // the function may only be defined if it is marked `default` or `final`.
  231. context.TODO(introducer.modifier_node_id(ModifierOrder::Decl),
  232. "interface modifier");
  233. }
  234. // Add the function declaration.
  235. auto function_decl = SemIR::FunctionDecl{
  236. SemIR::TypeId::Invalid, SemIR::FunctionId::Invalid, decl_block_id};
  237. auto decl_id =
  238. context.AddPlaceholderInst(SemIR::LocIdAndInst(node_id, function_decl));
  239. // Build the function entity. This will be merged into an existing function if
  240. // there is one, or otherwise added to the function store.
  241. auto function_info =
  242. SemIR::Function{{name_context.MakeEntityWithParamsBase(
  243. name, decl_id, is_extern, introducer.extern_library)},
  244. {.return_storage_id = return_storage_id,
  245. .virtual_modifier = virtual_modifier}};
  246. if (is_definition) {
  247. function_info.definition_id = decl_id;
  248. }
  249. TryMergeRedecl(context, node_id, name_context.prev_inst_id(), function_decl,
  250. function_info, is_definition);
  251. // Create a new function if this isn't a valid redeclaration.
  252. if (!function_decl.function_id.is_valid()) {
  253. if (function_info.is_extern && context.IsImplFile()) {
  254. DiagnoseExternRequiresDeclInApiFile(context, node_id);
  255. }
  256. function_info.generic_id = FinishGenericDecl(context, decl_id);
  257. function_decl.function_id = context.functions().Add(function_info);
  258. } else {
  259. FinishGenericRedecl(context, decl_id, function_info.generic_id);
  260. // TODO: Validate that the redeclaration doesn't set an access modifier.
  261. }
  262. function_decl.type_id = context.GetFunctionType(
  263. function_decl.function_id, context.scope_stack().PeekSpecificId());
  264. // Write the function ID into the FunctionDecl.
  265. context.ReplaceInstBeforeConstantUse(decl_id, function_decl);
  266. // Check if we need to add this to name lookup, now that the function decl is
  267. // done.
  268. if (!name_context.prev_inst_id().is_valid()) {
  269. // At interface scope, a function declaration introduces an associated
  270. // function.
  271. auto lookup_result_id = decl_id;
  272. if (parent_scope_inst && !name_context.has_qualifiers) {
  273. if (auto interface_scope =
  274. parent_scope_inst->TryAs<SemIR::InterfaceDecl>()) {
  275. lookup_result_id = BuildAssociatedEntity(
  276. context, interface_scope->interface_id, decl_id);
  277. }
  278. }
  279. context.decl_name_stack().AddName(name_context, lookup_result_id,
  280. introducer.modifier_set.GetAccessKind());
  281. }
  282. if (SemIR::IsEntryPoint(context.sem_ir(), function_decl.function_id)) {
  283. auto return_type_id = function_info.GetDeclaredReturnType(context.sem_ir());
  284. // TODO: Update this once valid signatures for the entry point are decided.
  285. if (function_info.implicit_param_refs_id.is_valid() ||
  286. !function_info.param_refs_id.is_valid() ||
  287. !context.inst_blocks().Get(function_info.param_refs_id).empty() ||
  288. (return_type_id.is_valid() &&
  289. return_type_id !=
  290. context.GetBuiltinType(SemIR::BuiltinInstKind::IntType) &&
  291. return_type_id != context.GetTupleType({}))) {
  292. CARBON_DIAGNOSTIC(InvalidMainRunSignature, Error,
  293. "invalid signature for `Main.Run` function; expected "
  294. "`fn ()` or `fn () -> i32`");
  295. context.emitter().Emit(node_id, InvalidMainRunSignature);
  296. }
  297. }
  298. if (!is_definition && context.IsImplFile() && !is_extern) {
  299. context.definitions_required().push_back(decl_id);
  300. }
  301. return {function_decl.function_id, decl_id};
  302. }
  303. auto HandleParseNode(Context& context, Parse::FunctionDeclId node_id) -> bool {
  304. BuildFunctionDecl(context, node_id, /*is_definition=*/false);
  305. context.decl_name_stack().PopScope();
  306. return true;
  307. }
  308. // Processes a function definition after a signature for which we have already
  309. // built a function ID. This logic is shared between processing regular function
  310. // definitions and delayed parsing of inline method definitions.
  311. static auto HandleFunctionDefinitionAfterSignature(
  312. Context& context, Parse::FunctionDefinitionStartId node_id,
  313. SemIR::FunctionId function_id, SemIR::InstId decl_id) -> void {
  314. auto& function = context.functions().Get(function_id);
  315. // Create the function scope and the entry block.
  316. context.return_scope_stack().push_back({.decl_id = decl_id});
  317. context.inst_block_stack().Push();
  318. context.scope_stack().Push(decl_id);
  319. StartGenericDefinition(context);
  320. context.AddCurrentCodeBlockToFunction();
  321. // Check the return type is complete.
  322. CheckFunctionReturnType(context, function.return_storage_id, function,
  323. SemIR::SpecificId::Invalid);
  324. // Check the parameter types are complete.
  325. for (auto param_ref_id : llvm::concat<const SemIR::InstId>(
  326. context.inst_blocks().GetOrEmpty(function.implicit_param_refs_id),
  327. context.inst_blocks().GetOrEmpty(function.param_refs_id))) {
  328. auto [param_id, param] =
  329. SemIR::Function::GetParamFromParamRefId(context.sem_ir(), param_ref_id);
  330. // The parameter types need to be complete.
  331. context.TryToCompleteType(param.type_id, [&] {
  332. CARBON_DIAGNOSTIC(
  333. IncompleteTypeInFunctionParam, Error,
  334. "parameter has incomplete type `{0}` in function definition",
  335. SemIR::TypeId);
  336. return context.emitter().Build(param_id, IncompleteTypeInFunctionParam,
  337. param.type_id);
  338. });
  339. }
  340. context.node_stack().Push(node_id, function_id);
  341. }
  342. auto HandleFunctionDefinitionSuspend(Context& context,
  343. Parse::FunctionDefinitionStartId node_id)
  344. -> SuspendedFunction {
  345. // Process the declaration portion of the function.
  346. auto [function_id, decl_id] =
  347. BuildFunctionDecl(context, node_id, /*is_definition=*/true);
  348. return {.function_id = function_id,
  349. .decl_id = decl_id,
  350. .saved_name_state = context.decl_name_stack().Suspend()};
  351. }
  352. auto HandleFunctionDefinitionResume(Context& context,
  353. Parse::FunctionDefinitionStartId node_id,
  354. SuspendedFunction suspended_fn) -> void {
  355. context.decl_name_stack().Restore(suspended_fn.saved_name_state);
  356. HandleFunctionDefinitionAfterSignature(
  357. context, node_id, suspended_fn.function_id, suspended_fn.decl_id);
  358. }
  359. auto HandleParseNode(Context& context, Parse::FunctionDefinitionStartId node_id)
  360. -> bool {
  361. // Process the declaration portion of the function.
  362. auto [function_id, decl_id] =
  363. BuildFunctionDecl(context, node_id, /*is_definition=*/true);
  364. HandleFunctionDefinitionAfterSignature(context, node_id, function_id,
  365. decl_id);
  366. return true;
  367. }
  368. auto HandleParseNode(Context& context, Parse::FunctionDefinitionId node_id)
  369. -> bool {
  370. SemIR::FunctionId function_id =
  371. context.node_stack().Pop<Parse::NodeKind::FunctionDefinitionStart>();
  372. // If the `}` of the function is reachable, reject if we need a return value
  373. // and otherwise add an implicit `return;`.
  374. if (context.is_current_position_reachable()) {
  375. if (context.functions().Get(function_id).return_storage_id.is_valid()) {
  376. CARBON_DIAGNOSTIC(
  377. MissingReturnStatement, Error,
  378. "missing `return` at end of function with declared return type");
  379. context.emitter().Emit(TokenOnly(node_id), MissingReturnStatement);
  380. } else {
  381. context.AddInst<SemIR::Return>(node_id, {});
  382. }
  383. }
  384. context.scope_stack().Pop();
  385. context.inst_block_stack().Pop();
  386. context.return_scope_stack().pop_back();
  387. context.decl_name_stack().PopScope();
  388. // If this is a generic function, collect information about the definition.
  389. auto& function = context.functions().Get(function_id);
  390. FinishGenericDefinition(context, function.generic_id);
  391. return true;
  392. }
  393. auto HandleParseNode(Context& context,
  394. Parse::BuiltinFunctionDefinitionStartId node_id) -> bool {
  395. // Process the declaration portion of the function.
  396. auto [function_id, _] =
  397. BuildFunctionDecl(context, node_id, /*is_definition=*/true);
  398. context.node_stack().Push(node_id, function_id);
  399. return true;
  400. }
  401. auto HandleParseNode(Context& context, Parse::BuiltinNameId node_id) -> bool {
  402. context.node_stack().Push(node_id);
  403. return true;
  404. }
  405. // Looks up a builtin function kind given its name as a string.
  406. // TODO: Move this out to another file.
  407. static auto LookupBuiltinFunctionKind(Context& context,
  408. Parse::BuiltinNameId name_id)
  409. -> SemIR::BuiltinFunctionKind {
  410. auto builtin_name = context.string_literal_values().Get(
  411. context.tokens().GetStringLiteralValue(
  412. context.parse_tree().node_token(name_id)));
  413. auto kind = SemIR::BuiltinFunctionKind::ForBuiltinName(builtin_name);
  414. if (kind == SemIR::BuiltinFunctionKind::None) {
  415. CARBON_DIAGNOSTIC(UnknownBuiltinFunctionName, Error,
  416. "unknown builtin function name \"{0}\"", std::string);
  417. context.emitter().Emit(name_id, UnknownBuiltinFunctionName,
  418. builtin_name.str());
  419. }
  420. return kind;
  421. }
  422. // Returns whether `function` is a valid declaration of the builtin
  423. // `builtin_inst_kind`.
  424. static auto IsValidBuiltinDeclaration(Context& context,
  425. const SemIR::Function& function,
  426. SemIR::BuiltinFunctionKind builtin_kind)
  427. -> bool {
  428. // Form the list of parameter types for the declaration.
  429. llvm::SmallVector<SemIR::TypeId> param_type_ids;
  430. auto implicit_param_refs =
  431. context.inst_blocks().GetOrEmpty(function.implicit_param_refs_id);
  432. auto param_refs = context.inst_blocks().GetOrEmpty(function.param_refs_id);
  433. param_type_ids.reserve(implicit_param_refs.size() + param_refs.size());
  434. for (auto param_id :
  435. llvm::concat<const SemIR::InstId>(implicit_param_refs, param_refs)) {
  436. // TODO: We also need to track whether the parameter is declared with
  437. // `var`.
  438. param_type_ids.push_back(context.insts().Get(param_id).type_id());
  439. }
  440. // Get the return type. This is `()` if none was specified.
  441. auto return_type_id = function.GetDeclaredReturnType(context.sem_ir());
  442. if (!return_type_id.is_valid()) {
  443. return_type_id = context.GetTupleType({});
  444. }
  445. return builtin_kind.IsValidType(context.sem_ir(), param_type_ids,
  446. return_type_id);
  447. }
  448. auto HandleParseNode(Context& context,
  449. Parse::BuiltinFunctionDefinitionId /*node_id*/) -> bool {
  450. auto name_id =
  451. context.node_stack().PopForSoloNodeId<Parse::NodeKind::BuiltinName>();
  452. auto [fn_node_id, function_id] =
  453. context.node_stack()
  454. .PopWithNodeId<Parse::NodeKind::BuiltinFunctionDefinitionStart>();
  455. auto builtin_kind = LookupBuiltinFunctionKind(context, name_id);
  456. if (builtin_kind != SemIR::BuiltinFunctionKind::None) {
  457. auto& function = context.functions().Get(function_id);
  458. if (IsValidBuiltinDeclaration(context, function, builtin_kind)) {
  459. function.builtin_function_kind = builtin_kind;
  460. } else {
  461. CARBON_DIAGNOSTIC(InvalidBuiltinSignature, Error,
  462. "invalid signature for builtin function \"{0}\"",
  463. std::string);
  464. context.emitter().Emit(fn_node_id, InvalidBuiltinSignature,
  465. builtin_kind.name().str());
  466. }
  467. }
  468. context.decl_name_stack().PopScope();
  469. return true;
  470. }
  471. } // namespace Carbon::Check