Fix deduction crash for function with missing parameters. (#4461)

This is because `var x:! () = ();` modifies the binding index, which
causes `A` to be generic, which causes the params to be used, which
crashes. There may be another issue to fix here so that the invalid
binding doesn't modify the binding index, but at least
`param_patterns_id` should probably be set consistently with
`params_id`.
This commit is contained in:
Jon Ross-Perkins
2024-10-31 17:12:49 +00:00
committed by GitHub
parent 85f6bf32b5
commit f70221c040
2 changed files with 75 additions and 5 deletions
+2
View File
@@ -183,8 +183,10 @@ static auto BuildFunctionDecl(Context& context,
auto name = PopNameComponent(context, return_slot_pattern_id);
if (!name.params_id.is_valid()) {
CARBON_CHECK(!name.param_patterns_id.is_valid());
context.TODO(node_id, "function with positional parameters");
name.params_id = SemIR::InstBlockId::Empty;
name.param_patterns_id = SemIR::InstBlockId::Empty;
}
auto name_context = context.decl_name_stack().FinishName(name);