Build generic eval blocks incrementally (#5313)

Instead of building an eval block as a separate pass at the end of a
generic, build the eval block incrementally.

The larger change here is that asking for the type or constant value of
an instruction now always returns an unattached type or constant value,
in order to preserve the behavior that we previously achieved by doing
the rewrite to attached types and constant values at the end of handling
the generic.

This also incidentally fixes some subtle issues where attached types and
constant values would leak out into check and cause it to get confused
about differences between attached and unattached values. Check should
no longer see attached values except where it explicitly asks for them.

---------

Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
Richard Smith
2025-05-01 20:24:15 +00:00
committed by GitHub
co-authored by Dana Jansens
parent 797b14eb8e
commit 4f5d11a28b
138 changed files with 1067 additions and 2109 deletions
+2 -2
View File
@@ -623,7 +623,7 @@ static auto HandleFunctionDefinitionAfterSignature(
context.scope_stack().PushForFunctionBody(decl_id);
context.inst_block_stack().Push();
context.region_stack().PushRegion(context.inst_block_stack().PeekOrAdd());
StartGenericDefinition(context);
StartGenericDefinition(context, function.generic_id);
CheckFunctionDefinitionSignature(context, function);
@@ -770,7 +770,7 @@ auto HandleParseNode(Context& context,
if (IsValidBuiltinDeclaration(context, function, builtin_kind)) {
function.builtin_function_kind = builtin_kind;
// Build an empty generic definition if this is a generic builtin.
StartGenericDefinition(context);
StartGenericDefinition(context, function.generic_id);
FinishGenericDefinition(context, function.generic_id);
} else {
CARBON_DIAGNOSTIC(InvalidBuiltinSignature, Error,