From ea0b0b4b48bf1236fe427a39dfd141fd39ab2389 Mon Sep 17 00:00:00 2001 From: josh11b <15258583+josh11b@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:43:55 -0800 Subject: [PATCH] Add facet type values and an instruction that produces them (#4460) Still to do: * Represent facet type values in a canonical form * Produce & consume facet type values instead of interface values * `type` should be associated with a canonical facet type value * Support `&` on facet type values * Type check and enforce requirements in facet types --------- Co-authored-by: Josh L --- toolchain/check/context.cpp | 4 +- toolchain/check/eval.cpp | 47 +- toolchain/check/handle_where.cpp | 2 + .../impl/fail_todo_impl_assoc_const.carbon | 5 +- .../testdata/where_expr/constraints.carbon | 470 +++++++++++------- .../testdata/where_expr/designator.carbon | 92 ++-- .../testdata/where_expr/non_generic.carbon | 13 +- toolchain/lower/file_context.cpp | 2 +- toolchain/sem_ir/BUILD | 1 + toolchain/sem_ir/facet_type_info.h | 32 ++ toolchain/sem_ir/file.cpp | 1 + toolchain/sem_ir/file.h | 10 + toolchain/sem_ir/formatter.cpp | 11 + toolchain/sem_ir/id_kind.h | 8 +- toolchain/sem_ir/ids.h | 19 +- toolchain/sem_ir/inst_kind.def | 1 + toolchain/sem_ir/stringify_type.cpp | 15 + toolchain/sem_ir/typed_insts.h | 11 + 18 files changed, 493 insertions(+), 251 deletions(-) create mode 100644 toolchain/sem_ir/facet_type_info.h diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index 061b445bd87f8..1161e2d5ad163 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -1060,8 +1060,8 @@ class TypeCompleter { template requires( InstT::Kind - .template IsAnyOf()) auto BuildValueReprForInst(SemIR::TypeId /*type_id*/, InstT /*inst*/) const diff --git a/toolchain/check/eval.cpp b/toolchain/check/eval.cpp index f314ab2d4c5e9..c7a70861b25a0 100644 --- a/toolchain/check/eval.cpp +++ b/toolchain/check/eval.cpp @@ -126,6 +126,9 @@ class EvalContext { auto interfaces() -> const ValueStore& { return sem_ir().interfaces(); } + auto facet_types() -> CanonicalValueStore& { + return sem_ir().facet_types(); + } auto specifics() -> const SemIR::SpecificStore& { return sem_ir().specifics(); } @@ -1106,6 +1109,20 @@ static auto MakeConstantForCall(EvalContext& eval_context, SemIRLoc loc, return SemIR::ConstantId::NotConstant; } +// Creates a FacetType constant. +static auto MakeFacetTypeResult(Context& context, + SemIR::TypeId base_facet_type_id, + SemIR::InstBlockId requirement_block_id, + Phase phase) -> SemIR::ConstantId { + SemIR::FacetTypeId facet_type_id = context.sem_ir().facet_types().Add( + SemIR::FacetTypeInfo{.base_facet_type_id = base_facet_type_id, + .requirement_block_id = requirement_block_id}); + return MakeConstantResult(context, + SemIR::FacetType{.type_id = SemIR::TypeId::TypeType, + .facet_type_id = facet_type_id}, + phase); +} + // Implementation for `TryEvalInst`, wrapping `Context` with `EvalContext`. static auto TryEvalInstInContext(EvalContext& eval_context, SemIR::InstId inst_id, SemIR::Inst inst) @@ -1287,6 +1304,23 @@ static auto TryEvalInstInContext(EvalContext& eval_context, Phase::Template); } + case CARBON_KIND(SemIR::FacetType facet_type): { + SemIR::FacetTypeInfo info = + eval_context.facet_types().Get(facet_type.facet_type_id); + Phase phase = Phase::Template; + SemIR::TypeId base_facet_type_id = + GetConstantValue(eval_context, info.base_facet_type_id, &phase); + // TODO: process & canonicalize requirements + SemIR::InstBlockId requirement_block_id = info.requirement_block_id; + // If nothing changed, can reuse this instruction. + if (base_facet_type_id == info.base_facet_type_id && + requirement_block_id == info.requirement_block_id) { + return MakeConstantResult(eval_context.context(), inst, phase); + } + return MakeFacetTypeResult(eval_context.context(), base_facet_type_id, + requirement_block_id, phase); + } + case CARBON_KIND(SemIR::InterfaceDecl interface_decl): { // If the interface has generic parameters, we don't produce an interface // type, but a callable whose return value is an interface type. @@ -1445,10 +1479,15 @@ static auto TryEvalInstInContext(EvalContext& eval_context, return eval_context.GetConstantValue(typed_inst.facet_id); } case CARBON_KIND(SemIR::WhereExpr typed_inst): { - // TODO: This currently ignores the requirements and just produces the - // left-hand type argument to the `where`. - return eval_context.GetConstantValue( - eval_context.insts().Get(typed_inst.period_self_id).type_id()); + SemIR::TypeId base_facet_type_id = + eval_context.insts().Get(typed_inst.period_self_id).type_id(); + Phase phase = Phase::Template; + base_facet_type_id = + GetConstantValue(eval_context, base_facet_type_id, &phase); + SemIR::InstBlockId requirement_block_id = typed_inst.requirements_id; + // TODO: process & canonicalize requirements + return MakeFacetTypeResult(eval_context.context(), base_facet_type_id, + requirement_block_id, phase); } // `not true` -> `false`, `not false` -> `true`. diff --git a/toolchain/check/handle_where.cpp b/toolchain/check/handle_where.cpp index e5e852b05a693..f2968fdb3d832 100644 --- a/toolchain/check/handle_where.cpp +++ b/toolchain/check/handle_where.cpp @@ -79,6 +79,7 @@ auto HandleParseNode(Context& context, Parse::RequirementEqualEqualId node_id) auto rhs = context.node_stack().PopExpr(); auto lhs = context.node_stack().PopExpr(); // TODO: type check lhs and rhs are comparable + // TODO: require that at least one side uses a designator // Build up the list of arguments for the `WhereExpr` inst. context.args_type_info_stack().AddInstId( @@ -103,6 +104,7 @@ auto HandleParseNode(Context& context, Parse::RequirementImplsId node_id) context.emitter().Emit(rhs_node, ImplsOnNonFacetType); rhs_as_type.inst_id = SemIR::InstId::BuiltinError; } + // TODO: require that at least one side uses a designator // Build up the list of arguments for the `WhereExpr` inst. context.args_type_info_stack().AddInstId( 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 16500f933e8be..7d8d604a24d3a 100644 --- a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon +++ b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon @@ -10,7 +10,7 @@ interface I { let T:! type; } -// CHECK:STDERR: fail_todo_impl_assoc_const.carbon:[[@LINE+10]]:1: error: semantics TODO: `impl of interface with associated constant` [SemanticsTodo] +// CHECK:STDERR: fail_todo_impl_assoc_const.carbon:[[@LINE+10]]:1: error: semantics TODO: `impl as non-interface` [SemanticsTodo] // CHECK:STDERR: impl bool as I where .T = bool {} // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: @@ -50,6 +50,7 @@ impl bool as I where .T = bool {} // CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [template] // CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.7 [symbolic] +// CHECK:STDOUT: %.9: type = facet_type [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -90,7 +91,7 @@ impl bool as I where .T = bool {} // CHECK:STDOUT: %.loc23_27.2: ref type = temporary_storage // CHECK:STDOUT: %.loc23_27.3: ref type = temporary %.loc23_27.2, %bool.make_type.loc23_27 // CHECK:STDOUT: %.loc23_27.4: %.1 = converted %bool.make_type.loc23_27, [template = ] -// CHECK:STDOUT: %.loc23_16: type = where_expr %.Self [template = constants.%I.type] { +// CHECK:STDOUT: %.loc23_16: type = where_expr %.Self [template = constants.%.9] { // CHECK:STDOUT: requirement_rewrite %T.ref, // CHECK:STDOUT: } // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/where_expr/constraints.carbon b/toolchain/check/testdata/where_expr/constraints.carbon index 1dbaac83161c6..9e81dc69d5c97 100644 --- a/toolchain/check/testdata/where_expr/constraints.carbon +++ b/toolchain/check/testdata/where_expr/constraints.carbon @@ -120,6 +120,9 @@ fn ImplsOfNonFacetType(U:! type where .Self impls i32); library "[[@TEST_NAME]]"; +// CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE+3]]:1: in import [InImport] +// CHECK:STDERR: state_constraints.carbon: error: semantics TODO: `TryResolveInst on FacetType` [SemanticsTodo] +// CHECK:STDERR: import library "state_constraints"; // C implements J but not I. @@ -128,17 +131,6 @@ impl C as J {} // TODO: Should report that `C` does not meet the constraint. fn DoesNotImplI() { - // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE+11]]:3: error: cannot implicitly convert from `type` to `J` [ImplicitAsConversionFailure] - // CHECK:STDERR: Impls(C); - // CHECK:STDERR: ^~~~~~ - // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE+8]]:3: note: type `type` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] - // CHECK:STDERR: Impls(C); - // CHECK:STDERR: ^~~~~~ - // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE-14]]:1: in import [InImport] - // CHECK:STDERR: state_constraints.carbon:13:1: note: while deducing parameters of generic declared here [DeductionGenericHere] - // CHECK:STDERR: fn Impls(V:! J where .Self impls I); - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // CHECK:STDERR: Impls(C); } @@ -146,19 +138,20 @@ fn EmptyStruct(Y:! J where .Self == {}); // TODO: Should report that `C` does not meeet the constraint. fn NotEmptyStruct() { - // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE+9]]:3: error: cannot implicitly convert from `type` to `J` [ImplicitAsConversionFailure] + // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE+10]]:3: error: cannot implicitly convert from `type` to `` [ImplicitAsConversionFailure] // CHECK:STDERR: EmptyStruct(C); // CHECK:STDERR: ^~~~~~~~~~~~ - // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE+6]]:3: note: type `type` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] + // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE+7]]:3: note: type `type` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] // CHECK:STDERR: EmptyStruct(C); // CHECK:STDERR: ^~~~~~~~~~~~ // CHECK:STDERR: fail_todo_enforce_constraint.carbon:[[@LINE-10]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: fn EmptyStruct(Y:! J where .Self == {}); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: EmptyStruct(C); } -// --- let.carbon +// --- fail_todo_let.carbon library "[[@TEST_NAME]]"; @@ -166,6 +159,12 @@ interface A {} class D {} impl D as A {} // TODO: This should be a compile-time binding, once that is supported. +// CHECK:STDERR: fail_todo_let.carbon:[[@LINE+6]]:1: error: cannot implicitly convert from `type` to `` [ImplicitAsConversionFailure] +// CHECK:STDERR: let B: type where .Self impls A = D; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fail_todo_let.carbon:[[@LINE+3]]:1: note: type `type` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] +// CHECK:STDERR: let B: type where .Self impls A = D; +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ let B: type where .Self impls A = D; // CHECK:STDOUT: --- state_constraints.carbon @@ -181,17 +180,20 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.4: type = assoc_entity_type %I.type, %J.type [template] // CHECK:STDOUT: %.5: %.4 = assoc_entity element1, @I.%Second [template] // CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self, 0 [symbolic] -// CHECK:STDOUT: %U: %I.type = bind_symbolic_name U, 0 [symbolic] -// CHECK:STDOUT: %U.patt: %I.type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %.6: type = facet_type [template] +// CHECK:STDOUT: %U: %.6 = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: %.6 = symbolic_binding_pattern U, 0 [symbolic] // CHECK:STDOUT: %EqualEqual.type: type = fn_type @EqualEqual [template] // CHECK:STDOUT: %EqualEqual: %EqualEqual.type = struct_value () [template] // CHECK:STDOUT: %.Self.2: %J.type = bind_symbolic_name .Self, 0 [symbolic] -// CHECK:STDOUT: %V: %J.type = bind_symbolic_name V, 0 [symbolic] -// CHECK:STDOUT: %V.patt: %J.type = symbolic_binding_pattern V, 0 [symbolic] +// CHECK:STDOUT: %.7: type = facet_type [template] +// CHECK:STDOUT: %V: %.7 = bind_symbolic_name V, 0 [symbolic] +// CHECK:STDOUT: %V.patt: %.7 = symbolic_binding_pattern V, 0 [symbolic] // CHECK:STDOUT: %Impls.type: type = fn_type @Impls [template] // CHECK:STDOUT: %Impls: %Impls.type = struct_value () [template] -// CHECK:STDOUT: %W: %I.type = bind_symbolic_name W, 0 [symbolic] -// CHECK:STDOUT: %W.patt: %I.type = symbolic_binding_pattern W, 0 [symbolic] +// CHECK:STDOUT: %.8: type = facet_type [template] +// CHECK:STDOUT: %W: %.8 = bind_symbolic_name W, 0 [symbolic] +// CHECK:STDOUT: %W.patt: %.8 = symbolic_binding_pattern W, 0 [symbolic] // CHECK:STDOUT: %And.type: type = fn_type @And [template] // CHECK:STDOUT: %And: %And.type = struct_value () [template] // CHECK:STDOUT: } @@ -216,22 +218,22 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {} // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {} // CHECK:STDOUT: %EqualEqual.decl: %EqualEqual.type = fn_decl @EqualEqual [template = constants.%EqualEqual] { -// CHECK:STDOUT: %U.patt.loc11_15.1: %I.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_15.2 (constants.%U.patt)] -// CHECK:STDOUT: %U.param_patt: %I.type = value_param_pattern %U.patt.loc11_15.1, runtime_param [symbolic = %U.patt.loc11_15.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.patt.loc11_15.1: %.6 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_15.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.param_patt: %.6 = value_param_pattern %U.patt.loc11_15.1, runtime_param [symbolic = %U.patt.loc11_15.2 (constants.%U.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self.1] // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self.1] // CHECK:STDOUT: %.loc11_37: %.3 = tuple_literal () -// CHECK:STDOUT: %.loc11_21: type = where_expr %.Self [template = constants.%I.type] { +// CHECK:STDOUT: %.loc11_21: type = where_expr %.Self [template = constants.%.6] { // CHECK:STDOUT: requirement_equivalent %.Self.ref, %.loc11_37 // CHECK:STDOUT: } -// CHECK:STDOUT: %U.param: %I.type = value_param runtime_param -// CHECK:STDOUT: %U.loc11_15.1: %I.type = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc11_15.2 (constants.%U)] +// CHECK:STDOUT: %U.param: %.6 = value_param runtime_param +// CHECK:STDOUT: %U.loc11_15.1: %.6 = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc11_15.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: %Impls.decl: %Impls.type = fn_decl @Impls [template = constants.%Impls] { -// CHECK:STDOUT: %V.patt.loc13_10.1: %J.type = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc13_10.2 (constants.%V.patt)] -// CHECK:STDOUT: %V.param_patt: %J.type = value_param_pattern %V.patt.loc13_10.1, runtime_param [symbolic = %V.patt.loc13_10.2 (constants.%V.patt)] +// CHECK:STDOUT: %V.patt.loc13_10.1: %.7 = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc13_10.2 (constants.%V.patt)] +// CHECK:STDOUT: %V.param_patt: %.7 = value_param_pattern %V.patt.loc13_10.1, runtime_param [symbolic = %V.patt.loc13_10.2 (constants.%V.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type] // CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self.2] @@ -239,15 +241,15 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: %.loc13_22.1: type = facet_type_access %.Self.ref [symbolic = constants.%.Self.2] // CHECK:STDOUT: %.loc13_22.2: type = converted %.Self.ref, %.loc13_22.1 [symbolic = constants.%.Self.2] -// CHECK:STDOUT: %.loc13_16: type = where_expr %.Self [template = constants.%J.type] { +// CHECK:STDOUT: %.loc13_16: type = where_expr %.Self [template = constants.%.7] { // CHECK:STDOUT: requirement_impls %.loc13_22.2, %I.ref // CHECK:STDOUT: } -// CHECK:STDOUT: %V.param: %J.type = value_param runtime_param -// CHECK:STDOUT: %V.loc13_10.1: %J.type = bind_symbolic_name V, 0, %V.param [symbolic = %V.loc13_10.2 (constants.%V)] +// CHECK:STDOUT: %V.param: %.7 = value_param runtime_param +// CHECK:STDOUT: %V.loc13_10.1: %.7 = bind_symbolic_name V, 0, %V.param [symbolic = %V.loc13_10.2 (constants.%V)] // CHECK:STDOUT: } // CHECK:STDOUT: %And.decl: %And.type = fn_decl @And [template = constants.%And] { -// CHECK:STDOUT: %W.patt.loc15_8.1: %I.type = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc15_8.2 (constants.%W.patt)] -// CHECK:STDOUT: %W.param_patt: %I.type = value_param_pattern %W.patt.loc15_8.1, runtime_param [symbolic = %W.patt.loc15_8.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.patt.loc15_8.1: %.8 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc15_8.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.param_patt: %.8 = value_param_pattern %W.patt.loc15_8.1, runtime_param [symbolic = %W.patt.loc15_8.2 (constants.%W.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self.1] @@ -258,12 +260,12 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.Self.ref.loc15_38: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self.1] // CHECK:STDOUT: %Member.ref: %.1 = name_ref Member, @I.%.loc7 [template = constants.%.2] // CHECK:STDOUT: %.loc15_50: %.3 = tuple_literal () -// CHECK:STDOUT: %.loc15_14: type = where_expr %.Self [template = constants.%I.type] { +// CHECK:STDOUT: %.loc15_14: type = where_expr %.Self [template = constants.%.8] { // CHECK:STDOUT: requirement_impls %.loc15_20.2, %J.ref // CHECK:STDOUT: requirement_equivalent %Member.ref, %.loc15_50 // CHECK:STDOUT: } -// CHECK:STDOUT: %W.param: %I.type = value_param runtime_param -// CHECK:STDOUT: %W.loc15_8.1: %I.type = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc15_8.2 (constants.%W)] +// CHECK:STDOUT: %W.param: %.8 = value_param runtime_param +// CHECK:STDOUT: %W.loc15_8.1: %.8 = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc15_8.2 (constants.%W)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -290,25 +292,25 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: witness = (%Member, %Second) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @EqualEqual(%U.loc11_15.1: %I.type) { -// CHECK:STDOUT: %U.loc11_15.2: %I.type = bind_symbolic_name U, 0 [symbolic = %U.loc11_15.2 (constants.%U)] -// CHECK:STDOUT: %U.patt.loc11_15.2: %I.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_15.2 (constants.%U.patt)] +// CHECK:STDOUT: generic fn @EqualEqual(%U.loc11_15.1: %.6) { +// CHECK:STDOUT: %U.loc11_15.2: %.6 = bind_symbolic_name U, 0 [symbolic = %U.loc11_15.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc11_15.2: %.6 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_15.2 (constants.%U.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%U.param_patt: %I.type); +// CHECK:STDOUT: fn(%U.param_patt: %.6); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @Impls(%V.loc13_10.1: %J.type) { -// CHECK:STDOUT: %V.loc13_10.2: %J.type = bind_symbolic_name V, 0 [symbolic = %V.loc13_10.2 (constants.%V)] -// CHECK:STDOUT: %V.patt.loc13_10.2: %J.type = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc13_10.2 (constants.%V.patt)] +// CHECK:STDOUT: generic fn @Impls(%V.loc13_10.1: %.7) { +// CHECK:STDOUT: %V.loc13_10.2: %.7 = bind_symbolic_name V, 0 [symbolic = %V.loc13_10.2 (constants.%V)] +// CHECK:STDOUT: %V.patt.loc13_10.2: %.7 = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc13_10.2 (constants.%V.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%V.param_patt: %J.type); +// CHECK:STDOUT: fn(%V.param_patt: %.7); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @And(%W.loc15_8.1: %I.type) { -// CHECK:STDOUT: %W.loc15_8.2: %I.type = bind_symbolic_name W, 0 [symbolic = %W.loc15_8.2 (constants.%W)] -// CHECK:STDOUT: %W.patt.loc15_8.2: %I.type = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc15_8.2 (constants.%W.patt)] +// CHECK:STDOUT: generic fn @And(%W.loc15_8.1: %.8) { +// CHECK:STDOUT: %W.loc15_8.2: %.8 = bind_symbolic_name W, 0 [symbolic = %W.loc15_8.2 (constants.%W)] +// CHECK:STDOUT: %W.patt.loc15_8.2: %.8 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc15_8.2 (constants.%W.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%W.param_patt: %I.type); +// CHECK:STDOUT: fn(%W.param_patt: %.8); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @EqualEqual(constants.%U) { @@ -354,8 +356,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.8: %.7 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: %.9: %.5 = assoc_entity element0, imports.%import_ref.6 [symbolic] // CHECK:STDOUT: %struct: %.4 = struct_value () [template] -// CHECK:STDOUT: %T: %N.type = bind_symbolic_name T, 0 [symbolic] -// CHECK:STDOUT: %T.patt: %N.type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %.10: type = facet_type [template] +// CHECK:STDOUT: %T: %.10 = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: %.10 = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %Equal.type: type = fn_type @Equal [template] // CHECK:STDOUT: %Equal: %Equal.type = struct_value () [template] // CHECK:STDOUT: } @@ -383,8 +386,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %N.decl: type = interface_decl @N [template = constants.%N.type] {} {} // CHECK:STDOUT: %Equal.decl: %Equal.type = fn_decl @Equal [template = constants.%Equal] { -// CHECK:STDOUT: %T.patt.loc15_10.1: %N.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc15_10.2 (constants.%T.patt)] -// CHECK:STDOUT: %T.param_patt: %N.type = value_param_pattern %T.patt.loc15_10.1, runtime_param [symbolic = %T.patt.loc15_10.2 (constants.%T.patt)] +// CHECK:STDOUT: %T.patt.loc15_10.1: %.10 = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc15_10.2 (constants.%T.patt)] +// CHECK:STDOUT: %T.param_patt: %.10 = value_param_pattern %T.patt.loc15_10.1, runtime_param [symbolic = %T.patt.loc15_10.2 (constants.%T.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %N.ref: type = name_ref N, file.%N.decl [template = constants.%N.type] // CHECK:STDOUT: %.Self: %N.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] @@ -397,11 +400,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %struct: %.4 = struct_value () [template = constants.%struct] // CHECK:STDOUT: %.loc15_28.3: %.4 = converted %.loc15_28.1, %struct [template = constants.%struct] // CHECK:STDOUT: %.loc15_28.4: %.1 = converted %.loc15_28.1, [template = ] -// CHECK:STDOUT: %.loc15_16: type = where_expr %.Self [template = constants.%N.type] { +// CHECK:STDOUT: %.loc15_16: type = where_expr %.Self [template = constants.%.10] { // CHECK:STDOUT: requirement_rewrite %P.ref, // CHECK:STDOUT: } -// CHECK:STDOUT: %T.param: %N.type = value_param runtime_param -// CHECK:STDOUT: %T.loc15_10.1: %N.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc15_10.2 (constants.%T)] +// CHECK:STDOUT: %T.param: %.10 = value_param runtime_param +// CHECK:STDOUT: %T.loc15_10.1: %.10 = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc15_10.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -444,11 +447,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @Equal(%T.loc15_10.1: %N.type) { -// CHECK:STDOUT: %T.loc15_10.2: %N.type = bind_symbolic_name T, 0 [symbolic = %T.loc15_10.2 (constants.%T)] -// CHECK:STDOUT: %T.patt.loc15_10.2: %N.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc15_10.2 (constants.%T.patt)] +// CHECK:STDOUT: generic fn @Equal(%T.loc15_10.1: %.10) { +// CHECK:STDOUT: %T.loc15_10.2: %.10 = bind_symbolic_name T, 0 [symbolic = %T.loc15_10.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc15_10.2: %.10 = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc15_10.2 (constants.%T.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%T.param_patt: %N.type); +// CHECK:STDOUT: fn(%T.param_patt: %.10); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { @@ -520,8 +523,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic] -// CHECK:STDOUT: %W: %K.type = bind_symbolic_name W, 0 [symbolic] -// CHECK:STDOUT: %W.patt: %K.type = symbolic_binding_pattern W, 0 [symbolic] +// CHECK:STDOUT: %.9: type = facet_type [template] +// CHECK:STDOUT: %W: %.9 = bind_symbolic_name W, 0 [symbolic] +// CHECK:STDOUT: %W.patt: %.9 = symbolic_binding_pattern W, 0 [symbolic] // CHECK:STDOUT: %AssociatedTypeImpls.type: type = fn_type @AssociatedTypeImpls [template] // CHECK:STDOUT: %AssociatedTypeImpls: %AssociatedTypeImpls.type = struct_value () [template] // CHECK:STDOUT: } @@ -553,8 +557,8 @@ 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] {} {} // CHECK:STDOUT: %AssociatedTypeImpls.decl: %AssociatedTypeImpls.type = fn_decl @AssociatedTypeImpls [template = constants.%AssociatedTypeImpls] { -// CHECK:STDOUT: %W.patt.loc18_24.1: %K.type = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc18_24.2 (constants.%W.patt)] -// CHECK:STDOUT: %W.param_patt: %K.type = value_param_pattern %W.patt.loc18_24.1, runtime_param [symbolic = %W.patt.loc18_24.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.patt.loc18_24.1: %.9 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc18_24.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.param_patt: %.9 = value_param_pattern %W.patt.loc18_24.1, runtime_param [symbolic = %W.patt.loc18_24.2 (constants.%W.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [template = constants.%K.type] // CHECK:STDOUT: %.Self: %K.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] @@ -565,11 +569,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.loc18_36.1: %.6 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.7] // CHECK:STDOUT: %Convert.ref: %.6 = name_ref Convert, %.loc18_36.1 [template = constants.%.7] // CHECK:STDOUT: %.loc18_36.2: type = converted %Associated.ref, [template = ] -// CHECK:STDOUT: %.loc18_30: type = where_expr %.Self [template = constants.%K.type] { +// CHECK:STDOUT: %.loc18_30: type = where_expr %.Self [template = constants.%.9] { // CHECK:STDOUT: requirement_impls , %M.ref // CHECK:STDOUT: } -// CHECK:STDOUT: %W.param: %K.type = value_param runtime_param -// CHECK:STDOUT: %W.loc18_24.1: %K.type = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc18_24.2 (constants.%W)] +// CHECK:STDOUT: %W.param: %.9 = value_param runtime_param +// CHECK:STDOUT: %W.loc18_24.1: %.9 = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc18_24.2 (constants.%W)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -629,11 +633,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.5)]() -> @Convert.%Dest (%Dest); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @AssociatedTypeImpls(%W.loc18_24.1: %K.type) { -// CHECK:STDOUT: %W.loc18_24.2: %K.type = bind_symbolic_name W, 0 [symbolic = %W.loc18_24.2 (constants.%W)] -// CHECK:STDOUT: %W.patt.loc18_24.2: %K.type = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc18_24.2 (constants.%W.patt)] +// CHECK:STDOUT: generic fn @AssociatedTypeImpls(%W.loc18_24.1: %.9) { +// CHECK:STDOUT: %W.loc18_24.2: %.9 = bind_symbolic_name W, 0 [symbolic = %W.loc18_24.2 (constants.%W)] +// CHECK:STDOUT: %W.patt.loc18_24.2: %.9 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc18_24.2 (constants.%W.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%W.param_patt: %K.type); +// CHECK:STDOUT: fn(%W.param_patt: %.9); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { @@ -702,8 +706,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.7: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.8: %.7 = assoc_entity element0, imports.%import_ref.16 [template] // CHECK:STDOUT: %.9: %.5 = assoc_entity element0, imports.%import_ref.17 [symbolic] -// CHECK:STDOUT: %X: %I.type = bind_symbolic_name X, 0 [symbolic] -// CHECK:STDOUT: %X.patt: %I.type = symbolic_binding_pattern X, 0 [symbolic] +// CHECK:STDOUT: %.10: type = facet_type [template] +// CHECK:STDOUT: %X: %.10 = bind_symbolic_name X, 0 [symbolic] +// CHECK:STDOUT: %X.patt: %.10 = symbolic_binding_pattern X, 0 [symbolic] // CHECK:STDOUT: %RewriteTypeMismatch.type: type = fn_type @RewriteTypeMismatch [template] // CHECK:STDOUT: %RewriteTypeMismatch: %RewriteTypeMismatch.type = struct_value () [template] // CHECK:STDOUT: } @@ -711,9 +716,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref.1 = import_ref Main//state_constraints, inst+3, unloaded // CHECK:STDOUT: %import_ref.2: type = import_ref Main//state_constraints, inst+7, loaded [template = constants.%I.type] -// CHECK:STDOUT: %import_ref.3 = import_ref Main//state_constraints, inst+34, unloaded -// CHECK:STDOUT: %import_ref.4 = import_ref Main//state_constraints, inst+54, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+77, unloaded +// CHECK:STDOUT: %import_ref.3 = import_ref Main//state_constraints, inst+35, unloaded +// CHECK:STDOUT: %import_ref.4 = import_ref Main//state_constraints, inst+56, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+80, unloaded // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .ImplicitAs = %import_ref.12 // CHECK:STDOUT: import Core//prelude @@ -746,8 +751,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %RewriteTypeMismatch.decl: %RewriteTypeMismatch.type = fn_decl @RewriteTypeMismatch [template = constants.%RewriteTypeMismatch] { -// CHECK:STDOUT: %X.patt.loc16_24.1: %I.type = symbolic_binding_pattern X, 0 [symbolic = %X.patt.loc16_24.2 (constants.%X.patt)] -// CHECK:STDOUT: %X.param_patt: %I.type = value_param_pattern %X.patt.loc16_24.1, runtime_param [symbolic = %X.patt.loc16_24.2 (constants.%X.patt)] +// CHECK:STDOUT: %X.patt.loc16_24.1: %.10 = symbolic_binding_pattern X, 0 [symbolic = %X.patt.loc16_24.2 (constants.%X.patt)] +// CHECK:STDOUT: %X.param_patt: %.10 = value_param_pattern %X.patt.loc16_24.1, runtime_param [symbolic = %X.patt.loc16_24.2 (constants.%X.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%import_ref.2 [template = constants.%I.type] // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] @@ -758,11 +763,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.loc16_46.2: %.7 = specific_constant imports.%import_ref.14, @ImplicitAs(constants.%.2) [template = constants.%.8] // CHECK:STDOUT: %Convert.ref: %.7 = name_ref Convert, %.loc16_46.2 [template = constants.%.8] // CHECK:STDOUT: %.loc16_46.3: %.2 = converted %.loc16_46.1, [template = ] -// CHECK:STDOUT: %.loc16_30: type = where_expr %.Self [template = constants.%I.type] { +// CHECK:STDOUT: %.loc16_30: type = where_expr %.Self [template = constants.%.10] { // CHECK:STDOUT: requirement_rewrite %Member.ref, // CHECK:STDOUT: } -// CHECK:STDOUT: %X.param: %I.type = value_param runtime_param -// CHECK:STDOUT: %X.loc16_24.1: %I.type = bind_symbolic_name X, 0, %X.param [symbolic = %X.loc16_24.2 (constants.%X)] +// CHECK:STDOUT: %X.param: %.10 = value_param runtime_param +// CHECK:STDOUT: %X.loc16_24.1: %.10 = bind_symbolic_name X, 0, %X.param [symbolic = %X.loc16_24.2 (constants.%X)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -802,11 +807,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @RewriteTypeMismatch(%X.loc16_24.1: %I.type) { -// CHECK:STDOUT: %X.loc16_24.2: %I.type = bind_symbolic_name X, 0 [symbolic = %X.loc16_24.2 (constants.%X)] -// CHECK:STDOUT: %X.patt.loc16_24.2: %I.type = symbolic_binding_pattern X, 0 [symbolic = %X.patt.loc16_24.2 (constants.%X.patt)] +// CHECK:STDOUT: generic fn @RewriteTypeMismatch(%X.loc16_24.1: %.10) { +// CHECK:STDOUT: %X.loc16_24.2: %.10 = bind_symbolic_name X, 0 [symbolic = %X.loc16_24.2 (constants.%X)] +// CHECK:STDOUT: %X.patt.loc16_24.2: %.10 = symbolic_binding_pattern X, 0 [symbolic = %X.patt.loc16_24.2 (constants.%X.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%X.param_patt: %I.type); +// CHECK:STDOUT: fn(%X.param_patt: %.10); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { @@ -871,8 +876,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: %.7: %.3 = assoc_entity element0, imports.%import_ref.6 [symbolic] -// CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic] -// CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %.8: type = facet_type [template] +// CHECK:STDOUT: %U: %.8 = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: %.8 = symbolic_binding_pattern U, 0 [symbolic] // CHECK:STDOUT: %NonTypeImpls.type: type = fn_type @NonTypeImpls [template] // CHECK:STDOUT: %NonTypeImpls: %NonTypeImpls.type = struct_value () [template] // CHECK:STDOUT: } @@ -898,8 +904,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %NonTypeImpls.decl: %NonTypeImpls.type = fn_decl @NonTypeImpls [template = constants.%NonTypeImpls] { -// CHECK:STDOUT: %U.patt.loc11_17.1: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] -// CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc11_17.1, runtime_param [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.patt.loc11_17.1: %.8 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.param_patt: %.8 = value_param_pattern %U.patt.loc11_17.1, runtime_param [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.loc11_32.1: i32 = int_value 7 [template = constants.%.1] @@ -907,11 +913,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.loc11_32.2: %.5 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.6] // CHECK:STDOUT: %Convert.ref: %.5 = name_ref Convert, %.loc11_32.2 [template = constants.%.6] // CHECK:STDOUT: %.loc11_32.3: type = converted %.loc11_32.1, [template = ] -// CHECK:STDOUT: %.loc11_26: type = where_expr %.Self [template = type] { +// CHECK:STDOUT: %.loc11_26: type = where_expr %.Self [template = constants.%.8] { // CHECK:STDOUT: requirement_impls , type // CHECK:STDOUT: } -// CHECK:STDOUT: %U.param: type = value_param runtime_param -// CHECK:STDOUT: %U.loc11_17.1: type = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc11_17.2 (constants.%U)] +// CHECK:STDOUT: %U.param: %.8 = value_param runtime_param +// CHECK:STDOUT: %U.loc11_17.1: %.8 = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc11_17.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -943,11 +949,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @NonTypeImpls(%U.loc11_17.1: type) { -// CHECK:STDOUT: %U.loc11_17.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc11_17.2 (constants.%U)] -// CHECK:STDOUT: %U.patt.loc11_17.2: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] +// CHECK:STDOUT: generic fn @NonTypeImpls(%U.loc11_17.1: %.8) { +// CHECK:STDOUT: %U.loc11_17.2: %.8 = bind_symbolic_name U, 0 [symbolic = %U.loc11_17.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc11_17.2: %.8 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%U.param_patt: type); +// CHECK:STDOUT: fn(%U.param_patt: %.8); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { @@ -1012,8 +1018,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: %.7: %.3 = assoc_entity element0, imports.%import_ref.6 [symbolic] -// CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic] -// CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %.8: type = facet_type [template] +// CHECK:STDOUT: %U: %.8 = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: %.8 = symbolic_binding_pattern U, 0 [symbolic] // CHECK:STDOUT: %ImplsNonType.type: type = fn_type @ImplsNonType [template] // CHECK:STDOUT: %ImplsNonType: %ImplsNonType.type = struct_value () [template] // CHECK:STDOUT: } @@ -1039,8 +1046,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %ImplsNonType.decl: %ImplsNonType.type = fn_decl @ImplsNonType [template = constants.%ImplsNonType] { -// CHECK:STDOUT: %U.patt.loc11_17.1: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] -// CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc11_17.1, runtime_param [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.patt.loc11_17.1: %.8 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.param_patt: %.8 = value_param_pattern %U.patt.loc11_17.1, runtime_param [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic = constants.%.Self] @@ -1049,11 +1056,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.loc11_44.2: %.5 = specific_constant imports.%import_ref.3, @ImplicitAs(type) [template = constants.%.6] // CHECK:STDOUT: %Convert.ref: %.5 = name_ref Convert, %.loc11_44.2 [template = constants.%.6] // CHECK:STDOUT: %.loc11_44.3: type = converted %.loc11_44.1, [template = ] -// CHECK:STDOUT: %.loc11_26: type = where_expr %.Self [template = type] { +// CHECK:STDOUT: %.loc11_26: type = where_expr %.Self [template = constants.%.8] { // CHECK:STDOUT: requirement_impls %.Self.ref, // CHECK:STDOUT: } -// CHECK:STDOUT: %U.param: type = value_param runtime_param -// CHECK:STDOUT: %U.loc11_17.1: type = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc11_17.2 (constants.%U)] +// CHECK:STDOUT: %U.param: %.8 = value_param runtime_param +// CHECK:STDOUT: %U.loc11_17.1: %.8 = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc11_17.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -1085,11 +1092,11 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @ImplsNonType(%U.loc11_17.1: type) { -// CHECK:STDOUT: %U.loc11_17.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc11_17.2 (constants.%U)] -// CHECK:STDOUT: %U.patt.loc11_17.2: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] +// CHECK:STDOUT: generic fn @ImplsNonType(%U.loc11_17.1: %.8) { +// CHECK:STDOUT: %U.loc11_17.2: %.8 = bind_symbolic_name U, 0 [symbolic = %U.loc11_17.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc11_17.2: %.8 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc11_17.2 (constants.%U.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%U.param_patt: type); +// CHECK:STDOUT: fn(%U.param_patt: %.8); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { @@ -1138,8 +1145,9 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] -// CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic] -// CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %.2: type = facet_type [template] +// CHECK:STDOUT: %U: %.2 = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: %.2 = symbolic_binding_pattern U, 0 [symbolic] // CHECK:STDOUT: %ImplsOfNonFacetType.type: type = fn_type @ImplsOfNonFacetType [template] // CHECK:STDOUT: %ImplsOfNonFacetType: %ImplsOfNonFacetType.type = struct_value () [template] // CHECK:STDOUT: } @@ -1160,29 +1168,29 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %ImplsOfNonFacetType.decl: %ImplsOfNonFacetType.type = fn_decl @ImplsOfNonFacetType [template = constants.%ImplsOfNonFacetType] { -// CHECK:STDOUT: %U.patt.loc8_24.1: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_24.2 (constants.%U.patt)] -// CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc8_24.1, runtime_param [symbolic = %U.patt.loc8_24.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.patt.loc8_24.1: %.2 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_24.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.param_patt: %.2 = value_param_pattern %U.patt.loc8_24.1, runtime_param [symbolic = %U.patt.loc8_24.2 (constants.%U.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_51.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc8_51.2: type = converted %int.make_type_32, %.loc8_51.1 [template = i32] -// CHECK:STDOUT: %.loc8_33: type = where_expr %.Self [template = type] { +// CHECK:STDOUT: %.loc8_33: type = where_expr %.Self [template = constants.%.2] { // CHECK:STDOUT: requirement_impls %.Self.ref, // CHECK:STDOUT: } -// CHECK:STDOUT: %U.param: type = value_param runtime_param -// CHECK:STDOUT: %U.loc8_24.1: type = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc8_24.2 (constants.%U)] +// CHECK:STDOUT: %U.param: %.2 = value_param runtime_param +// CHECK:STDOUT: %U.loc8_24.1: %.2 = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc8_24.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @ImplsOfNonFacetType(%U.loc8_24.1: type) { -// CHECK:STDOUT: %U.loc8_24.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc8_24.2 (constants.%U)] -// CHECK:STDOUT: %U.patt.loc8_24.2: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_24.2 (constants.%U.patt)] +// CHECK:STDOUT: generic fn @ImplsOfNonFacetType(%U.loc8_24.1: %.2) { +// CHECK:STDOUT: %U.loc8_24.2: %.2 = bind_symbolic_name U, 0 [symbolic = %U.loc8_24.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc8_24.2: %.2 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc8_24.2 (constants.%U.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%U.param_patt: type); +// CHECK:STDOUT: fn(%U.param_patt: %.2); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplsOfNonFacetType(constants.%U) { @@ -1204,8 +1212,16 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %DoesNotImplI: %DoesNotImplI.type = struct_value () [template] // CHECK:STDOUT: %Impls.type: type = fn_type @Impls [template] // CHECK:STDOUT: %Impls: %Impls.type = struct_value () [template] -// CHECK:STDOUT: %V: %J.type = bind_symbolic_name V, 0 [symbolic] -// CHECK:STDOUT: %V.patt: %J.type = symbolic_binding_pattern V, 0 [symbolic] +// CHECK:STDOUT: %V: = bind_symbolic_name V, 0 [symbolic] +// CHECK:STDOUT: %V.patt: = symbolic_binding_pattern V, 0 [symbolic] +// CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self, 0 [symbolic] +// CHECK:STDOUT: %.5: type = facet_type [template] +// CHECK:STDOUT: %Y: %.5 = bind_symbolic_name Y, 0 [symbolic] +// CHECK:STDOUT: %Y.patt: %.5 = symbolic_binding_pattern Y, 0 [symbolic] +// CHECK:STDOUT: %EmptyStruct.type: type = fn_type @EmptyStruct [template] +// CHECK:STDOUT: %EmptyStruct: %EmptyStruct.type = struct_value () [template] +// CHECK:STDOUT: %NotEmptyStruct.type: type = fn_type @NotEmptyStruct [template] +// CHECK:STDOUT: %NotEmptyStruct: %NotEmptyStruct.type = struct_value () [template] // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template] // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template] // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic] @@ -1215,29 +1231,22 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %Self.3: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic] // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic] // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic] -// CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic] -// CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.11 [symbolic] -// CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%J.type) [template] -// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%J.type) [template] +// CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.11 [symbolic] +// CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%.5) [template] +// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%.5) [template] // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template] -// CHECK:STDOUT: %.7: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] -// CHECK:STDOUT: %.8: %.7 = assoc_entity element0, imports.%import_ref.11 [template] -// CHECK:STDOUT: %.9: %.5 = assoc_entity element0, imports.%import_ref.12 [symbolic] -// CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self, 0 [symbolic] -// CHECK:STDOUT: %Y: %J.type = bind_symbolic_name Y, 0 [symbolic] -// CHECK:STDOUT: %Y.patt: %J.type = symbolic_binding_pattern Y, 0 [symbolic] -// CHECK:STDOUT: %EmptyStruct.type: type = fn_type @EmptyStruct [template] -// CHECK:STDOUT: %EmptyStruct: %EmptyStruct.type = struct_value () [template] -// CHECK:STDOUT: %NotEmptyStruct.type: type = fn_type @NotEmptyStruct [template] -// CHECK:STDOUT: %NotEmptyStruct: %NotEmptyStruct.type = struct_value () [template] +// CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] +// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.11 [template] +// CHECK:STDOUT: %.10: %.6 = assoc_entity element0, imports.%import_ref.12 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref.1: type = import_ref Main//state_constraints, inst+3, loaded [template = constants.%J.type] // CHECK:STDOUT: %import_ref.2 = import_ref Main//state_constraints, inst+7, unloaded -// CHECK:STDOUT: %import_ref.3 = import_ref Main//state_constraints, inst+34, unloaded -// CHECK:STDOUT: %import_ref.4: %Impls.type = import_ref Main//state_constraints, inst+54, loaded [template = constants.%Impls] -// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+77, 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+56, loaded [template = constants.%Impls] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//state_constraints, inst+80, unloaded // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .ImplicitAs = %import_ref.7 // CHECK:STDOUT: import Core//prelude @@ -1246,7 +1255,7 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %import_ref.6 = import_ref Main//state_constraints, inst+5, unloaded // CHECK:STDOUT: %import_ref.7: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs] // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/as, inst+55, unloaded -// CHECK:STDOUT: %import_ref.9: @ImplicitAs.%.1 (%.5) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.9)] +// CHECK:STDOUT: %import_ref.9: @ImplicitAs.%.1 (%.6) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.10)] // CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/as, inst+70, unloaded // CHECK:STDOUT: %import_ref.11 = import_ref Core//prelude/operators/as, inst+70, unloaded // CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/as, inst+70, unloaded @@ -1274,18 +1283,18 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: } // CHECK:STDOUT: %DoesNotImplI.decl: %DoesNotImplI.type = fn_decl @DoesNotImplI [template = constants.%DoesNotImplI] {} {} // CHECK:STDOUT: %EmptyStruct.decl: %EmptyStruct.type = fn_decl @EmptyStruct [template = constants.%EmptyStruct] { -// CHECK:STDOUT: %Y.patt.loc26_16.1: %J.type = symbolic_binding_pattern Y, 0 [symbolic = %Y.patt.loc26_16.2 (constants.%Y.patt)] -// CHECK:STDOUT: %Y.param_patt: %J.type = value_param_pattern %Y.patt.loc26_16.1, runtime_param [symbolic = %Y.patt.loc26_16.2 (constants.%Y.patt)] +// CHECK:STDOUT: %Y.patt.loc18_16.1: %.5 = symbolic_binding_pattern Y, 0 [symbolic = %Y.patt.loc18_16.2 (constants.%Y.patt)] +// CHECK:STDOUT: %Y.param_patt: %.5 = value_param_pattern %Y.patt.loc18_16.1, runtime_param [symbolic = %Y.patt.loc18_16.2 (constants.%Y.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %J.ref: type = name_ref J, imports.%import_ref.1 [template = constants.%J.type] // CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.Self.ref: %J.type = name_ref .Self, %.Self [symbolic = constants.%.Self] -// CHECK:STDOUT: %.loc26_38: %.1 = struct_literal () -// CHECK:STDOUT: %.loc26_22: type = where_expr %.Self [template = constants.%J.type] { -// CHECK:STDOUT: requirement_equivalent %.Self.ref, %.loc26_38 +// CHECK:STDOUT: %.loc18_38: %.1 = struct_literal () +// CHECK:STDOUT: %.loc18_22: type = where_expr %.Self [template = constants.%.5] { +// CHECK:STDOUT: requirement_equivalent %.Self.ref, %.loc18_38 // CHECK:STDOUT: } -// CHECK:STDOUT: %Y.param: %J.type = value_param runtime_param -// CHECK:STDOUT: %Y.loc26_16.1: %J.type = bind_symbolic_name Y, 0, %Y.param [symbolic = %Y.loc26_16.2 (constants.%Y)] +// CHECK:STDOUT: %Y.param: %.5 = value_param runtime_param +// CHECK:STDOUT: %Y.loc18_16.1: %.5 = bind_symbolic_name Y, 0, %Y.param [symbolic = %Y.loc18_16.2 (constants.%Y)] // CHECK:STDOUT: } // CHECK:STDOUT: %NotEmptyStruct.decl: %NotEmptyStruct.type = fn_decl @NotEmptyStruct [template = constants.%NotEmptyStruct] {} {} // CHECK:STDOUT: } @@ -1305,8 +1314,8 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)] // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)] // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)] -// CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.5)] -// CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.5) = assoc_entity element0, imports.%import_ref.11 [symbolic = %.2 (constants.%.6)] +// CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.6)] +// CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.6) = assoc_entity element0, imports.%import_ref.11 [symbolic = %.2 (constants.%.7)] // CHECK:STDOUT: // CHECK:STDOUT: interface { // CHECK:STDOUT: !members: @@ -1317,14 +1326,14 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl: %C.ref as %J.ref { -// CHECK:STDOUT: %.loc8: = interface_witness () [template = constants.%.4] +// CHECK:STDOUT: %.loc11: = interface_witness () [template = constants.%.4] // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = %.loc8 +// CHECK:STDOUT: witness = %.loc11 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { -// CHECK:STDOUT: %.loc7: = complete_type_witness %.1 [template = constants.%.2] +// CHECK:STDOUT: %.loc10: = complete_type_witness %.1 [template = constants.%.2] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C @@ -1334,51 +1343,52 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: !entry: // CHECK:STDOUT: %Impls.ref: %Impls.type = name_ref Impls, imports.%import_ref.4 [template = constants.%Impls] // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] -// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%J.type) [template = constants.%ImplicitAs.type.3] -// CHECK:STDOUT: %.loc23_8.1: %.7 = specific_constant imports.%import_ref.9, @ImplicitAs(constants.%J.type) [template = constants.%.8] -// CHECK:STDOUT: %Convert.ref: %.7 = name_ref Convert, %.loc23_8.1 [template = constants.%.8] -// CHECK:STDOUT: %.loc23_8.2: %J.type = converted %C.ref, [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @Impls(constants.%V: %J.type) { -// CHECK:STDOUT: %V: %J.type = bind_symbolic_name V, 0 [symbolic = %V (constants.%V)] -// CHECK:STDOUT: %V.patt: %J.type = symbolic_binding_pattern V, 0 [symbolic = %V.patt (constants.%V.patt)] -// CHECK:STDOUT: -// CHECK:STDOUT: fn(%V.param_patt: %J.type); -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) { -// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] -// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)] -// CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)] +// CHECK:STDOUT: generic fn @Impls(constants.%V: ) { +// CHECK:STDOUT: %V: = bind_symbolic_name V, 0 [symbolic = %V (constants.%V)] +// CHECK:STDOUT: %V.patt: = symbolic_binding_pattern V, 0 [symbolic = %V.patt (constants.%V.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest); +// CHECK:STDOUT: fn(%V.param_patt: ); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @EmptyStruct(%Y.loc26_16.1: %J.type) { -// CHECK:STDOUT: %Y.loc26_16.2: %J.type = bind_symbolic_name Y, 0 [symbolic = %Y.loc26_16.2 (constants.%Y)] -// CHECK:STDOUT: %Y.patt.loc26_16.2: %J.type = symbolic_binding_pattern Y, 0 [symbolic = %Y.patt.loc26_16.2 (constants.%Y.patt)] +// CHECK:STDOUT: generic fn @EmptyStruct(%Y.loc18_16.1: %.5) { +// CHECK:STDOUT: %Y.loc18_16.2: %.5 = bind_symbolic_name Y, 0 [symbolic = %Y.loc18_16.2 (constants.%Y)] +// CHECK:STDOUT: %Y.patt.loc18_16.2: %.5 = symbolic_binding_pattern Y, 0 [symbolic = %Y.patt.loc18_16.2 (constants.%Y.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%Y.param_patt: %J.type); +// CHECK:STDOUT: fn(%Y.param_patt: %.5); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @NotEmptyStruct() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %EmptyStruct.ref: %EmptyStruct.type = name_ref EmptyStruct, file.%EmptyStruct.decl [template = constants.%EmptyStruct] // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C] -// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%J.type) [template = constants.%ImplicitAs.type.3] -// CHECK:STDOUT: %.loc39_14.1: %.7 = specific_constant imports.%import_ref.9, @ImplicitAs(constants.%J.type) [template = constants.%.8] -// CHECK:STDOUT: %Convert.ref: %.7 = name_ref Convert, %.loc39_14.1 [template = constants.%.8] -// CHECK:STDOUT: %.loc39_14.2: %J.type = converted %C.ref, [template = ] +// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%.5) [template = constants.%ImplicitAs.type.3] +// CHECK:STDOUT: %.loc32_14.1: %.8 = specific_constant imports.%import_ref.9, @ImplicitAs(constants.%.5) [template = constants.%.9] +// CHECK:STDOUT: %Convert.ref: %.8 = name_ref Convert, %.loc32_14.1 [template = constants.%.9] +// CHECK:STDOUT: %.loc32_14.2: %.5 = converted %C.ref, [template = ] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) { +// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] +// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)] +// CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest); +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific @Impls(constants.%V) { // CHECK:STDOUT: %V => constants.%V // CHECK:STDOUT: %V.patt => constants.%V // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @EmptyStruct(constants.%Y) { +// CHECK:STDOUT: %Y.loc18_16.2 => constants.%Y +// CHECK:STDOUT: %Y.patt.loc18_16.2 => constants.%Y +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { // CHECK:STDOUT: %Dest => constants.%Dest // CHECK:STDOUT: %Dest.patt => constants.%Dest @@ -1400,42 +1410,62 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %Self => constants.%Self.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @ImplicitAs(constants.%J.type) { -// CHECK:STDOUT: %Dest => constants.%J.type -// CHECK:STDOUT: %Dest.patt => constants.%J.type +// CHECK:STDOUT: specific @ImplicitAs(constants.%.5) { +// CHECK:STDOUT: %Dest => constants.%.5 +// CHECK:STDOUT: %Dest.patt => constants.%.5 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3 // CHECK:STDOUT: %Self => constants.%Self.3 // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2 // CHECK:STDOUT: %Convert => constants.%Convert.2 -// CHECK:STDOUT: %.1 => constants.%.7 -// CHECK:STDOUT: %.2 => constants.%.8 +// CHECK:STDOUT: %.1 => constants.%.8 +// CHECK:STDOUT: %.2 => constants.%.9 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @EmptyStruct(constants.%Y) { -// CHECK:STDOUT: %Y.loc26_16.2 => constants.%Y -// CHECK:STDOUT: %Y.patt.loc26_16.2 => constants.%Y -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- let.carbon +// CHECK:STDOUT: --- fail_todo_let.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %A.type: type = interface_type @A [template] -// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %Self.1: %A.type = bind_symbolic_name Self, 0 [symbolic] // CHECK:STDOUT: %D: type = class_type @D [template] // CHECK:STDOUT: %.1: type = struct_type {} [template] // CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] // CHECK:STDOUT: %.3: type = tuple_type () [template] // CHECK:STDOUT: %.4: = interface_witness () [template] // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self, 0 [symbolic] +// CHECK:STDOUT: %.5: type = facet_type [template] +// CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template] +// CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template] +// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic] +// CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic] +// CHECK:STDOUT: %Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic] +// CHECK:STDOUT: %Self.3: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic] +// CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [symbolic] +// CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%.5) [template] +// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%.5) [template] +// CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template] +// CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] +// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.5 [template] +// CHECK:STDOUT: %.10: %.6 = assoc_entity element0, imports.%import_ref.6 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { +// CHECK:STDOUT: .ImplicitAs = %import_ref.1 // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs] +// CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+55, unloaded +// CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.6) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.10)] +// CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+70, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+70, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+70, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1455,19 +1485,39 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A.type] -// CHECK:STDOUT: %.loc8: type = where_expr %.Self [template = type] { +// CHECK:STDOUT: %.loc14: type = where_expr %.Self [template = constants.%.5] { // CHECK:STDOUT: requirement_impls %.Self.ref, %A.ref // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: interface @A { -// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self // CHECK:STDOUT: witness = () // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) { +// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] +// CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)] +// CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)] +// CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)] +// CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)] +// CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.6)] +// CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.6) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.7)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: .Convert = imports.%import_ref.3 +// CHECK:STDOUT: witness = (imports.%import_ref.4) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: impl @impl: %D.ref as %A.ref { // CHECK:STDOUT: %.loc6: = interface_witness () [template = constants.%.4] // CHECK:STDOUT: @@ -1482,10 +1532,56 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: .Self = constants.%D // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) { +// CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] +// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)] +// CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)] +// CHECK:STDOUT: +// CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest); +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D] -// CHECK:STDOUT: %B: type = bind_name B, %D.ref +// CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%.5) [template = constants.%ImplicitAs.type.3] +// CHECK:STDOUT: %.loc14_36.1: %.8 = specific_constant imports.%import_ref.3, @ImplicitAs(constants.%.5) [template = constants.%.9] +// CHECK:STDOUT: %Convert.ref: %.8 = name_ref Convert, %.loc14_36.1 [template = constants.%.9] +// CHECK:STDOUT: %.loc14_36.2: %.5 = converted %D.ref, [template = ] +// CHECK:STDOUT: %B: %.5 = bind_name B, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { +// CHECK:STDOUT: %Dest => constants.%Dest +// CHECK:STDOUT: %Dest.patt => constants.%Dest +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) { +// CHECK:STDOUT: %Dest => constants.%Dest +// CHECK:STDOUT: %Dest.patt => constants.%Dest +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) { +// CHECK:STDOUT: %Dest => constants.%Dest +// CHECK:STDOUT: %Dest.patt => constants.%Dest +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.2) { +// CHECK:STDOUT: %Dest => constants.%Dest +// CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2 +// CHECK:STDOUT: %Self => constants.%Self.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @ImplicitAs(constants.%.5) { +// CHECK:STDOUT: %Dest => constants.%.5 +// CHECK:STDOUT: %Dest.patt => constants.%.5 +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3 +// CHECK:STDOUT: %Self => constants.%Self.3 +// CHECK:STDOUT: %Convert.type => constants.%Convert.type.2 +// CHECK:STDOUT: %Convert => constants.%Convert.2 +// CHECK:STDOUT: %.1 => constants.%.8 +// CHECK:STDOUT: %.2 => constants.%.9 +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/where_expr/designator.carbon b/toolchain/check/testdata/where_expr/designator.carbon index 7f0e78110749d..bc5ae9f4647d3 100644 --- a/toolchain/check/testdata/where_expr/designator.carbon +++ b/toolchain/check/testdata/where_expr/designator.carbon @@ -95,17 +95,20 @@ class D { // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @I.%Member [template] // CHECK:STDOUT: %.Self.1: %I.type = bind_symbolic_name .Self, 0 [symbolic] // CHECK:STDOUT: %.3: type = tuple_type () [template] -// CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic] -// CHECK:STDOUT: %T.patt: %I.type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %.4: type = facet_type [template] +// CHECK:STDOUT: %T: %.4 = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: %.4 = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %PeriodSelf.type: type = fn_type @PeriodSelf [template] // CHECK:STDOUT: %PeriodSelf: %PeriodSelf.type = struct_value () [template] -// CHECK:STDOUT: %U: %I.type = bind_symbolic_name U, 0 [symbolic] -// CHECK:STDOUT: %U.patt: %I.type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %.5: type = facet_type [template] +// CHECK:STDOUT: %U: %.5 = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: %.5 = symbolic_binding_pattern U, 0 [symbolic] // CHECK:STDOUT: %PeriodMember.type: type = fn_type @PeriodMember [template] // CHECK:STDOUT: %PeriodMember: %PeriodMember.type = struct_value () [template] // CHECK:STDOUT: %.Self.2: type = bind_symbolic_name .Self, 0 [symbolic] -// CHECK:STDOUT: %V: type = bind_symbolic_name V, 0 [symbolic] -// CHECK:STDOUT: %V.patt: type = symbolic_binding_pattern V, 0 [symbolic] +// CHECK:STDOUT: %.6: type = facet_type [template] +// CHECK:STDOUT: %V: %.6 = bind_symbolic_name V, 0 [symbolic] +// CHECK:STDOUT: %V.patt: %.6 = symbolic_binding_pattern V, 0 [symbolic] // CHECK:STDOUT: %TypeSelfImpls.type: type = fn_type @TypeSelfImpls [template] // CHECK:STDOUT: %TypeSelfImpls: %TypeSelfImpls.type = struct_value () [template] // CHECK:STDOUT: } @@ -128,46 +131,46 @@ class D { // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {} // CHECK:STDOUT: %PeriodSelf.decl: %PeriodSelf.type = fn_decl @PeriodSelf [template = constants.%PeriodSelf] { -// CHECK:STDOUT: %T.patt.loc8_15.1: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)] -// CHECK:STDOUT: %T.param_patt: %I.type = value_param_pattern %T.patt.loc8_15.1, runtime_param [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)] +// CHECK:STDOUT: %T.patt.loc8_15.1: %.4 = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)] +// CHECK:STDOUT: %T.param_patt: %.4 = value_param_pattern %T.patt.loc8_15.1, runtime_param [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self.1] // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self.1] // CHECK:STDOUT: %.loc8_37: %.3 = tuple_literal () -// CHECK:STDOUT: %.loc8_21: type = where_expr %.Self [template = constants.%I.type] { +// CHECK:STDOUT: %.loc8_21: type = where_expr %.Self [template = constants.%.4] { // CHECK:STDOUT: requirement_equivalent %.Self.ref, %.loc8_37 // CHECK:STDOUT: } -// CHECK:STDOUT: %T.param: %I.type = value_param runtime_param -// CHECK:STDOUT: %T.loc8_15.1: %I.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc8_15.2 (constants.%T)] +// CHECK:STDOUT: %T.param: %.4 = value_param runtime_param +// CHECK:STDOUT: %T.loc8_15.1: %.4 = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc8_15.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %PeriodMember.decl: %PeriodMember.type = fn_decl @PeriodMember [template = constants.%PeriodMember] { -// CHECK:STDOUT: %U.patt.loc10_17.1: %I.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc10_17.2 (constants.%U.patt)] -// CHECK:STDOUT: %U.param_patt: %I.type = value_param_pattern %U.patt.loc10_17.1, runtime_param [symbolic = %U.patt.loc10_17.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.patt.loc10_17.1: %.5 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc10_17.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.param_patt: %.5 = value_param_pattern %U.patt.loc10_17.1, runtime_param [symbolic = %U.patt.loc10_17.2 (constants.%U.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self.1] // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self.1] // CHECK:STDOUT: %Member.ref: %.1 = name_ref Member, @I.%.loc5 [template = constants.%.2] // CHECK:STDOUT: %.loc10_41: %.3 = tuple_literal () -// CHECK:STDOUT: %.loc10_23: type = where_expr %.Self [template = constants.%I.type] { +// CHECK:STDOUT: %.loc10_23: type = where_expr %.Self [template = constants.%.5] { // CHECK:STDOUT: requirement_equivalent %Member.ref, %.loc10_41 // CHECK:STDOUT: } -// CHECK:STDOUT: %U.param: %I.type = value_param runtime_param -// CHECK:STDOUT: %U.loc10_17.1: %I.type = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc10_17.2 (constants.%U)] +// CHECK:STDOUT: %U.param: %.5 = value_param runtime_param +// CHECK:STDOUT: %U.loc10_17.1: %.5 = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc10_17.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: %TypeSelfImpls.decl: %TypeSelfImpls.type = fn_decl @TypeSelfImpls [template = constants.%TypeSelfImpls] { -// CHECK:STDOUT: %V.patt.loc12_18.1: type = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc12_18.2 (constants.%V.patt)] -// CHECK:STDOUT: %V.param_patt: type = value_param_pattern %V.patt.loc12_18.1, runtime_param [symbolic = %V.patt.loc12_18.2 (constants.%V.patt)] +// CHECK:STDOUT: %V.patt.loc12_18.1: %.6 = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc12_18.2 (constants.%V.patt)] +// CHECK:STDOUT: %V.param_patt: %.6 = value_param_pattern %V.patt.loc12_18.1, runtime_param [symbolic = %V.patt.loc12_18.2 (constants.%V.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self.2] // CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic = constants.%.Self.2] // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] -// CHECK:STDOUT: %.loc12: type = where_expr %.Self [template = type] { +// CHECK:STDOUT: %.loc12: type = where_expr %.Self [template = constants.%.6] { // CHECK:STDOUT: requirement_impls %.Self.ref, %I.ref // CHECK:STDOUT: } -// CHECK:STDOUT: %V.param: type = value_param runtime_param -// CHECK:STDOUT: %V.loc12_18.1: type = bind_symbolic_name V, 0, %V.param [symbolic = %V.loc12_18.2 (constants.%V)] +// CHECK:STDOUT: %V.param: %.6 = value_param runtime_param +// CHECK:STDOUT: %V.loc12_18.1: %.6 = bind_symbolic_name V, 0, %V.param [symbolic = %V.loc12_18.2 (constants.%V)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -182,25 +185,25 @@ class D { // CHECK:STDOUT: witness = (%Member) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @PeriodSelf(%T.loc8_15.1: %I.type) { -// CHECK:STDOUT: %T.loc8_15.2: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_15.2 (constants.%T)] -// CHECK:STDOUT: %T.patt.loc8_15.2: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)] +// CHECK:STDOUT: generic fn @PeriodSelf(%T.loc8_15.1: %.4) { +// CHECK:STDOUT: %T.loc8_15.2: %.4 = bind_symbolic_name T, 0 [symbolic = %T.loc8_15.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc8_15.2: %.4 = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_15.2 (constants.%T.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%T.param_patt: %I.type); +// CHECK:STDOUT: fn(%T.param_patt: %.4); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @PeriodMember(%U.loc10_17.1: %I.type) { -// CHECK:STDOUT: %U.loc10_17.2: %I.type = bind_symbolic_name U, 0 [symbolic = %U.loc10_17.2 (constants.%U)] -// CHECK:STDOUT: %U.patt.loc10_17.2: %I.type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc10_17.2 (constants.%U.patt)] +// CHECK:STDOUT: generic fn @PeriodMember(%U.loc10_17.1: %.5) { +// CHECK:STDOUT: %U.loc10_17.2: %.5 = bind_symbolic_name U, 0 [symbolic = %U.loc10_17.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc10_17.2: %.5 = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc10_17.2 (constants.%U.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%U.param_patt: %I.type); +// CHECK:STDOUT: fn(%U.param_patt: %.5); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @TypeSelfImpls(%V.loc12_18.1: type) { -// CHECK:STDOUT: %V.loc12_18.2: type = bind_symbolic_name V, 0 [symbolic = %V.loc12_18.2 (constants.%V)] -// CHECK:STDOUT: %V.patt.loc12_18.2: type = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc12_18.2 (constants.%V.patt)] +// CHECK:STDOUT: generic fn @TypeSelfImpls(%V.loc12_18.1: %.6) { +// CHECK:STDOUT: %V.loc12_18.2: %.6 = bind_symbolic_name V, 0 [symbolic = %V.loc12_18.2 (constants.%V)] +// CHECK:STDOUT: %V.patt.loc12_18.2: %.6 = symbolic_binding_pattern V, 0 [symbolic = %V.patt.loc12_18.2 (constants.%V.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%V.param_patt: type); +// CHECK:STDOUT: fn(%V.param_patt: %.6); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @PeriodSelf(constants.%T) { @@ -228,8 +231,9 @@ class D { // CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self, 0 [symbolic] // CHECK:STDOUT: %.3: type = tuple_type () [template] // CHECK:STDOUT: %.4: type = struct_type {} [template] -// CHECK:STDOUT: %W: %J.type = bind_symbolic_name W, 0 [symbolic] -// CHECK:STDOUT: %W.patt: %J.type = symbolic_binding_pattern W, 0 [symbolic] +// CHECK:STDOUT: %.5: type = facet_type [template] +// CHECK:STDOUT: %W: %.5 = bind_symbolic_name W, 0 [symbolic] +// CHECK:STDOUT: %W.patt: %.5 = symbolic_binding_pattern W, 0 [symbolic] // CHECK:STDOUT: %PeriodMismatch.type: type = fn_type @PeriodMismatch [template] // CHECK:STDOUT: %PeriodMismatch: %PeriodMismatch.type = struct_value () [template] // CHECK:STDOUT: } @@ -250,19 +254,19 @@ class D { // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {} // CHECK:STDOUT: %PeriodMismatch.decl: %PeriodMismatch.type = fn_decl @PeriodMismatch [template = constants.%PeriodMismatch] { -// CHECK:STDOUT: %W.patt.loc12_19.1: %J.type = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc12_19.2 (constants.%W.patt)] -// CHECK:STDOUT: %W.param_patt: %J.type = value_param_pattern %W.patt.loc12_19.1, runtime_param [symbolic = %W.patt.loc12_19.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.patt.loc12_19.1: %.5 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc12_19.2 (constants.%W.patt)] +// CHECK:STDOUT: %W.param_patt: %.5 = value_param_pattern %W.patt.loc12_19.1, runtime_param [symbolic = %W.patt.loc12_19.2 (constants.%W.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type] // CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.Self.ref: %J.type = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %Mismatch.ref: = name_ref Mismatch, [template = ] // CHECK:STDOUT: %.loc12_44: %.4 = struct_literal () -// CHECK:STDOUT: %.loc12_25: type = where_expr %.Self [template = constants.%J.type] { +// CHECK:STDOUT: %.loc12_25: type = where_expr %.Self [template = constants.%.5] { // CHECK:STDOUT: requirement_rewrite %Mismatch.ref, // CHECK:STDOUT: } -// CHECK:STDOUT: %W.param: %J.type = value_param runtime_param -// CHECK:STDOUT: %W.loc12_19.1: %J.type = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc12_19.2 (constants.%W)] +// CHECK:STDOUT: %W.param: %.5 = value_param runtime_param +// CHECK:STDOUT: %W.loc12_19.1: %.5 = bind_symbolic_name W, 0, %W.param [symbolic = %W.loc12_19.2 (constants.%W)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -277,11 +281,11 @@ class D { // CHECK:STDOUT: witness = (%Member) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @PeriodMismatch(%W.loc12_19.1: %J.type) { -// CHECK:STDOUT: %W.loc12_19.2: %J.type = bind_symbolic_name W, 0 [symbolic = %W.loc12_19.2 (constants.%W)] -// CHECK:STDOUT: %W.patt.loc12_19.2: %J.type = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc12_19.2 (constants.%W.patt)] +// CHECK:STDOUT: generic fn @PeriodMismatch(%W.loc12_19.1: %.5) { +// CHECK:STDOUT: %W.loc12_19.2: %.5 = bind_symbolic_name W, 0 [symbolic = %W.loc12_19.2 (constants.%W)] +// CHECK:STDOUT: %W.patt.loc12_19.2: %.5 = symbolic_binding_pattern W, 0 [symbolic = %W.patt.loc12_19.2 (constants.%W.patt)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%W.param_patt: %J.type); +// CHECK:STDOUT: fn(%W.param_patt: %.5); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @PeriodMismatch(constants.%W) { diff --git a/toolchain/check/testdata/where_expr/non_generic.carbon b/toolchain/check/testdata/where_expr/non_generic.carbon index 4a14d45e2babb..0a6ab38cdcc21 100644 --- a/toolchain/check/testdata/where_expr/non_generic.carbon +++ b/toolchain/check/testdata/where_expr/non_generic.carbon @@ -24,6 +24,7 @@ fn NotGenericF(U: I where .T == i32) {} // CHECK:STDOUT: %.3: type = tuple_type () [template] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = facet_type [template] // CHECK:STDOUT: %NotGenericF.type: type = fn_type @NotGenericF [template] // CHECK:STDOUT: %NotGenericF: %NotGenericF.type = struct_value () [template] // CHECK:STDOUT: } @@ -46,19 +47,19 @@ fn NotGenericF(U: I where .T == i32) {} // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {} // CHECK:STDOUT: %NotGenericF.decl: %NotGenericF.type = fn_decl @NotGenericF [template = constants.%NotGenericF] { -// CHECK:STDOUT: %U.patt: %I.type = binding_pattern U -// CHECK:STDOUT: %U.param_patt: %I.type = value_param_pattern %U.patt, runtime_param0 +// CHECK:STDOUT: %U.patt: %.4 = binding_pattern U +// CHECK:STDOUT: %U.param_patt: %.4 = value_param_pattern %U.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type] // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self, 0 [symbolic = constants.%.Self] // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %T.ref: %.1 = name_ref T, @I.%.loc11 [template = constants.%.2] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] -// CHECK:STDOUT: %.loc14: type = where_expr %.Self [template = constants.%I.type] { +// CHECK:STDOUT: %.loc14: type = where_expr %.Self [template = constants.%.4] { // CHECK:STDOUT: requirement_equivalent %T.ref, %int.make_type_32 // CHECK:STDOUT: } -// CHECK:STDOUT: %U.param: %I.type = value_param runtime_param0 -// CHECK:STDOUT: %U: %I.type = bind_name U, %U.param +// CHECK:STDOUT: %U.param: %.4 = value_param runtime_param0 +// CHECK:STDOUT: %U: %.4 = bind_name U, %U.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: @@ -75,7 +76,7 @@ fn NotGenericF(U: I where .T == i32) {} // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: -// CHECK:STDOUT: fn @NotGenericF(%U.param_patt: %I.type) { +// CHECK:STDOUT: fn @NotGenericF(%U.param_patt: %.4) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/lower/file_context.cpp b/toolchain/lower/file_context.cpp index 9d021a0ac5ef6..8fa7e961812f6 100644 --- a/toolchain/lower/file_context.cpp +++ b/toolchain/lower/file_context.cpp @@ -576,7 +576,7 @@ static auto BuildTypeForInst(FileContext& context, SemIR::TupleType inst) template requires(InstT::Kind.template IsAnyOf< - SemIR::AssociatedEntityType, SemIR::FunctionType, + SemIR::AssociatedEntityType, SemIR::FacetType, SemIR::FunctionType, SemIR::GenericClassType, SemIR::GenericInterfaceType, SemIR::InterfaceType, SemIR::UnboundElementType, SemIR::WhereExpr>()) static auto BuildTypeForInst(FileContext& context, InstT /*inst*/) diff --git a/toolchain/sem_ir/BUILD b/toolchain/sem_ir/BUILD index a510ef03c705f..6b135c50fe363 100644 --- a/toolchain/sem_ir/BUILD +++ b/toolchain/sem_ir/BUILD @@ -101,6 +101,7 @@ cc_library( "copy_on_write_block.h", "entity_name.h", "entity_with_params_base.h", + "facet_type_info.h", "file.h", "function.h", "generic.h", diff --git a/toolchain/sem_ir/facet_type_info.h b/toolchain/sem_ir/facet_type_info.h new file mode 100644 index 0000000000000..8360167900fa4 --- /dev/null +++ b/toolchain/sem_ir/facet_type_info.h @@ -0,0 +1,32 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef CARBON_TOOLCHAIN_SEM_IR_FACET_TYPE_INFO_H_ +#define CARBON_TOOLCHAIN_SEM_IR_FACET_TYPE_INFO_H_ + +#include "toolchain/sem_ir/ids.h" + +namespace Carbon::SemIR { + +struct FacetTypeInfo : Printable { + // TODO: Need to switch to a processed, canonical form, that can support facet + // type equality as defined by + // https://github.com/carbon-language/carbon-lang/issues/2409. + TypeId base_facet_type_id; + InstBlockId requirement_block_id; + + auto Print(llvm::raw_ostream& out) const -> void { + out << "{base_facet_type: " << base_facet_type_id + << ", requirements: " << requirement_block_id << "}"; + } + auto operator==(const FacetTypeInfo& rhs) const -> bool { + return base_facet_type_id == rhs.base_facet_type_id && + requirement_block_id == rhs.requirement_block_id; + } + // TODO: Implement hash +}; + +} // namespace Carbon::SemIR + +#endif // CARBON_TOOLCHAIN_SEM_IR_FACET_TYPE_INFO_H_ diff --git a/toolchain/sem_ir/file.cpp b/toolchain/sem_ir/file.cpp index f1bc6ef83a77e..a08ca175928bf 100644 --- a/toolchain/sem_ir/file.cpp +++ b/toolchain/sem_ir/file.cpp @@ -256,6 +256,7 @@ auto GetExprCategory(const File& file, InstId inst_id) -> ExprCategory { case ClassType::Kind: case CompleteTypeWitness::Kind: case ConstType::Kind: + case FacetType::Kind: case FacetTypeAccess::Kind: case FloatLiteral::Kind: case FloatType::Kind: diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index a138a3346fbc3..fe871f497754b 100644 --- a/toolchain/sem_ir/file.h +++ b/toolchain/sem_ir/file.h @@ -16,6 +16,7 @@ #include "toolchain/sem_ir/class.h" #include "toolchain/sem_ir/constant.h" #include "toolchain/sem_ir/entity_name.h" +#include "toolchain/sem_ir/facet_type_info.h" #include "toolchain/sem_ir/function.h" #include "toolchain/sem_ir/generic.h" #include "toolchain/sem_ir/ids.h" @@ -114,6 +115,12 @@ class File : public Printable { auto interfaces() const -> const ValueStore& { return interfaces_; } + auto facet_types() -> CanonicalValueStore& { + return facet_types_; + } + auto facet_types() const -> const CanonicalValueStore& { + return facet_types_; + } auto impls() -> ImplStore& { return impls_; } auto impls() const -> const ImplStore& { return impls_; } auto generics() -> GenericStore& { return generics_; } @@ -202,6 +209,9 @@ class File : public Printable { // Storage for interfaces. ValueStore interfaces_; + // Storage for facet types. + CanonicalValueStore facet_types_; + // Storage for impls. ImplStore impls_; diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index ac67d90a55912..f54530d27d90b 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -956,6 +956,17 @@ class FormatterImpl { } } + auto FormatArg(FacetTypeId id) -> void { + const auto& info = sem_ir_.facet_types().Get(id); + out_ << ""; + } + auto FormatArg(IntKind k) -> void { k.Print(out_); } auto FormatArg(FloatKind k) -> void { k.Print(out_); } diff --git a/toolchain/sem_ir/id_kind.h b/toolchain/sem_ir/id_kind.h index a7d59e1c06023..50540481e9bc4 100644 --- a/toolchain/sem_ir/id_kind.h +++ b/toolchain/sem_ir/id_kind.h @@ -121,10 +121,10 @@ using IdKind = TypeEnum< IntId, RealId, FloatId, StringLiteralValueId, // From sem_ir/id.h. InstId, AbsoluteInstId, MatchingInstId, ConstantId, EntityNameId, - CompileTimeBindIndex, RuntimeParamIndex, FunctionId, ClassId, InterfaceId, - ImplId, GenericId, SpecificId, ImportIRId, ImportIRInstId, LocId, BoolValue, - IntKind, NameId, NameScopeId, InstBlockId, TypeId, TypeBlockId, - ElementIndex, LibraryNameId, FloatKind>; + CompileTimeBindIndex, RuntimeParamIndex, FacetTypeId, FunctionId, ClassId, + InterfaceId, ImplId, GenericId, SpecificId, ImportIRId, ImportIRInstId, + LocId, BoolValue, IntKind, NameId, NameScopeId, InstBlockId, TypeId, + TypeBlockId, ElementIndex, LibraryNameId, FloatKind>; } // namespace Carbon::SemIR diff --git a/toolchain/sem_ir/ids.h b/toolchain/sem_ir/ids.h index 15aa2dbb03389..2ee08415b7435 100644 --- a/toolchain/sem_ir/ids.h +++ b/toolchain/sem_ir/ids.h @@ -20,13 +20,14 @@ class File; class Inst; struct EntityName; struct Class; +struct FacetTypeInfo; struct Function; struct Generic; struct Specific; struct ImportIR; struct ImportIRInst; -struct Interface; struct Impl; +struct Interface; struct NameScope; struct TypeInfo; @@ -360,6 +361,22 @@ struct InterfaceId : public IdBase, public Printable { constexpr InterfaceId InterfaceId::Invalid = InterfaceId(InvalidIndex); +// The ID of an faceet type value. +struct FacetTypeId : public IdBase, public Printable { + using ValueType = FacetTypeInfo; + + // An explicitly invalid ID. + static const FacetTypeId Invalid; + + using IdBase::IdBase; + auto Print(llvm::raw_ostream& out) const -> void { + out << "facet type"; + IdBase::Print(out); + } +}; + +constexpr FacetTypeId FacetTypeId::Invalid = FacetTypeId(InvalidIndex); + // The ID of an impl. struct ImplId : public IdBase, public Printable { using ValueType = Impl; diff --git a/toolchain/sem_ir/inst_kind.def b/toolchain/sem_ir/inst_kind.def index 71224a7305818..5120c02fcb72a 100644 --- a/toolchain/sem_ir/inst_kind.def +++ b/toolchain/sem_ir/inst_kind.def @@ -51,6 +51,7 @@ CARBON_SEM_IR_INST_KIND(CompleteTypeWitness) CARBON_SEM_IR_INST_KIND(ConstType) CARBON_SEM_IR_INST_KIND(Converted) CARBON_SEM_IR_INST_KIND(Deref) +CARBON_SEM_IR_INST_KIND(FacetType) CARBON_SEM_IR_INST_KIND(FacetTypeAccess) CARBON_SEM_IR_INST_KIND(FieldDecl) CARBON_SEM_IR_INST_KIND(FloatLiteral) diff --git a/toolchain/sem_ir/stringify_type.cpp b/toolchain/sem_ir/stringify_type.cpp index d8a402b8a409b..936f58de668d8 100644 --- a/toolchain/sem_ir/stringify_type.cpp +++ b/toolchain/sem_ir/stringify_type.cpp @@ -120,6 +120,21 @@ auto StringifyTypeExpr(const SemIR::File& outer_sem_ir, InstId outer_inst_id) } break; } + case CARBON_KIND(FacetType inst): { + if (step.index == 0) { + out << ""; + } + break; + } case CARBON_KIND(FacetTypeAccess inst): { // Print `T as type` as simply `T`. push_inst_id(inst.facet_id); diff --git a/toolchain/sem_ir/typed_insts.h b/toolchain/sem_ir/typed_insts.h index 78cb6f2d645a0..4b42a0253be1c 100644 --- a/toolchain/sem_ir/typed_insts.h +++ b/toolchain/sem_ir/typed_insts.h @@ -551,6 +551,17 @@ struct ExportDecl { InstId value_id; }; +// A facet type value. +struct FacetType { + static constexpr auto Kind = InstKind::FacetType.Define( + {.ir_name = "facet_type", + .is_type = InstIsType::Always, + .constant_kind = InstConstantKind::Always}); + + TypeId type_id; + FacetTypeId facet_type_id; +}; + // Represents accessing the `type` field in a facet value, which is notionally a // pair of a type and a witness. struct FacetTypeAccess {