|
@@ -43,6 +43,20 @@ auto HandleParseNode(Context& context, Parse::ReturnTypeId node_id) -> bool {
|
|
|
// Propagate the type expression.
|
|
// Propagate the type expression.
|
|
|
auto [type_node_id, type_inst_id] = context.node_stack().PopExprWithNodeId();
|
|
auto [type_node_id, type_inst_id] = context.node_stack().PopExprWithNodeId();
|
|
|
auto type_id = ExprAsType(context, type_node_id, type_inst_id).type_id;
|
|
auto type_id = ExprAsType(context, type_node_id, type_inst_id).type_id;
|
|
|
|
|
+
|
|
|
|
|
+ // If the previous node was `IdentifierNameBeforeParams`, then it would have
|
|
|
|
|
+ // caused these entries to be pushed to the pattern stacks. But it's possible
|
|
|
|
|
+ // to have a fn declaration without any parameters, in which case we find
|
|
|
|
|
+ // `IdentifierNameNotBeforeParams` on the node stack. Then these entries are
|
|
|
|
|
+ // not on the pattern stacks yet. They are only needed in that case if we have
|
|
|
|
|
+ // a return type, which we now know that we do.
|
|
|
|
|
+ if (context.node_stack().PeekNodeKind() ==
|
|
|
|
|
+ Parse::NodeKind::IdentifierNameNotBeforeParams) {
|
|
|
|
|
+ context.pattern_block_stack().Push();
|
|
|
|
|
+ context.full_pattern_stack().PushFullPattern(
|
|
|
|
|
+ FullPatternStack::Kind::ExplicitParamList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
auto return_slot_pattern_id =
|
|
auto return_slot_pattern_id =
|
|
|
context.AddPatternInst<SemIR::ReturnSlotPattern>(
|
|
context.AddPatternInst<SemIR::ReturnSlotPattern>(
|
|
|
node_id, {.type_id = type_id, .type_inst_id = type_inst_id});
|
|
node_id, {.type_id = type_id, .type_inst_id = type_inst_id});
|