Don't crash if a builtin fn is declared with positional parameters. (#5444)

Crash discovered by fuzzer.
This commit is contained in:
Richard Smith
2025-05-07 22:27:29 +00:00
committed by GitHub
parent e060342411
commit f2a16d8742
2 changed files with 83 additions and 0 deletions
+5
View File
@@ -681,6 +681,11 @@ static auto IsValidBuiltinDeclaration(Context& context,
const SemIR::Function& function,
SemIR::BuiltinFunctionKind builtin_kind)
-> bool {
if (!function.call_params_id.has_value()) {
// For now, we have no builtins that support positional parameters.
return false;
}
// Find the list of call parameters other than the implicit return slot.
auto call_params = context.inst_blocks().Get(function.call_params_id);
if (function.return_slot_pattern_id.has_value()) {