diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index 7fef1804defe0..520693feb002b 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -509,12 +509,12 @@ static auto PerformAggregateAccess(EvalContext& eval_context, SemIR::Inst inst) -> SemIR::ConstantId { auto access_inst = inst.As(); Phase phase = Phase::Template; - if (auto aggregate_id = - GetConstantValue(eval_context, access_inst.aggregate_id, &phase); - aggregate_id.is_valid()) { + if (ReplaceFieldWithConstantValue(eval_context, &access_inst, + &SemIR::AnyAggregateAccess::aggregate_id, + &phase)) { if (auto aggregate = eval_context.insts().TryGetAs( - aggregate_id)) { + access_inst.aggregate_id)) { auto elements = eval_context.inst_blocks().Get(aggregate->elements_id); auto index = static_cast(access_inst.index.index); CARBON_CHECK(index < elements.size(), "Access out of bounds."); @@ -526,6 +526,7 @@ static auto PerformAggregateAccess(EvalContext& eval_context, SemIR::Inst inst) CARBON_CHECK(phase != Phase::Template, "Failed to evaluate template constant {0}", inst); } + return MakeConstantResult(eval_context.context(), access_inst, phase); } return MakeNonConstantResult(phase); } diff --git a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon index 2cdaebdf22bf6..a48499d37ef30 100644 --- a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon +++ b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon @@ -26,6 +26,7 @@ impl bool as I where .T = bool {} // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template] // CHECK:STDOUT: %.Self: %I.type.1 = bind_symbolic_name .Self, 0 [symbolic] // CHECK:STDOUT: %.3: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %.4: type = interface_witness_access %.3, element0 [symbolic] // CHECK:STDOUT: %I.type.2: type = facet_type <@I where TODO> [template] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -53,7 +54,7 @@ impl bool as I where .T = bool {} // CHECK:STDOUT: %.Self.ref: %I.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %T.ref: %.1 = name_ref T, @I.%.loc11 [template = constants.%.2] // CHECK:STDOUT: %.loc16_22.1: = facet_access_witness %.Self.ref [symbolic = constants.%.3] -// CHECK:STDOUT: %.loc16_22.2: type = interface_witness_access %.loc16_22.1, element0 +// CHECK:STDOUT: %.loc16_22.2: type = interface_witness_access %.loc16_22.1, element0 [symbolic = constants.%.4] // CHECK:STDOUT: %bool.make_type.loc16_27: init type = call constants.%Bool() [template = bool] // CHECK:STDOUT: %.loc16_27.1: type = value_of_initializer %bool.make_type.loc16_27 [template = bool] // CHECK:STDOUT: %.loc16_27.2: type = converted %bool.make_type.loc16_27, %.loc16_27.1 [template = bool] 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 c2f3be18300c1..b65c8745e96b6 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 @@ -39,7 +39,8 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: %CallStatic.type: type = fn_type @CallStatic [template] // CHECK:STDOUT: %CallStatic: %CallStatic.type = struct_value () [template] // CHECK:STDOUT: %.3: = facet_access_witness %T [symbolic] -// CHECK:STDOUT: %.4: type = facet_access_type %T [symbolic] +// CHECK:STDOUT: %.4: %F.type = interface_witness_access %.3, element0 [symbolic] +// CHECK:STDOUT: %.5: type = facet_access_type %T [symbolic] // CHECK:STDOUT: %CallFacet.type: type = fn_type @CallFacet [template] // CHECK:STDOUT: %CallFacet: %CallFacet.type = struct_value () [template] // CHECK:STDOUT: } @@ -62,17 +63,17 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: %CallFacet.decl: %CallFacet.type = fn_decl @CallFacet [template = constants.%CallFacet] { // CHECK:STDOUT: %T.patt.loc21_14.1: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)] // CHECK:STDOUT: %T.param_patt: %Interface.type = value_param_pattern %T.patt.loc21_14.1, runtime_param [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)] -// CHECK:STDOUT: %x.patt: @CallFacet.%.loc21_32.3 (%.4) = binding_pattern x -// CHECK:STDOUT: %x.param_patt: @CallFacet.%.loc21_32.3 (%.4) = value_param_pattern %x.patt, runtime_param0 +// CHECK:STDOUT: %x.patt: @CallFacet.%.loc21_32.3 (%.5) = binding_pattern x +// CHECK:STDOUT: %x.param_patt: @CallFacet.%.loc21_32.3 (%.5) = value_param_pattern %x.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type] // CHECK:STDOUT: %T.ref: %Interface.type = name_ref T, %T.loc21_14.1 [symbolic = %T.loc21_14.2 (constants.%T)] -// CHECK:STDOUT: %.loc21_32.1: type = facet_access_type %T.ref [symbolic = %.loc21_32.3 (constants.%.4)] -// CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %.loc21_32.1 [symbolic = %.loc21_32.3 (constants.%.4)] +// CHECK:STDOUT: %.loc21_32.1: type = facet_access_type %T.ref [symbolic = %.loc21_32.3 (constants.%.5)] +// CHECK:STDOUT: %.loc21_32.2: type = converted %T.ref, %.loc21_32.1 [symbolic = %.loc21_32.3 (constants.%.5)] // CHECK:STDOUT: %T.param: %Interface.type = value_param runtime_param // CHECK:STDOUT: %T.loc21_14.1: %Interface.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc21_14.2 (constants.%T)] -// CHECK:STDOUT: %x.param: @CallFacet.%.loc21_32.3 (%.4) = value_param runtime_param0 -// CHECK:STDOUT: %x: @CallFacet.%.loc21_32.3 (%.4) = bind_name x, %x.param +// CHECK:STDOUT: %x.param: @CallFacet.%.loc21_32.3 (%.5) = value_param runtime_param0 +// CHECK:STDOUT: %x: @CallFacet.%.loc21_32.3 (%.5) = bind_name x, %x.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -98,13 +99,14 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %.loc18_4.3: = facet_access_witness %T.loc13_15.2 [symbolic = %.loc18_4.3 (constants.%.3)] +// CHECK:STDOUT: %.loc18_4.4: %F.type = interface_witness_access %.loc18_4.3, element0 [symbolic = %.loc18_4.4 (constants.%.4)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.param_patt: %Interface.type) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %T.ref: %Interface.type = name_ref T, %T.loc13_15.1 [symbolic = %T.loc13_15.2 (constants.%T)] // CHECK:STDOUT: %F.ref: %.1 = name_ref F, @Interface.%.loc11 [template = constants.%.2] // CHECK:STDOUT: %.loc18_4.1: = facet_access_witness %T.ref [symbolic = %.loc18_4.3 (constants.%.3)] -// CHECK:STDOUT: %.loc18_4.2: %F.type = interface_witness_access %.loc18_4.1, element0 +// CHECK:STDOUT: %.loc18_4.2: %F.type = interface_witness_access %.loc18_4.1, element0 [symbolic = %.loc18_4.4 (constants.%.4)] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -112,13 +114,13 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: generic fn @CallFacet(%T.loc21_14.1: %Interface.type) { // CHECK:STDOUT: %T.loc21_14.2: %Interface.type = bind_symbolic_name T, 0 [symbolic = %T.loc21_14.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc21_14.2: %Interface.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt)] -// CHECK:STDOUT: %.loc21_32.3: type = facet_access_type %T.loc21_14.2 [symbolic = %.loc21_32.3 (constants.%.4)] +// CHECK:STDOUT: %.loc21_32.3: type = facet_access_type %T.loc21_14.2 [symbolic = %.loc21_32.3 (constants.%.5)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: -// CHECK:STDOUT: fn(%T.param_patt: %Interface.type, %x.param_patt: @CallFacet.%.loc21_32.3 (%.4)) { +// CHECK:STDOUT: fn(%T.param_patt: %Interface.type, %x.param_patt: @CallFacet.%.loc21_32.3 (%.5)) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %x.ref: @CallFacet.%.loc21_32.3 (%.4) = name_ref x, %x +// CHECK:STDOUT: %x.ref: @CallFacet.%.loc21_32.3 (%.5) = name_ref x, %x // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -133,6 +135,6 @@ fn CallFacet(T:! Interface, x: T) { // CHECK:STDOUT: specific @CallFacet(constants.%T) { // CHECK:STDOUT: %T.loc21_14.2 => constants.%T // CHECK:STDOUT: %T.patt.loc21_14.2 => constants.%T -// CHECK:STDOUT: %.loc21_32.3 => constants.%.4 +// CHECK:STDOUT: %.loc21_32.3 => constants.%.5 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/let/compile_time_bindings.carbon b/toolchain/check/testdata/let/compile_time_bindings.carbon index 3cd9e3f45a5b7..2bbe443443d8b 100644 --- a/toolchain/check/testdata/let/compile_time_bindings.carbon +++ b/toolchain/check/testdata/let/compile_time_bindings.carbon @@ -296,7 +296,10 @@ impl i32 as Empty { // CHECK:STDOUT: %tuple.type.3: type = tuple_type (%empty_tuple.type, %empty_tuple.type) [template] // CHECK:STDOUT: %tuple.2: %tuple.type.3 = tuple_value (%empty_tuple, %empty_tuple) [template] // CHECK:STDOUT: %c: %tuple.type.3 = bind_symbolic_name c, 1 [symbolic] +// CHECK:STDOUT: %.5: %empty_tuple.type = tuple_access %b, element0 [symbolic] // CHECK:STDOUT: %tuple.3: %tuple.type.1 = tuple_value (%empty_tuple) [template] +// CHECK:STDOUT: %.6: %empty_tuple.type = tuple_access %c, element0 [symbolic] +// CHECK:STDOUT: %.7: %empty_tuple.type = tuple_access %c, element1 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -369,6 +372,9 @@ impl i32 as Empty { // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %c.loc11_9.2: %tuple.type.3 = bind_symbolic_name c, 1 [symbolic = %c.loc11_9.2 (constants.%c)] +// CHECK:STDOUT: %.loc14_21.6: %empty_tuple.type = tuple_access %b.loc10_8.1, element0 [symbolic = %.loc14_21.6 (constants.%.5)] +// CHECK:STDOUT: %.loc15_24.10: %empty_tuple.type = tuple_access %c.loc11_9.2, element0 [symbolic = %.loc15_24.10 (constants.%.6)] +// CHECK:STDOUT: %.loc15_24.11: %empty_tuple.type = tuple_access %c.loc11_9.2, element1 [symbolic = %.loc15_24.11 (constants.%.7)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%b.param_patt: %tuple.type.1) { // CHECK:STDOUT: !entry: @@ -403,7 +409,7 @@ impl i32 as Empty { // CHECK:STDOUT: %b1.var: ref %tuple.type.1 = var b1 // CHECK:STDOUT: %b1: ref %tuple.type.1 = bind_name b1, %b1.var // CHECK:STDOUT: %b.ref: %tuple.type.1 = name_ref b, %b.loc10_8.2 [symbolic = %b.loc10_8.1 (constants.%b)] -// CHECK:STDOUT: %.loc14_21.1: %empty_tuple.type = tuple_access %b.ref, element0 +// CHECK:STDOUT: %.loc14_21.1: %empty_tuple.type = tuple_access %b.ref, element0 [symbolic = %.loc14_21.6 (constants.%.5)] // CHECK:STDOUT: %.loc14_21.2: ref %empty_tuple.type = tuple_access %b1.var, element0 // CHECK:STDOUT: %.loc14_21.3: init %empty_tuple.type = tuple_init () to %.loc14_21.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc14_21.4: init %empty_tuple.type = converted %.loc14_21.1, %.loc14_21.3 [template = constants.%empty_tuple] @@ -419,11 +425,11 @@ impl i32 as Empty { // CHECK:STDOUT: %c1.var: ref %tuple.type.3 = var c1 // CHECK:STDOUT: %c1: ref %tuple.type.3 = bind_name c1, %c1.var // CHECK:STDOUT: %c.ref: %tuple.type.3 = name_ref c, %c.loc11_9.1 [symbolic = %c.loc11_9.2 (constants.%c)] -// CHECK:STDOUT: %.loc15_24.1: %empty_tuple.type = tuple_access %c.ref, element0 +// CHECK:STDOUT: %.loc15_24.1: %empty_tuple.type = tuple_access %c.ref, element0 [symbolic = %.loc15_24.10 (constants.%.6)] // CHECK:STDOUT: %.loc15_24.2: ref %empty_tuple.type = tuple_access %c1.var, element0 // CHECK:STDOUT: %.loc15_24.3: init %empty_tuple.type = tuple_init () to %.loc15_24.2 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc15_24.4: init %empty_tuple.type = converted %.loc15_24.1, %.loc15_24.3 [template = constants.%empty_tuple] -// CHECK:STDOUT: %.loc15_24.5: %empty_tuple.type = tuple_access %c.ref, element1 +// CHECK:STDOUT: %.loc15_24.5: %empty_tuple.type = tuple_access %c.ref, element1 [symbolic = %.loc15_24.11 (constants.%.7)] // CHECK:STDOUT: %.loc15_24.6: ref %empty_tuple.type = tuple_access %c1.var, element1 // CHECK:STDOUT: %.loc15_24.7: init %empty_tuple.type = tuple_init () to %.loc15_24.6 [template = constants.%empty_tuple] // CHECK:STDOUT: %.loc15_24.8: init %empty_tuple.type = converted %.loc15_24.5, %.loc15_24.7 [template = constants.%empty_tuple] diff --git a/toolchain/check/testdata/where_expr/constraints.carbon b/toolchain/check/testdata/where_expr/constraints.carbon index d6f43c4f73d8f..7c120c1bb48a4 100644 --- a/toolchain/check/testdata/where_expr/constraints.carbon +++ b/toolchain/check/testdata/where_expr/constraints.carbon @@ -35,7 +35,7 @@ interface N { fn Equal(T:! N where .P = {}); -// --- fail_todo_associated_type_impls.carbon +// --- associated_type_impls.carbon library "[[@TEST_NAME]]"; @@ -46,10 +46,6 @@ interface K { let Associated:! L; } -// CHECK:STDERR: fail_todo_associated_type_impls.carbon:[[@LINE+4]]:36: error: cannot evaluate type expression [TypeExprEvaluationFailure] -// CHECK:STDERR: fn AssociatedTypeImpls(W:! K where .Associated impls M); -// CHECK:STDERR: ^~~~~~~~~~~ -// CHECK:STDERR: fn AssociatedTypeImpls(W:! K where .Associated impls M); // --- fail_check_rewrite_constraints.carbon @@ -190,6 +186,7 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %Impls: %Impls.type = struct_value () [template] // CHECK:STDOUT: %.6: type = facet_access_type %.Self.1 [symbolic] // CHECK:STDOUT: %.7: = facet_access_witness %.Self.1 [symbolic] +// CHECK:STDOUT: %.8: type = interface_witness_access %.7, element0 [symbolic] // CHECK:STDOUT: %I.type.3: type = facet_type <@I where TODO> [template] // CHECK:STDOUT: %W: %I.type.3 = bind_symbolic_name W, 0 [symbolic] // CHECK:STDOUT: %W.patt: %I.type.3 = symbolic_binding_pattern W, 0 [symbolic] @@ -259,7 +256,7 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.Self.ref.loc15_38: %I.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self.1] // CHECK:STDOUT: %Member.ref: %.1 = name_ref Member, @I.%.loc7 [template = constants.%.2] // CHECK:STDOUT: %.loc15_38.1: = facet_access_witness %.Self.ref.loc15_38 [symbolic = constants.%.7] -// CHECK:STDOUT: %.loc15_38.2: type = interface_witness_access %.loc15_38.1, element0 +// CHECK:STDOUT: %.loc15_38.2: type = interface_witness_access %.loc15_38.1, element0 [symbolic = constants.%.8] // CHECK:STDOUT: %.loc15_50: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc15_14: type = where_expr %.Self [template = constants.%I.type.3] { // CHECK:STDOUT: requirement_impls %.loc15_20.2, %J.ref @@ -338,7 +335,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @N.%P [template] // CHECK:STDOUT: %.Self: %N.type.1 = bind_symbolic_name .Self, 0 [symbolic] // CHECK:STDOUT: %.3: = facet_access_witness %.Self [symbolic] -// CHECK:STDOUT: %.4: type = struct_type {} [template] +// CHECK:STDOUT: %.4: type = interface_witness_access %.3, element0 [symbolic] +// CHECK:STDOUT: %.5: type = struct_type {} [template] // CHECK:STDOUT: %N.type.2: type = facet_type <@N where TODO> [template] // CHECK:STDOUT: %T: %N.type.2 = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %T.patt: %N.type.2 = symbolic_binding_pattern T, 0 [symbolic] @@ -370,9 +368,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.Self.ref: %N.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %P.ref: %.1 = name_ref P, @N.%.loc5 [template = constants.%.2] // CHECK:STDOUT: %.loc8_22.1: = facet_access_witness %.Self.ref [symbolic = constants.%.3] -// CHECK:STDOUT: %.loc8_22.2: type = interface_witness_access %.loc8_22.1, element0 -// CHECK:STDOUT: %.loc8_28.1: %.4 = struct_literal () -// CHECK:STDOUT: %.loc8_28.2: type = converted %.loc8_28.1, constants.%.4 [template = constants.%.4] +// CHECK:STDOUT: %.loc8_22.2: type = interface_witness_access %.loc8_22.1, element0 [symbolic = constants.%.4] +// CHECK:STDOUT: %.loc8_28.1: %.5 = struct_literal () +// CHECK:STDOUT: %.loc8_28.2: type = converted %.loc8_28.1, constants.%.5 [template = constants.%.5] // CHECK:STDOUT: %.loc8_16: type = where_expr %.Self [template = constants.%N.type.2] { // CHECK:STDOUT: requirement_rewrite %.loc8_22.2, %.loc8_28.2 // CHECK:STDOUT: } @@ -404,7 +402,7 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %T.patt.loc8_10.2 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_associated_type_impls.carbon +// CHECK:STDOUT: --- associated_type_impls.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %L.type: type = facet_type <@L> [template] @@ -417,6 +415,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @K.%Associated [template] // CHECK:STDOUT: %.Self: %K.type.1 = bind_symbolic_name .Self, 0 [symbolic] // CHECK:STDOUT: %.3: = facet_access_witness %.Self [symbolic] +// CHECK:STDOUT: %.4: %L.type = interface_witness_access %.3, element0 [symbolic] +// CHECK:STDOUT: %.5: type = facet_access_type %.4 [symbolic] // CHECK:STDOUT: %K.type.2: type = facet_type <@K where TODO> [template] // CHECK:STDOUT: %W: %K.type.2 = bind_symbolic_name W, 0 [symbolic] // CHECK:STDOUT: %W.patt: %K.type.2 = symbolic_binding_pattern W, 0 [symbolic] @@ -444,23 +444,23 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %M.decl: type = interface_decl @M [template = constants.%M.type] {} {} // CHECK:STDOUT: %K.decl: type = interface_decl @K [template = constants.%K.type.1] {} {} // CHECK:STDOUT: %AssociatedTypeImpls.decl: %AssociatedTypeImpls.type = fn_decl @AssociatedTypeImpls [template = constants.%AssociatedTypeImpls] { -// CHECK:STDOUT: %W.patt.loc15_24.1: %K.type.2 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc15_24.2 (constants.%W.patt)] -// CHECK:STDOUT: %W.param_patt: %K.type.2 = value_param_pattern %W.patt.loc15_24.1, runtime_param [symbolic = %W.patt.loc15_24.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.patt.loc11_24.1: %K.type.2 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc11_24.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.param_patt: %K.type.2 = value_param_pattern %W.patt.loc11_24.1, runtime_param [symbolic = %W.patt.loc11_24.2 (constants.%W.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [template = constants.%K.type.1] // CHECK:STDOUT: %.Self: %K.type.1 = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.Self.ref: %K.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %Associated.ref: %.1 = name_ref Associated, @K.%.loc8 [template = constants.%.2] -// CHECK:STDOUT: %.loc15_36.1: = facet_access_witness %.Self.ref [symbolic = constants.%.3] -// CHECK:STDOUT: %.loc15_36.2: %L.type = interface_witness_access %.loc15_36.1, element0 +// CHECK:STDOUT: %.loc11_36.1: = facet_access_witness %.Self.ref [symbolic = constants.%.3] +// CHECK:STDOUT: %.loc11_36.2: %L.type = interface_witness_access %.loc11_36.1, element0 [symbolic = constants.%.4] // CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [template = constants.%M.type] -// CHECK:STDOUT: %.loc15_36.3: type = facet_access_type %.loc15_36.2 -// CHECK:STDOUT: %.loc15_36.4: type = converted %.loc15_36.2, %.loc15_36.3 -// CHECK:STDOUT: %.loc15_30: type = where_expr %.Self [template = constants.%K.type.2] { -// CHECK:STDOUT: requirement_impls , %M.ref +// CHECK:STDOUT: %.loc11_36.3: type = facet_access_type %.loc11_36.2 [symbolic = constants.%.5] +// CHECK:STDOUT: %.loc11_36.4: type = converted %.loc11_36.2, %.loc11_36.3 [symbolic = constants.%.5] +// CHECK:STDOUT: %.loc11_30: type = where_expr %.Self [template = constants.%K.type.2] { +// CHECK:STDOUT: requirement_impls %.loc11_36.4, %M.ref // CHECK:STDOUT: } // CHECK:STDOUT: %W.param: %K.type.2 = value_param runtime_param -// CHECK:STDOUT: %W.loc15_24.1: %K.type.2 = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc15_24.2 (constants.%W)] +// CHECK:STDOUT: %W.loc11_24.1: %K.type.2 = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc11_24.2 (constants.%W)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -492,16 +492,16 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: witness = (%Associated) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @AssociatedTypeImpls(%W.loc15_24.1: %K.type.2) { -// CHECK:STDOUT: %W.loc15_24.2: %K.type.2 = bind_symbolic_name W, 0 [symbolic = %W.loc15_24.2 (constants.%W)] -// CHECK:STDOUT: %W.patt.loc15_24.2: %K.type.2 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc15_24.2 (constants.%W.patt)] +// CHECK:STDOUT: generic fn @AssociatedTypeImpls(%W.loc11_24.1: %K.type.2) { +// CHECK:STDOUT: %W.loc11_24.2: %K.type.2 = bind_symbolic_name W, 0 [symbolic = %W.loc11_24.2 (constants.%W)] +// CHECK:STDOUT: %W.patt.loc11_24.2: %K.type.2 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc11_24.2 (constants.%W.patt)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%W.param_patt: %K.type.2); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @AssociatedTypeImpls(constants.%W) { -// CHECK:STDOUT: %W.loc15_24.2 => constants.%W -// CHECK:STDOUT: %W.patt.loc15_24.2 => constants.%W +// CHECK:STDOUT: %W.loc11_24.2 => constants.%W +// CHECK:STDOUT: %W.patt.loc11_24.2 => constants.%W // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_check_rewrite_constraints.carbon @@ -512,7 +512,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.1: type = assoc_entity_type %I.type.1, type [template] // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, imports.%import_ref.11 [template] // CHECK:STDOUT: %.3: = facet_access_witness %.Self [symbolic] -// CHECK:STDOUT: %.4: Core.IntLiteral = int_value 2 [template] +// CHECK:STDOUT: %.4: type = interface_witness_access %.3, element0 [symbolic] +// CHECK:STDOUT: %.5: Core.IntLiteral = int_value 2 [template] // CHECK:STDOUT: %I.type.2: type = facet_type <@I where TODO> [template] // CHECK:STDOUT: %X: %I.type.2 = bind_symbolic_name X, 0 [symbolic] // CHECK:STDOUT: %X.patt: %I.type.2 = symbolic_binding_pattern X, 0 [symbolic] @@ -525,7 +526,7 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %import_ref.2: type = import_ref Main//state_constraints, inst+7, loaded [template = constants.%I.type.1] // CHECK:STDOUT: %import_ref.3 = import_ref Main//state_constraints, inst+35, unloaded // CHECK:STDOUT: %import_ref.4 = import_ref Main//state_constraints, inst+57, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+85, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+86, unloaded // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .ImplicitAs = %import_ref.12 // CHECK:STDOUT: import Core//prelude @@ -559,8 +560,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.Self.ref: %I.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %Member.ref: %.1 = name_ref Member, imports.%import_ref.7 [template = constants.%.2] // CHECK:STDOUT: %.loc14_36.1: = facet_access_witness %.Self.ref [symbolic = constants.%.3] -// CHECK:STDOUT: %.loc14_36.2: type = interface_witness_access %.loc14_36.1, element0 -// CHECK:STDOUT: %.loc14_46.1: Core.IntLiteral = int_value 2 [template = constants.%.4] +// CHECK:STDOUT: %.loc14_36.2: type = interface_witness_access %.loc14_36.1, element0 [symbolic = constants.%.4] +// CHECK:STDOUT: %.loc14_46.1: Core.IntLiteral = int_value 2 [template = constants.%.5] // CHECK:STDOUT: %.loc14_46.2: type = converted %.loc14_46.1, [template = ] // CHECK:STDOUT: %.loc14_30: type = where_expr %.Self [template = constants.%I.type.2] { // CHECK:STDOUT: requirement_rewrite %.loc14_36.2, @@ -785,7 +786,7 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %import_ref.2 = import_ref Main//state_constraints, inst+7, unloaded // CHECK:STDOUT: %import_ref.3 = import_ref Main//state_constraints, inst+35, unloaded // CHECK:STDOUT: %import_ref.4: %Impls.type = import_ref Main//state_constraints, inst+57, loaded [template = constants.%Impls] -// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+85, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+86, unloaded // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .ImplicitAs = %import_ref.7 // CHECK:STDOUT: import Core//prelude diff --git a/toolchain/check/testdata/where_expr/designator.carbon b/toolchain/check/testdata/where_expr/designator.carbon index da3c7ea84c37b..b4dd57fb4c79f 100644 --- a/toolchain/check/testdata/where_expr/designator.carbon +++ b/toolchain/check/testdata/where_expr/designator.carbon @@ -101,6 +101,7 @@ class D { // CHECK:STDOUT: %PeriodSelf.type: type = fn_type @PeriodSelf [template] // CHECK:STDOUT: %PeriodSelf: %PeriodSelf.type = struct_value () [template] // CHECK:STDOUT: %.3: = facet_access_witness %.Self.1 [symbolic] +// CHECK:STDOUT: %.4: type = interface_witness_access %.3, element0 [symbolic] // CHECK:STDOUT: %I.type.3: type = facet_type <@I where TODO> [template] // CHECK:STDOUT: %U: %I.type.3 = bind_symbolic_name U, 0 [symbolic] // CHECK:STDOUT: %U.patt: %I.type.3 = symbolic_binding_pattern U, 0 [symbolic] @@ -154,7 +155,7 @@ class D { // CHECK:STDOUT: %.Self.ref: %I.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self.1] // CHECK:STDOUT: %Member.ref: %.1 = name_ref Member, @I.%.loc5 [template = constants.%.2] // CHECK:STDOUT: %.loc10_29.1: = facet_access_witness %.Self.ref [symbolic = constants.%.3] -// CHECK:STDOUT: %.loc10_29.2: type = interface_witness_access %.loc10_29.1, element0 +// CHECK:STDOUT: %.loc10_29.2: type = interface_witness_access %.loc10_29.1, element0 [symbolic = constants.%.4] // CHECK:STDOUT: %.loc10_41: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc10_23: type = where_expr %.Self [template = constants.%I.type.3] { // CHECK:STDOUT: requirement_equivalent %.loc10_29.2, %.loc10_41 diff --git a/toolchain/check/testdata/where_expr/non_generic.carbon b/toolchain/check/testdata/where_expr/non_generic.carbon index ffacf28ff334c..421885f053077 100644 --- a/toolchain/check/testdata/where_expr/non_generic.carbon +++ b/toolchain/check/testdata/where_expr/non_generic.carbon @@ -22,10 +22,11 @@ fn NotGenericF(U: I where .T == i32) {} // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @I.%T [template] // CHECK:STDOUT: %.Self: %I.type.1 = bind_symbolic_name .Self, 0 [symbolic] // CHECK:STDOUT: %.3: = facet_access_witness %.Self [symbolic] -// CHECK:STDOUT: %.4: Core.IntLiteral = int_value 32 [template] +// CHECK:STDOUT: %.4: type = interface_witness_access %.3, element0 [symbolic] +// CHECK:STDOUT: %.5: Core.IntLiteral = int_value 32 [template] // CHECK:STDOUT: %Int.type: type = fn_type @Int [template] // CHECK:STDOUT: %Int: %Int.type = struct_value () [template] -// CHECK:STDOUT: %i32: type = int_type signed, %.4 [template] +// CHECK:STDOUT: %i32: type = int_type signed, %.5 [template] // CHECK:STDOUT: %I.type.2: type = facet_type <@I where TODO> [template] // CHECK:STDOUT: %NotGenericF.type: type = fn_type @NotGenericF [template] // CHECK:STDOUT: %NotGenericF: %NotGenericF.type = struct_value () [template] @@ -56,8 +57,8 @@ fn NotGenericF(U: I where .T == i32) {} // CHECK:STDOUT: %.Self.ref: %I.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %T.ref: %.1 = name_ref T, @I.%.loc11 [template = constants.%.2] // CHECK:STDOUT: %.loc14_27.1: = facet_access_witness %.Self.ref [symbolic = constants.%.3] -// CHECK:STDOUT: %.loc14_27.2: type = interface_witness_access %.loc14_27.1, element0 -// CHECK:STDOUT: %.loc14_33: Core.IntLiteral = int_value 32 [template = constants.%.4] +// CHECK:STDOUT: %.loc14_27.2: type = interface_witness_access %.loc14_27.1, element0 [symbolic = constants.%.4] +// CHECK:STDOUT: %.loc14_33: Core.IntLiteral = int_value 32 [template = constants.%.5] // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc14_33) [template = constants.%i32] // CHECK:STDOUT: %.loc14_21: type = where_expr %.Self [template = constants.%I.type.2] { // CHECK:STDOUT: requirement_equivalent %.loc14_27.2, %int.make_type_signed diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index c0816f771464f..937c7d39e55eb 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -480,7 +480,8 @@ struct ClassElementAccess { // TODO: Make Parse::NodeId more specific. static constexpr auto Kind = InstKind::ClassElementAccess.Define( - {.ir_name = "class_element_access"}); + {.ir_name = "class_element_access", + .constant_kind = InstConstantKind::SymbolicOnly}); TypeId type_id; InstId base_id; @@ -1221,7 +1222,8 @@ struct StringType { struct StructAccess { // TODO: Make Parse::NodeId more specific. static constexpr auto Kind = InstKind::StructAccess.Define( - {.ir_name = "struct_access"}); + {.ir_name = "struct_access", + .constant_kind = InstConstantKind::SymbolicOnly}); TypeId type_id; InstId struct_id; @@ -1296,8 +1298,9 @@ struct TemporaryStorage { // for assignment. struct TupleAccess { // TODO: Make Parse::NodeId more specific. - static constexpr auto Kind = - InstKind::TupleAccess.Define({.ir_name = "tuple_access"}); + static constexpr auto Kind = InstKind::TupleAccess.Define( + {.ir_name = "tuple_access", + .constant_kind = InstConstantKind::SymbolicOnly}); TypeId type_id; InstId tuple_id;