When converting an expression to type type, retain the resulting instruction as well as the TypeId. (#4355)

The `TypeId` is lossy, as it represents only the canonical type, and not
the specific computation that produced it.
This commit is contained in:
Richard Smith
2024-10-01 01:49:39 +00:00
committed by GitHub
parent 9d5ec52232
commit 4ca711c175
15 changed files with 48 additions and 33 deletions
+3 -3
View File
@@ -48,7 +48,7 @@ auto HandleParseNode(Context& context, Parse::InfixOperatorAsId node_id)
auto [rhs_node, rhs_id] = context.node_stack().PopExprWithNodeId();
auto [lhs_node, lhs_id] = context.node_stack().PopExprWithNodeId();
auto rhs_type_id = ExprAsType(context, rhs_node, rhs_id);
auto rhs_type_id = ExprAsType(context, rhs_node, rhs_id).type_id;
context.node_stack().Push(
node_id, ConvertForExplicitAs(context, node_id, lhs_id, rhs_type_id));
return true;
@@ -213,7 +213,7 @@ auto HandleParseNode(Context& context, Parse::InfixOperatorStarEqualId node_id)
auto HandleParseNode(Context& context, Parse::PostfixOperatorStarId node_id)
-> bool {
auto value_id = context.node_stack().PopExpr();
auto inner_type_id = ExprAsType(context, node_id, value_id);
auto inner_type_id = ExprAsType(context, node_id, value_id).type_id;
context.AddInstAndPush<SemIR::PointerType>(
node_id,
{.type_id = SemIR::TypeId::TypeType, .pointee_id = inner_type_id});
@@ -266,7 +266,7 @@ auto HandleParseNode(Context& context, Parse::PrefixOperatorConstId node_id)
"additional effect");
context.emitter().Emit(node_id, RepeatedConst);
}
auto inner_type_id = ExprAsType(context, node_id, value_id);
auto inner_type_id = ExprAsType(context, node_id, value_id).type_id;
context.AddInstAndPush<SemIR::ConstType>(
node_id, {.type_id = SemIR::TypeId::TypeType, .inner_id = inner_type_id});
return true;