From dc84664b2c9f3076777899ce86910cf19b492c24 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 14 Jul 2024 18:19:59 +0000 Subject: [PATCH] Build an evaluation block for the definition region of a generic. --- toolchain/check/generic.cpp | 17 ++++++++-- .../check/testdata/array/generic_empty.carbon | 13 ++++---- .../testdata/class/fail_generic_method.carbon | 9 ++++-- .../check/testdata/class/generic/basic.carbon | 9 ++++-- .../class/generic/fail_todo_use.carbon | 9 ++++-- .../check/testdata/class/generic/field.carbon | 18 ++++++++--- .../check/testdata/class/generic/self.carbon | 28 ++++++++--------- .../testdata/class/generic_method.carbon | 9 ++++-- .../check/testdata/eval/fail_symbolic.carbon | 2 +- toolchain/check/testdata/eval/symbolic.carbon | 31 ++++++++++--------- .../fail_type_param_mismatch.carbon | 18 +++++------ .../generic/no_prelude/type_param.carbon | 20 ++++++------ .../no_prelude/type_param_scope.carbon | 8 ++--- .../function/generic/redeclare.carbon | 16 +++++----- .../impl/fail_extend_impl_forall.carbon | 2 +- .../no_prelude/as_type_of_type.carbon | 10 +++--- .../fail_add_member_outside_definition.carbon | 2 +- .../fail_generic_redeclaration.carbon | 4 +-- .../no_prelude/fail_todo_facet_lookup.carbon | 2 +- .../fail_todo_generic_default_fn.carbon | 2 +- .../interface/no_prelude/generic.carbon | 10 +++--- .../no_prelude/generic_import.carbon | 2 +- toolchain/sem_ir/formatter.cpp | 8 ++--- 23 files changed, 145 insertions(+), 104 deletions(-) diff --git a/toolchain/check/generic.cpp b/toolchain/check/generic.cpp index 06f5af48a9561..d734113cb8301 100644 --- a/toolchain/check/generic.cpp +++ b/toolchain/check/generic.cpp @@ -145,8 +145,16 @@ static auto MakeGenericEvalBlock(Context& context, SemIR::GenericId generic_id, if ((dep_kind & GenericRegionStack::DependencyKind::SymbolicType) != GenericRegionStack::DependencyKind::None) { auto inst = context.insts().Get(inst_id); - inst.SetType(AddGenericTypeToEvalBlock( - context, generic_id, region, constants_in_generic, inst.type_id())); + auto type_id = AddGenericTypeToEvalBlock( + context, generic_id, region, constants_in_generic, inst.type_id()); + // TODO: Eventually, completeness requirements should be modeled as + // constraints on the generic rather than properties of the type. For now, + // require the transformed type to be complete if the original was. + // TODO: We'll also need to do this when evaluating the eval block. + if (context.types().IsComplete(inst.type_id())) { + context.TryToCompleteType(type_id); + } + inst.SetType(type_id); context.sem_ir().insts().Set(inst_id, inst); } @@ -231,7 +239,10 @@ auto FinishGenericDefinition(Context& context, SemIR::GenericId generic_id) return; } - // TODO: Track the list of dependent instructions in this region. + auto definition_block_id = MakeGenericEvalBlock( + context, generic_id, SemIR::GenericInstIndex::Region::Definition); + context.generics().Get(generic_id).definition_block_id = definition_block_id; + context.generic_region_stack().Pop(); } diff --git a/toolchain/check/testdata/array/generic_empty.carbon b/toolchain/check/testdata/array/generic_empty.carbon index 38d6141de0688..f0248f884bc4a 100644 --- a/toolchain/check/testdata/array/generic_empty.carbon +++ b/toolchain/check/testdata/array/generic_empty.carbon @@ -24,6 +24,7 @@ fn G(T:! type) { // CHECK:STDOUT: %.3: type = array_type %.2, %T [symbolic] // CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic] // CHECK:STDOUT: %array: %.3 = tuple_value () [symbolic] +// CHECK:STDOUT: %.5: type = ptr_type @G.%.loc13_17 (%.3) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -42,14 +43,14 @@ fn G(T:! type) { // CHECK:STDOUT: fn @G(%T: type) // CHECK:STDOUT: generic [%T: type] { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T.ref (constants.%T)] // CHECK:STDOUT: %.loc13_16: i32 = int_literal 0 [template = constants.%.2] -// CHECK:STDOUT: %.loc13_17: type = array_type %.loc13_16, %T [symbolic = constants.%.3] -// CHECK:STDOUT: %arr.var: ref %.3 = var arr -// CHECK:STDOUT: %arr: ref %.3 = bind_name arr, %arr.var +// CHECK:STDOUT: %.loc13_17: type = array_type %.loc13_16, %T [symbolic = %.loc13_17 (constants.%.3)] +// CHECK:STDOUT: %arr.var: ref @G.%.loc13_17 (%.3) = var arr +// CHECK:STDOUT: %arr: ref @G.%.loc13_17 (%.3) = bind_name arr, %arr.var // CHECK:STDOUT: %.loc13_22.1: %.1 = tuple_literal () -// CHECK:STDOUT: %.loc13_22.2: init %.3 = array_init () to %arr.var [symbolic = constants.%array] -// CHECK:STDOUT: %.loc13_23: init %.3 = converted %.loc13_22.1, %.loc13_22.2 [symbolic = constants.%array] +// CHECK:STDOUT: %.loc13_22.2: init @G.%.loc13_17 (%.3) = array_init () to %arr.var [symbolic = %.loc13_22.2 (constants.%array)] +// CHECK:STDOUT: %.loc13_23: init @G.%.loc13_17 (%.3) = converted %.loc13_22.1, %.loc13_22.2 [symbolic = %.loc13_22.2 (constants.%array)] // CHECK:STDOUT: assign %arr.var, %.loc13_23 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/fail_generic_method.carbon b/toolchain/check/testdata/class/fail_generic_method.carbon index e90960d29c287..1e3ee32d2bc0f 100644 --- a/toolchain/check/testdata/class/fail_generic_method.carbon +++ b/toolchain/check/testdata/class/fail_generic_method.carbon @@ -82,8 +82,8 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: %.2 = field_decl a, element0 [template] +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12 (constants.%T)] +// CHECK:STDOUT: %.loc12: (%.2) = field_decl a, element0 [template] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %.loc13: type = specific_constant constants.%Class.2, file.%Class.decl(constants.%T) [symbolic = %.loc13 (constants.%Class.2)] // CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc13 [symbolic = %.loc13 (constants.%Class.2)] @@ -122,6 +122,11 @@ fn Class(N:! i32).F[self: Self](n: T) {} // CHECK:STDOUT: @Class.%T.ref.loc13 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific file.%Class.decl(@Class.%T.ref.loc12) { +// CHECK:STDOUT: declaration: +// CHECK:STDOUT: file.%T.loc11_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific file.%.decl(constants.%N) { // CHECK:STDOUT: declaration: // CHECK:STDOUT: file.%N.loc32_10.2 => constants.%N diff --git a/toolchain/check/testdata/class/generic/basic.carbon b/toolchain/check/testdata/class/generic/basic.carbon index 037aece1e0269..5d5441296daa8 100644 --- a/toolchain/check/testdata/class/generic/basic.carbon +++ b/toolchain/check/testdata/class/generic/basic.carbon @@ -75,8 +75,8 @@ class Class(T:! type) { // CHECK:STDOUT: %T.ref.loc17: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc17 (constants.%T)] // CHECK:STDOUT: %return.var.loc17: ref %T = var // CHECK:STDOUT: } -// CHECK:STDOUT: %T.ref.loc21: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc21: %.4 = field_decl k, element0 [template] +// CHECK:STDOUT: %T.ref.loc21: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc21 (constants.%T)] +// CHECK:STDOUT: %.loc21: (%.4) = field_decl k, element0 [template] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%Class.2 @@ -125,3 +125,8 @@ class Class(T:! type) { // CHECK:STDOUT: @Class.%T.ref.loc17 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific file.%Class.decl(@Class.%T.ref.loc21) { +// CHECK:STDOUT: declaration: +// CHECK:STDOUT: file.%T.loc11_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/fail_todo_use.carbon b/toolchain/check/testdata/class/generic/fail_todo_use.carbon index 097e433630f0d..aa121ada21ab0 100644 --- a/toolchain/check/testdata/class/generic/fail_todo_use.carbon +++ b/toolchain/check/testdata/class/generic/fail_todo_use.carbon @@ -99,8 +99,8 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc12_34: type = ptr_type %T [symbolic = %.loc12_34 (constants.%.3)] // CHECK:STDOUT: %return.var: ref %.3 = var // CHECK:STDOUT: } -// CHECK:STDOUT: %T.ref.loc16: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc16: %.4 = field_decl k, element0 [template] +// CHECK:STDOUT: %T.ref.loc16: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc16 (constants.%T)] +// CHECK:STDOUT: %.loc16: (%.4) = field_decl k, element0 [template] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%Class.2 @@ -156,6 +156,11 @@ fn Run() -> i32 { // CHECK:STDOUT: @Class.%.loc12_34 => constants.%.3 // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific file.%Class.decl(@Class.%T.ref.loc16) { +// CHECK:STDOUT: declaration: +// CHECK:STDOUT: file.%T.loc11_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific file.%Class.decl(i32) { // CHECK:STDOUT: declaration: // CHECK:STDOUT: file.%T.loc11_13.2 => i32 diff --git a/toolchain/check/testdata/class/generic/field.carbon b/toolchain/check/testdata/class/generic/field.carbon index 93f7ee6f2cafa..6e394c2e2d126 100644 --- a/toolchain/check/testdata/class/generic/field.carbon +++ b/toolchain/check/testdata/class/generic/field.carbon @@ -95,8 +95,8 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc2_13.2: type] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc2_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc3: %.2 = field_decl x, element0 [template] +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc2_13.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %.loc3: (%.2) = field_decl x, element0 [template] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%Class.2 @@ -118,6 +118,11 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: file.%T.loc2_13.2 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific file.%Class.decl(@Class.%T.ref) { +// CHECK:STDOUT: declaration: +// CHECK:STDOUT: file.%T.loc2_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific file.%G.decl(constants.%T) { // CHECK:STDOUT: declaration: // CHECK:STDOUT: @G.%T => constants.%T @@ -196,8 +201,8 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc2_13.2: type] { -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc2_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc3: %.2 = field_decl x, element0 [template] +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc2_13.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %.loc3: (%.2) = field_decl x, element0 [template] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%Class.2 @@ -228,6 +233,11 @@ fn H(U:! type, c: Class(U)) -> U { // CHECK:STDOUT: file.%T.loc2_13.2 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific file.%Class.decl(@Class.%T.ref) { +// CHECK:STDOUT: declaration: +// CHECK:STDOUT: file.%T.loc2_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific file.%Class.decl(i32) { // CHECK:STDOUT: declaration: // CHECK:STDOUT: file.%T.loc2_13.2 => i32 diff --git a/toolchain/check/testdata/class/generic/self.carbon b/toolchain/check/testdata/class/generic/self.carbon index 796e7cf5a0981..48f12c7149e8a 100644 --- a/toolchain/check/testdata/class/generic/self.carbon +++ b/toolchain/check/testdata/class/generic/self.carbon @@ -84,23 +84,23 @@ class Class(T:! type) { // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1] -// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc17_17: init type = call %Class.ref(%T.ref) [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc17_19.1: type = value_of_initializer %.loc17_17 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %.loc17_19.2: type = converted %.loc17_17, %.loc17_19.1 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %c.var: ref %Class.2 = var c -// CHECK:STDOUT: %c: ref %Class.2 = bind_name c, %c.var +// CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %.loc17_17: init type = call %Class.ref(%T.ref) [symbolic = %.loc17_17 (constants.%Class.2)] +// CHECK:STDOUT: %.loc17_19.1: type = value_of_initializer %.loc17_17 [symbolic = %.loc17_17 (constants.%Class.2)] +// CHECK:STDOUT: %.loc17_19.2: type = converted %.loc17_17, %.loc17_19.1 [symbolic = %.loc17_17 (constants.%Class.2)] +// CHECK:STDOUT: %c.var: ref @F.%.loc17_17 (%Class.2) = var c +// CHECK:STDOUT: %c: ref @F.%.loc17_17 (%Class.2) = bind_name c, %c.var // CHECK:STDOUT: %MakeSelf.ref: %MakeSelf.type = name_ref MakeSelf, @Class.%MakeSelf.decl [template = constants.%MakeSelf] -// CHECK:STDOUT: %.loc17_9: ref %Class.2 = splice_block %c.var {} -// CHECK:STDOUT: %MakeSelf.call: init %Class.2 = call %MakeSelf.ref() to %.loc17_9 +// CHECK:STDOUT: %.loc17_9: ref @F.%.loc17_17 (%Class.2) = splice_block %c.var {} +// CHECK:STDOUT: %MakeSelf.call: init @F.%.loc17_17 (%Class.2) = call %MakeSelf.ref() to %.loc17_9 // CHECK:STDOUT: assign %c.var, %MakeSelf.call -// CHECK:STDOUT: %.loc18_12: type = specific_constant constants.%Class.2, file.%Class.decl(constants.%T) [symbolic = constants.%Class.2] -// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc18_12 [symbolic = constants.%Class.2] -// CHECK:STDOUT: %s.var: ref %Class.2 = var s -// CHECK:STDOUT: %s: ref %Class.2 = bind_name s, %s.var +// CHECK:STDOUT: %.loc18_12: type = specific_constant constants.%Class.2, file.%Class.decl(constants.%T) [symbolic = %.loc17_17 (constants.%Class.2)] +// CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc18_12 [symbolic = %.loc17_17 (constants.%Class.2)] +// CHECK:STDOUT: %s.var: ref @F.%.loc17_17 (%Class.2) = var s +// CHECK:STDOUT: %s: ref @F.%.loc17_17 (%Class.2) = bind_name s, %s.var // CHECK:STDOUT: %MakeClass.ref: %MakeClass.type = name_ref MakeClass, @Class.%MakeClass.decl [template = constants.%MakeClass] -// CHECK:STDOUT: %.loc18_9: ref %Class.2 = splice_block %s.var {} -// CHECK:STDOUT: %MakeClass.call: init %Class.2 = call %MakeClass.ref() to %.loc18_9 +// CHECK:STDOUT: %.loc18_9: ref @F.%.loc17_17 (%Class.2) = splice_block %s.var {} +// CHECK:STDOUT: %MakeClass.call: init @F.%.loc17_17 (%Class.2) = call %MakeClass.ref() to %.loc18_9 // CHECK:STDOUT: assign %s.var, %MakeClass.call // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/generic_method.carbon b/toolchain/check/testdata/class/generic_method.carbon index ebf33e41f36de..ffca2fd596c1b 100644 --- a/toolchain/check/testdata/class/generic_method.carbon +++ b/toolchain/check/testdata/class/generic_method.carbon @@ -56,8 +56,8 @@ fn Class(T:! type).F[self: Self](n: T) {} // CHECK:STDOUT: // CHECK:STDOUT: class @Class // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: %.2 = field_decl a, element0 [template] +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, file.%T.loc11_13.2 [symbolic = %T.ref.loc12 (constants.%T)] +// CHECK:STDOUT: %.loc12: (%.2) = field_decl a, element0 [template] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %.loc13: type = specific_constant constants.%Class.2, file.%Class.decl(constants.%T) [symbolic = %.loc13 (constants.%Class.2)] // CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc13 [symbolic = %.loc13 (constants.%Class.2)] @@ -91,3 +91,8 @@ fn Class(T:! type).F[self: Self](n: T) {} // CHECK:STDOUT: @Class.%T.ref.loc13 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific file.%Class.decl(@Class.%T.ref.loc12) { +// CHECK:STDOUT: declaration: +// CHECK:STDOUT: file.%T.loc11_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/eval/fail_symbolic.carbon b/toolchain/check/testdata/eval/fail_symbolic.carbon index b4afd5f877931..a573a9f93938b 100644 --- a/toolchain/check/testdata/eval/fail_symbolic.carbon +++ b/toolchain/check/testdata/eval/fail_symbolic.carbon @@ -54,7 +54,7 @@ fn G(N:! i32) { // CHECK:STDOUT: generic [%N: i32] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %N.ref: i32 = name_ref N, %N [symbolic = constants.%N] +// CHECK:STDOUT: %N.ref: i32 = name_ref N, %N [symbolic = %N.ref (constants.%N)] // CHECK:STDOUT: %.loc16_11.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc16_11.2: type = converted %int.make_type_32, %.loc16_11.1 [template = i32] // CHECK:STDOUT: %.loc16_17: type = array_type %N.ref, i32 [template = ] diff --git a/toolchain/check/testdata/eval/symbolic.carbon b/toolchain/check/testdata/eval/symbolic.carbon index 8c1088c4e45e6..315a5386bd14b 100644 --- a/toolchain/check/testdata/eval/symbolic.carbon +++ b/toolchain/check/testdata/eval/symbolic.carbon @@ -32,6 +32,7 @@ fn F(T:! type) { // CHECK:STDOUT: %.9: i32 = int_literal 5 [template] // CHECK:STDOUT: %.10: type = array_type %.9, %T [symbolic] // CHECK:STDOUT: %.11: type = ptr_type %.10 [symbolic] +// CHECK:STDOUT: %.12: type = ptr_type @F.%.loc15_15 (%.10) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -50,23 +51,23 @@ fn F(T:! type) { // CHECK:STDOUT: fn @F(%T: type) // CHECK:STDOUT: generic [%T: type] { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref.loc13_11: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc13_12: type = ptr_type %T [symbolic = constants.%.2] -// CHECK:STDOUT: %T.ref.loc13_21: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc13_15: type = const_type %T [symbolic = constants.%.3] +// CHECK:STDOUT: %T.ref.loc13_11: type = name_ref T, %T [symbolic = %T.ref.loc13_11 (constants.%T)] +// CHECK:STDOUT: %.loc13_12: type = ptr_type %T [symbolic = %.loc13_12 (constants.%.2)] +// CHECK:STDOUT: %T.ref.loc13_21: type = name_ref T, %T [symbolic = %T.ref.loc13_11 (constants.%T)] +// CHECK:STDOUT: %.loc13_15: type = const_type %T [symbolic = %.loc13_15 (constants.%.3)] // CHECK:STDOUT: %.loc13_22.1: %.4 = tuple_literal (%.loc13_12, %.loc13_15) -// CHECK:STDOUT: %.loc13_22.2: type = converted %.loc13_22.1, constants.%.5 [symbolic = constants.%.5] -// CHECK:STDOUT: %u.var: ref %.5 = var u -// CHECK:STDOUT: %u: ref %.5 = bind_name u, %u.var -// CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc14: type = struct_type {.a: %T} [symbolic = constants.%.8] -// CHECK:STDOUT: %v.var: ref %.8 = var v -// CHECK:STDOUT: %v: ref %.8 = bind_name v, %v.var -// CHECK:STDOUT: %T.ref.loc15: type = name_ref T, %T [symbolic = constants.%T] +// CHECK:STDOUT: %.loc13_22.2: type = converted %.loc13_22.1, constants.%.5 [symbolic = %.loc13_22.2 (constants.%.5)] +// CHECK:STDOUT: %u.var: ref @F.%.loc13_22.2 (%.5) = var u +// CHECK:STDOUT: %u: ref @F.%.loc13_22.2 (%.5) = bind_name u, %u.var +// CHECK:STDOUT: %T.ref.loc14: type = name_ref T, %T [symbolic = %T.ref.loc13_11 (constants.%T)] +// CHECK:STDOUT: %.loc14: type = struct_type {.a: %T} [symbolic = %.loc14 (constants.%.8)] +// CHECK:STDOUT: %v.var: ref @F.%.loc14 (%.8) = var v +// CHECK:STDOUT: %v: ref @F.%.loc14 (%.8) = bind_name v, %v.var +// CHECK:STDOUT: %T.ref.loc15: type = name_ref T, %T [symbolic = %T.ref.loc13_11 (constants.%T)] // CHECK:STDOUT: %.loc15_14: i32 = int_literal 5 [template = constants.%.9] -// CHECK:STDOUT: %.loc15_15: type = array_type %.loc15_14, %T [symbolic = constants.%.10] -// CHECK:STDOUT: %w.var: ref %.10 = var w -// CHECK:STDOUT: %w: ref %.10 = bind_name w, %w.var +// CHECK:STDOUT: %.loc15_15: type = array_type %.loc15_14, %T [symbolic = %.loc15_15 (constants.%.10)] +// CHECK:STDOUT: %w.var: ref @F.%.loc15_15 (%.10) = var w +// CHECK:STDOUT: %w: ref @F.%.loc15_15 (%.10) = bind_name w, %w.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon index 8a1d80259f818..556853141cf63 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/fail_type_param_mismatch.carbon @@ -42,15 +42,15 @@ fn F(T:! type, U:! type) { // CHECK:STDOUT: fn @F(%T: type, %U: type) // CHECK:STDOUT: generic [%T: type, %U: type] { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = constants.%.2] -// CHECK:STDOUT: %p.var: ref %.2 = var p -// CHECK:STDOUT: %p: ref %.2 = bind_name p, %p.var -// CHECK:STDOUT: %U.ref: type = name_ref U, %U [symbolic = constants.%U] -// CHECK:STDOUT: %p.ref: ref %.2 = name_ref p, %p -// CHECK:STDOUT: %.loc16_15: %.2 = bind_value %p.ref -// CHECK:STDOUT: %.loc16_14: ref %T = deref %.loc16_15 -// CHECK:STDOUT: %n: %U = bind_name n, +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = %.loc12 (constants.%.2)] +// CHECK:STDOUT: %p.var: ref @F.%.loc12 (%.2) = var p +// CHECK:STDOUT: %p: ref @F.%.loc12 (%.2) = bind_name p, %p.var +// CHECK:STDOUT: %U.ref: type = name_ref U, %U [symbolic = %U.ref (constants.%U)] +// CHECK:STDOUT: %p.ref: ref @F.%.loc12 (%.2) = name_ref p, %p +// CHECK:STDOUT: %.loc16_15: @F.%.loc12 (%.2) = bind_value %p.ref +// CHECK:STDOUT: %.loc16_14: ref @F.%T.ref (%T) = deref %.loc16_15 +// CHECK:STDOUT: %n: @F.%U.ref (%U) = bind_name n, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon index c99b3f6d0b5b0..5b9a3c98ae3c7 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param.carbon @@ -36,16 +36,16 @@ fn F(T:! type) { // CHECK:STDOUT: fn @F(%T: type) // CHECK:STDOUT: generic [%T: type] { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = constants.%.2] -// CHECK:STDOUT: %p.var: ref %.2 = var p -// CHECK:STDOUT: %p: ref %.2 = bind_name p, %p.var -// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %p.ref: ref %.2 = name_ref p, %p -// CHECK:STDOUT: %.loc13_15: %.2 = bind_value %p.ref -// CHECK:STDOUT: %.loc13_14.1: ref %T = deref %.loc13_15 -// CHECK:STDOUT: %.loc13_14.2: %T = bind_value %.loc13_14.1 -// CHECK:STDOUT: %n: %T = bind_name n, %.loc13_14.2 +// CHECK:STDOUT: %T.ref.loc12: type = name_ref T, %T [symbolic = %T.ref.loc12 (constants.%T)] +// CHECK:STDOUT: %.loc12: type = ptr_type %T [symbolic = %.loc12 (constants.%.2)] +// CHECK:STDOUT: %p.var: ref @F.%.loc12 (%.2) = var p +// CHECK:STDOUT: %p: ref @F.%.loc12 (%.2) = bind_name p, %p.var +// CHECK:STDOUT: %T.ref.loc13: type = name_ref T, %T [symbolic = %T.ref.loc12 (constants.%T)] +// CHECK:STDOUT: %p.ref: ref @F.%.loc12 (%.2) = name_ref p, %p +// CHECK:STDOUT: %.loc13_15: @F.%.loc12 (%.2) = bind_value %p.ref +// CHECK:STDOUT: %.loc13_14.1: ref @F.%T.ref.loc12 (%T) = deref %.loc13_15 +// CHECK:STDOUT: %.loc13_14.2: @F.%T.ref.loc12 (%T) = bind_value %.loc13_14.1 +// CHECK:STDOUT: %n: @F.%T.ref.loc12 (%T) = bind_name n, %.loc13_14.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon index e266a9375c120..0c150fedf204b 100644 --- a/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon +++ b/toolchain/check/testdata/function/generic/no_prelude/type_param_scope.carbon @@ -40,10 +40,10 @@ fn F(T:! type, n: T) -> T { // CHECK:STDOUT: fn @F(%T: type, %n: @F.%T (%T)) -> %T // CHECK:STDOUT: generic [%T: type] { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %n.ref: %T = name_ref n, %n -// CHECK:STDOUT: %m: %T = bind_name m, %n.ref -// CHECK:STDOUT: %m.ref: %T = name_ref m, %m +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %n.ref: @F.%T.ref (%T) = name_ref n, %n +// CHECK:STDOUT: %m: @F.%T.ref (%T) = bind_name m, %n.ref +// CHECK:STDOUT: %m.ref: @F.%T.ref (%T) = name_ref m, %m // CHECK:STDOUT: return %m.ref // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/function/generic/redeclare.carbon b/toolchain/check/testdata/function/generic/redeclare.carbon index 67c079017ad97..9ee50b07c79ae 100644 --- a/toolchain/check/testdata/function/generic/redeclare.carbon +++ b/toolchain/check/testdata/function/generic/redeclare.carbon @@ -138,10 +138,10 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: generic [file.%T.loc4_6.2: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl.loc4 [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %F.call: init %.1 = call %F.ref(%T.ref) -// CHECK:STDOUT: %.loc7_14.1: %.1 = value_of_initializer %F.call -// CHECK:STDOUT: %.loc7_14.2: %.1 = converted %F.call, %.loc7_14.1 +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %F.call: init (%.1) = call %F.ref(%T.ref) +// CHECK:STDOUT: %.loc7_14.1: (%.1) = value_of_initializer %F.call +// CHECK:STDOUT: %.loc7_14.2: (%.1) = converted %F.call, %.loc7_14.1 // CHECK:STDOUT: return %.loc7_14.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -199,8 +199,8 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: generic [%T: type, %U: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %F.call: init (%.1) = call %F.ref() [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -268,7 +268,7 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: generic [%U: type, %T: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T.2] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T.ref (constants.%T.2)] // CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -337,7 +337,7 @@ fn F(U:! type, T:! type) -> U* { // CHECK:STDOUT: generic [%U: type, %T: type] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = constants.%T.2] +// CHECK:STDOUT: %T.ref: type = name_ref T, %T [symbolic = %T.ref (constants.%T.2)] // CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon b/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon index 9b087c625f798..871116c1c2e48 100644 --- a/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon +++ b/toolchain/check/testdata/impl/fail_extend_impl_forall.carbon @@ -58,7 +58,7 @@ class C { // CHECK:STDOUT: // CHECK:STDOUT: interface @GenericInterface // CHECK:STDOUT: generic [file.%T.loc11_28.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { // CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc11_28.2 [symbolic = %T.ref (constants.%T)] // CHECK:STDOUT: %x.loc12_8.1: @GenericInterface.%T.ref (%T) = param x diff --git a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon index 4019d8f821192..611758a229c5f 100644 --- a/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon +++ b/toolchain/check/testdata/interface/no_prelude/as_type_of_type.carbon @@ -49,11 +49,11 @@ fn F(T:! Empty) { // CHECK:STDOUT: fn @F(%T: %.1) // CHECK:STDOUT: generic [%T: %.1] { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T [symbolic = constants.%T] -// CHECK:STDOUT: %.loc14_10.1: type = facet_type_access %T.ref [symbolic = constants.%T] -// CHECK:STDOUT: %.loc14_10.2: type = converted %T.ref, %.loc14_10.1 [symbolic = constants.%T] -// CHECK:STDOUT: %x.var: ref %T = var x -// CHECK:STDOUT: %x: ref %T = bind_name x, %x.var +// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %.loc14_10.1: type = facet_type_access %T.ref [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %.loc14_10.2: type = converted %T.ref, %.loc14_10.1 [symbolic = %T.ref (constants.%T)] +// CHECK:STDOUT: %x.var: ref @F.%T.ref (%T) = var x +// CHECK:STDOUT: %x: ref @F.%T.ref (%T) = bind_name x, %x.var // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon b/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon index 0b4dc8bd8c36a..fd235bd656748 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_add_member_outside_definition.carbon @@ -81,7 +81,7 @@ interface Outer { // CHECK:STDOUT: // CHECK:STDOUT: interface @Inner // CHECK:STDOUT: generic [@Outer.%Self: %.3] { -// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = constants.%Self.3] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.3)] // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.5] {} // CHECK:STDOUT: // CHECK:STDOUT: !members: diff --git a/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon b/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon index 70a2494cb11ec..1c42430947331 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_generic_redeclaration.carbon @@ -92,7 +92,7 @@ interface DifferentParams(T:! ()) {} // CHECK:STDOUT: // CHECK:STDOUT: interface @.1 // CHECK:STDOUT: generic [file.%T.loc19_22.2: type] { -// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = constants.%Self.1] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.1)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self @@ -115,7 +115,7 @@ interface DifferentParams(T:! ()) {} // CHECK:STDOUT: // CHECK:STDOUT: interface @.3 // CHECK:STDOUT: generic [file.%T.loc38_27.2: %.2] { -// CHECK:STDOUT: %Self: %.7 = bind_symbolic_name Self 1 [symbolic = constants.%Self.3] +// CHECK:STDOUT: %Self: %.7 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.3)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self diff --git a/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon index 6a0f8ef9d842f..06e4b3d9b3e12 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_facet_lookup.carbon @@ -83,7 +83,7 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: fn @CallStatic(%T: %.1) // CHECK:STDOUT: generic [%T: %.1] { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T [symbolic = constants.%T] +// CHECK:STDOUT: %T.ref: %.1 = name_ref T, %T [symbolic = %T.ref (constants.%T)] // CHECK:STDOUT: %F.ref: %.3 = name_ref F, @Interface.%.loc11 [template = constants.%.4] // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon index c1513ebd6bab7..463f6a1cec3e1 100644 --- a/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon +++ b/toolchain/check/testdata/interface/no_prelude/fail_todo_generic_default_fn.carbon @@ -65,7 +65,7 @@ fn I(T:! type).F[self: Self]() -> Self { return self; } // CHECK:STDOUT: // CHECK:STDOUT: interface @I // CHECK:STDOUT: generic [file.%T.loc11_13.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { // CHECK:STDOUT: %.loc13_14.1: %.2 = specific_constant %Self, file.%I.decl(constants.%T) [symbolic = %.loc13_14.1 (constants.%Self)] // CHECK:STDOUT: %Self.ref.loc13_14: %.2 = name_ref Self, %.loc13_14.1 [symbolic = %.loc13_14.1 (constants.%Self)] diff --git a/toolchain/check/testdata/interface/no_prelude/generic.carbon b/toolchain/check/testdata/interface/no_prelude/generic.carbon index cf5154abd65a5..09e6e51ef7f56 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic.carbon @@ -145,7 +145,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: // CHECK:STDOUT: interface @Simple // CHECK:STDOUT: generic [file.%T.loc4_18.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self.1] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.1)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self @@ -154,7 +154,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: // CHECK:STDOUT: interface @WithAssocFn // CHECK:STDOUT: generic [file.%T.loc8_23.2: type] { -// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = constants.%Self.2] +// CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)] // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] { // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X] // CHECK:STDOUT: %return.var: ref %X = var @@ -232,7 +232,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: generic [%T: %.7] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Receive.ref: %Receive.type = name_ref Receive, file.%Receive.decl [template = constants.%Receive] -// CHECK:STDOUT: %T.ref: %.7 = name_ref T, %T [symbolic = constants.%T.2] +// CHECK:STDOUT: %T.ref: %.7 = name_ref T, %T [symbolic = %T.ref (constants.%T.2)] // CHECK:STDOUT: %Receive.call: init %.1 = call %Receive.ref(%T.ref) // CHECK:STDOUT: return // CHECK:STDOUT: } @@ -335,7 +335,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: // CHECK:STDOUT: interface @Generic // CHECK:STDOUT: generic [file.%T.loc4_19.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self @@ -359,7 +359,7 @@ fn G(T:! Generic(B)) { // CHECK:STDOUT: generic [%T: %.5] { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F] -// CHECK:STDOUT: %T.ref: %.5 = name_ref T, %T [symbolic = constants.%T.3] +// CHECK:STDOUT: %T.ref: %.5 = name_ref T, %T [symbolic = %T.ref (constants.%T.3)] // CHECK:STDOUT: %F.call: init %.1 = call %F.ref() [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/interface/no_prelude/generic_import.carbon b/toolchain/check/testdata/interface/no_prelude/generic_import.carbon index e993bfd00f589..c6ec7ee5bd390 100644 --- a/toolchain/check/testdata/interface/no_prelude/generic_import.carbon +++ b/toolchain/check/testdata/interface/no_prelude/generic_import.carbon @@ -54,7 +54,7 @@ impl C as AddWith(C) { // CHECK:STDOUT: // CHECK:STDOUT: interface @AddWith // CHECK:STDOUT: generic [file.%T.loc4_19.2: type] { -// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} // CHECK:STDOUT: %.loc5: %.3 = assoc_entity element0, %F.decl [template = constants.%.4] // CHECK:STDOUT: diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index 75c6dd8acec05..a630f10411e01 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -956,13 +956,11 @@ class Formatter { const auto& symbolic_constant = sem_ir_.constant_values().GetSymbolicConstant(id); if (symbolic_constant.generic_id.is_valid()) { - CARBON_CHECK(symbolic_constant.index.region() == - GenericInstIndex::Region::Declaration) - << "TODO: implement formatting of definition constants"; const auto& generic = sem_ir_.generics().Get(symbolic_constant.generic_id); - FormatInstName(sem_ir_.inst_blocks().Get( - generic.decl_block_id)[symbolic_constant.index.index()]); + FormatInstName(sem_ir_.inst_blocks().Get(generic.GetEvalBlock( + symbolic_constant.index + .region()))[symbolic_constant.index.index()]); out_ << " ("; FormatInstName(sem_ir_.constant_values().GetInstId(id)); out_ << ")";