From e1b87ac2e173c81f93fc6564ec4c4e2f4f13940c Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Mon, 29 Sep 2025 11:17:48 -0700 Subject: [PATCH] Change IndexWith to use a standard binary operator setup (#6127) This is closer to [the design](https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/expressions/indexing.md?plain=1#L55-L64), just lacking `ref`, but does remove a lot of special-casing done for the lookup. The `ErrorInst` changes in `Build*Operator` are to align with what was being done for `IndexWith`; don't do an interface lookup if the relevant operand is an error. Otherwise, that becomes visible because some files have an error operand and don't provide the interface. --- core/prelude/operators/index.carbon | 3 +- toolchain/check/handle_index.cpp | 104 +------ toolchain/check/operator.cpp | 11 + .../facet/aggregate_through_access.carbon | 2 +- .../testdata/index/fail_invalid_base.carbon | 4 +- .../index/fail_non_tuple_access.carbon | 2 +- .../builtin/fail_type_mismatch_once.carbon | 1 - .../operators/overloaded/index.carbon | 240 ++++++++------- .../overloaded/index_with_prelude.carbon | 278 +++++++++++------- toolchain/diagnostics/diagnostic_kind.def | 1 - 10 files changed, 325 insertions(+), 321 deletions(-) diff --git a/core/prelude/operators/index.carbon b/core/prelude/operators/index.carbon index 9582c9313b0a..e34992978e03 100644 --- a/core/prelude/operators/index.carbon +++ b/core/prelude/operators/index.carbon @@ -4,6 +4,7 @@ package Core library "prelude/operators/index"; -interface IndexWith(SubscriptType:! type, ElementType:! type) { +interface IndexWith(SubscriptType:! type) { + let ElementType:! type; fn At[self: Self](subscript: SubscriptType) -> ElementType; } diff --git a/toolchain/check/handle_index.cpp b/toolchain/check/handle_index.cpp index a477e0ba59e4..17a502403c6d 100644 --- a/toolchain/check/handle_index.cpp +++ b/toolchain/check/handle_index.cpp @@ -26,105 +26,20 @@ auto HandleParseNode(Context& /*context*/, Parse::IndexExprStartId /*node_id*/) return true; } -// Returns the argument values of the `IndexWith` interface. Arguments -// correspond to the `SubscriptType` and the `ElementType`. If no arguments are -// used to define `IndexWith`, this returns an empty array reference. If the -// class does not implement the said interface, this returns a `std::nullopt`. -// TODO: Switch to using an associated type instead of a parameter for the -// `ElementType`. -static auto GetIndexWithArgs(Context& context, Parse::NodeId node_id, - SemIR::TypeId self_id) - -> std::optional> { - auto index_with_inst_id = LookupNameInCore(context, node_id, "IndexWith"); - // If the `IndexWith` interface doesn't have generic arguments then return an - // empty reference. - if (context.insts().Is(index_with_inst_id)) { - return llvm::ArrayRef(); - } - - auto index_with_inst = - context.insts().TryGetAsIfValid(index_with_inst_id); - if (!index_with_inst) { - return std::nullopt; - } - - auto index_with_interface = - context.types().TryGetAs( - index_with_inst->type_id); - if (!index_with_interface) { - return std::nullopt; - } - - for (const auto& impl : context.impls().values()) { - auto impl_self_type_id = - context.types().GetTypeIdForTypeInstId(impl.self_id); - auto impl_constraint_type_id = - context.types().GetTypeIdForTypeInstId(impl.constraint_id); - - if (impl_self_type_id != self_id) { - continue; - } - auto facet_type = - context.types().TryGetAs(impl_constraint_type_id); - if (!facet_type) { - continue; - } - const auto& facet_type_info = - context.facet_types().Get(facet_type->facet_type_id); - auto interface_type = facet_type_info.TryAsSingleInterface(); - if (!interface_type) { - continue; - } - if (index_with_interface->interface_id != interface_type->interface_id) { - continue; - } - - return context.inst_blocks().GetOrEmpty( - context.specifics().Get(interface_type->specific_id).args_id); - } - - return std::nullopt; -} - // Performs an index with base expression `operand_inst_id` and // `operand_type_id` for types that are not an array. This checks if // the base expression implements the `IndexWith` interface; if so, uses the // `At` associative method, otherwise prints a diagnostic. static auto PerformIndexWith(Context& context, Parse::NodeId node_id, SemIR::InstId operand_inst_id, - SemIR::TypeId operand_type_id, SemIR::InstId index_inst_id) -> SemIR::InstId { - auto args = GetIndexWithArgs(context, node_id, operand_type_id); - - // If the type does not implement the `IndexWith` interface, then return - // an error. - if (!args) { - CARBON_DIAGNOSTIC(TypeNotIndexable, Error, - "type {0} does not support indexing", SemIR::TypeId); - context.emitter().Emit(node_id, TypeNotIndexable, operand_type_id); - return SemIR::ErrorInst::InstId; - } - - Operator op{ - .interface_name = "IndexWith", - .interface_args_ref = *args, - .op_name = "At", - }; - - // IndexWith is defined without generic arguments. - if (args->empty()) { - return BuildBinaryOperator(context, node_id, op, operand_inst_id, - index_inst_id); - } - - // The first argument of the `IndexWith` interface corresponds to the - // `SubscriptType`, so first cast `index_inst_id` to that type. - auto subscript_type_id = context.types().GetTypeIdForTypeInstId((*args)[0]); - auto cast_index_id = - ConvertToValueOfType(context, node_id, index_inst_id, subscript_type_id); - + SemIR::InstId args[] = { + context.types().GetInstId(context.insts().Get(index_inst_id).type_id())}; + Operator op{.interface_name = "IndexWith", + .interface_args_ref = args, + .op_name = "At"}; return BuildBinaryOperator(context, node_id, op, operand_inst_id, - cast_index_id); + index_inst_id); } auto HandleParseNode(Context& context, Parse::IndexExprId node_id) -> bool { @@ -170,11 +85,8 @@ auto HandleParseNode(Context& context, Parse::IndexExprId node_id) -> bool { } default: { - auto elem_id = SemIR::ErrorInst::InstId; - if (operand_type_id != SemIR::ErrorInst::TypeId) { - elem_id = PerformIndexWith(context, node_id, operand_inst_id, - operand_type_id, index_inst_id); - } + auto elem_id = + PerformIndexWith(context, node_id, operand_inst_id, index_inst_id); context.node_stack().Push(node_id, elem_id); return true; } diff --git a/toolchain/check/operator.cpp b/toolchain/check/operator.cpp index 95330b77ee9d..9ff645846bda 100644 --- a/toolchain/check/operator.cpp +++ b/toolchain/check/operator.cpp @@ -25,6 +25,7 @@ static auto GetOperatorOpFunction(Context& context, SemIR::LocId loc_id, auto implicit_loc_id = context.insts().GetLocIdForDesugaring(loc_id); // Look up the interface, and pass it any generic arguments. + // TODO: Improve diagnostics when the found `interface_id` isn't callable. auto interface_id = LookupNameInCore(context, implicit_loc_id, op.interface_name); if (!op.interface_args_ref.empty()) { @@ -58,6 +59,11 @@ auto BuildUnaryOperator(Context& context, SemIR::LocId loc_id, Operator op, SemIR::InstId operand_id, MakeDiagnosticBuilderFn missing_impl_diagnoser) -> SemIR::InstId { + if (operand_id == SemIR::ErrorInst::InstId) { + // Exit early for errors, which prevent forming an `Op` function. + return SemIR::ErrorInst::InstId; + } + // For unary operators with a C++ class as the operand, try to import and call // the C++ operator. // TODO: Change impl lookup instead. See @@ -91,6 +97,11 @@ auto BuildBinaryOperator(Context& context, SemIR::LocId loc_id, Operator op, SemIR::InstId lhs_id, SemIR::InstId rhs_id, MakeDiagnosticBuilderFn missing_impl_diagnoser) -> SemIR::InstId { + if (lhs_id == SemIR::ErrorInst::InstId) { + // Exit early for errors, which prevent forming an `Op` function. + return SemIR::ErrorInst::InstId; + } + // For binary operators with a C++ class as at least one of the operands, try // to import and call the C++ operator. // TODO: Instead of hooking this here, change impl lookup, so that a generic diff --git a/toolchain/check/testdata/facet/aggregate_through_access.carbon b/toolchain/check/testdata/facet/aggregate_through_access.carbon index defef08f4e55..3a8cfa351f6f 100644 --- a/toolchain/check/testdata/facet/aggregate_through_access.carbon +++ b/toolchain/check/testdata/facet/aggregate_through_access.carbon @@ -47,7 +47,7 @@ interface Z { let X:! type; } -// CHECK:STDERR: fail_todo_array_access_through_witness.carbon:[[@LINE+4]]:40: error: type `type` does not support indexing [TypeNotIndexable] +// CHECK:STDERR: fail_todo_array_access_through_witness.carbon:[[@LINE+4]]:40: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `type` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: fn F(T:! Z where .X = array({}, 1)) -> T.X[0] { // CHECK:STDERR: ^~~~~~ // CHECK:STDERR: diff --git a/toolchain/check/testdata/index/fail_invalid_base.carbon b/toolchain/check/testdata/index/fail_invalid_base.carbon index b6ad56e0454f..4c59d4346d69 100644 --- a/toolchain/check/testdata/index/fail_invalid_base.carbon +++ b/toolchain/check/testdata/index/fail_invalid_base.carbon @@ -27,13 +27,13 @@ fn F(); // CHECK:STDERR: var b: i32 = F[1]; -// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+4]]:14: error: type `{.a: Core.IntLiteral, .b: Core.IntLiteral}` does not support indexing [TypeNotIndexable] +// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+4]]:14: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `{.a: Core.IntLiteral, .b: Core.IntLiteral}` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: var c: i32 = {.a = 1, .b = 2}[0]; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: var c: i32 = {.a = 1, .b = 2}[0]; -// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+4]]:14: error: type `type` does not support indexing [TypeNotIndexable] +// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+4]]:14: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `type` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: diff --git a/toolchain/check/testdata/index/fail_non_tuple_access.carbon b/toolchain/check/testdata/index/fail_non_tuple_access.carbon index f73a3a25e68c..ea0e12fa7c31 100644 --- a/toolchain/check/testdata/index/fail_non_tuple_access.carbon +++ b/toolchain/check/testdata/index/fail_non_tuple_access.carbon @@ -13,7 +13,7 @@ // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/index/fail_non_tuple_access.carbon fn Main() { - // CHECK:STDERR: fail_non_tuple_access.carbon:[[@LINE+4]]:3: error: type `Core.IntLiteral` does not support indexing [TypeNotIndexable] + // CHECK:STDERR: fail_non_tuple_access.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `Core.IntLiteral` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: 0[1]; // CHECK:STDERR: ^~~~ // CHECK:STDERR: diff --git a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon index e1f861cc16cf..1eecb5040c60 100644 --- a/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon +++ b/toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon @@ -72,7 +72,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc22: %empty_struct_type = struct_literal () // CHECK:STDOUT: %float: Core.FloatLiteral = float_literal_value 34e-1 [concrete = constants.%float] // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete = constants.%int_12] -// CHECK:STDOUT: %impl.elem1: = impl_witness_access , element1 [concrete = ] // CHECK:STDOUT: return to %return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/overloaded/index.carbon b/toolchain/check/testdata/operators/overloaded/index.carbon index 930562088975..ae93e23c9840 100644 --- a/toolchain/check/testdata/operators/overloaded/index.carbon +++ b/toolchain/check/testdata/operators/overloaded/index.carbon @@ -24,7 +24,7 @@ library "[[@TEST_NAME]]"; import Core library "core_wrong_index_with"; -// CHECK:STDERR: fail_wrong_index_with.carbon:[[@LINE+4]]:10: error: type `Core.IntLiteral` does not support indexing [TypeNotIndexable] +// CHECK:STDERR: fail_wrong_index_with.carbon:[[@LINE+4]]:10: error: value of type `type` is not callable [CallToNonCallable] // CHECK:STDERR: fn F() { 0[1]; } // CHECK:STDERR: ^~~~ // CHECK:STDERR: @@ -34,11 +34,7 @@ fn F() { 0[1]; } library "[[@TEST_NAME]]"; -// CHECK:STDERR: fail_missing_index_with.carbon:[[@LINE+8]]:10: error: `Core.IndexWith` implicitly referenced here, but package `Core` not found [CoreNotFound] -// CHECK:STDERR: fn F() { 0[1]; } -// CHECK:STDERR: ^~~~ -// CHECK:STDERR: -// CHECK:STDERR: fail_missing_index_with.carbon:[[@LINE+4]]:10: error: type `Core.IntLiteral` does not support indexing [TypeNotIndexable] +// CHECK:STDERR: fail_missing_index_with.carbon:[[@LINE+4]]:10: error: `Core.IndexWith` implicitly referenced here, but package `Core` not found [CoreNotFound] // CHECK:STDERR: fn F() { 0[1]; } // CHECK:STDERR: ^~~~ // CHECK:STDERR: @@ -48,22 +44,31 @@ fn F() { 0[1]; } package Core library "[[@TEST_NAME]]"; -interface IndexWith(SubscriptType:! type) { - fn At[self: Self](subscript: SubscriptType) -> (); +interface IndexWith(SubscriptType:! type, ElementType:! type) { + fn At[self: Self](subscript: SubscriptType) -> ElementType; } -// --- wrong_arg_count.carbon + +// --- fail_wrong_arg_count.carbon library "[[@TEST_NAME]]"; import Core library "core_wrong_arg_count"; -impl () as Core.IndexWith(()) { +impl () as Core.IndexWith((), ()) { fn At[self: Self](subscript: ()) -> () { return (); } } +// CHECK:STDERR: fail_wrong_arg_count.carbon:[[@LINE+8]]:10: error: 1 argument passed to generic interface expecting 2 arguments [CallArgCountMismatch] +// CHECK:STDERR: fn F() { ()[()]; } +// CHECK:STDERR: ^~~~~~ +// CHECK:STDERR: fail_wrong_arg_count.carbon:[[@LINE-11]]:1: in import [InImport] +// CHECK:STDERR: core_wrong_arg_count.carbon:4:1: note: calling generic interface declared here [InCallToEntity] +// CHECK:STDERR: interface IndexWith(SubscriptType:! type, ElementType:! type) { +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: fn F() { ()[()]; } // CHECK:STDOUT: --- core_wrong_index_with.carbon @@ -164,18 +169,18 @@ fn F() { ()[()]; } // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self] // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic] // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete] +// CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic] // CHECK:STDOUT: %IndexWith.type.68b: type = generic_interface_type @IndexWith [concrete] -// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.68b = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.type.06d: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic] -// CHECK:STDOUT: %Self: %IndexWith.type.06d = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %IndexWith.type.472: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic] +// CHECK:STDOUT: %Self: %IndexWith.type.472 = bind_symbolic_name Self, 2 [symbolic] // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic] -// CHECK:STDOUT: %pattern_type.356: type = pattern_type %Self.as_type [symbolic] +// CHECK:STDOUT: %pattern_type.a4e: type = pattern_type %Self.as_type [symbolic] // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %SubscriptType [symbolic] -// CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete] -// CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType) [symbolic] +// CHECK:STDOUT: %pattern_type.a32: type = pattern_type %ElementType [symbolic] +// CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType, %ElementType) [symbolic] // CHECK:STDOUT: %IndexWith.At: %IndexWith.At.type = struct_value () [symbolic] -// CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic] +// CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic] // CHECK:STDOUT: %assoc0: %IndexWith.assoc_type = assoc_entity element0, @IndexWith.%IndexWith.At.decl [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: @@ -185,39 +190,42 @@ fn F() { ()[()]; } // CHECK:STDOUT: } // CHECK:STDOUT: %IndexWith.decl: %IndexWith.type.68b = interface_decl @IndexWith [concrete = constants.%IndexWith.generic] { // CHECK:STDOUT: %SubscriptType.patt: %pattern_type.98f = symbolic_binding_pattern SubscriptType, 0 [concrete] +// CHECK:STDOUT: %ElementType.patt: %pattern_type.98f = symbolic_binding_pattern ElementType, 1 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.1: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] // CHECK:STDOUT: %SubscriptType.loc4_21.2: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType.loc4_21.1 (constants.%SubscriptType)] +// CHECK:STDOUT: %.Self.2: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %ElementType.loc4_43.2: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType.loc4_43.1 (constants.%ElementType)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic interface @IndexWith(%SubscriptType.loc4_21.2: type) { +// CHECK:STDOUT: generic interface @IndexWith(%SubscriptType.loc4_21.2: type, %ElementType.loc4_43.2: type) { // CHECK:STDOUT: %SubscriptType.loc4_21.1: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType.loc4_21.1 (constants.%SubscriptType)] +// CHECK:STDOUT: %ElementType.loc4_43.1: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType.loc4_43.1 (constants.%ElementType)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.loc4_21.1)> [symbolic = %IndexWith.type (constants.%IndexWith.type.06d)] -// CHECK:STDOUT: %Self.2: @IndexWith.%IndexWith.type (%IndexWith.type.06d) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] -// CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType.loc4_21.1) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type)] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.loc4_21.1, %ElementType.loc4_43.1)> [symbolic = %IndexWith.type (constants.%IndexWith.type.472)] +// CHECK:STDOUT: %Self.2: @IndexWith.%IndexWith.type (%IndexWith.type.472) = bind_symbolic_name Self, 2 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType.loc4_21.1, %ElementType.loc4_43.1) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type)] // CHECK:STDOUT: %IndexWith.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type) = struct_value () [symbolic = %IndexWith.At (constants.%IndexWith.At)] -// CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.loc4_21.1) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type)] -// CHECK:STDOUT: %assoc0.loc5_52.2: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_52.2 (constants.%assoc0)] +// CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.loc4_21.1, %ElementType.loc4_43.1) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type)] +// CHECK:STDOUT: %assoc0.loc5_61.2: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_61.2 (constants.%assoc0)] // CHECK:STDOUT: // CHECK:STDOUT: interface { -// CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.06d) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.472) = bind_symbolic_name Self, 2 [symbolic = %Self.2 (constants.%Self)] // CHECK:STDOUT: %IndexWith.At.decl: @IndexWith.%IndexWith.At.type (%IndexWith.At.type) = fn_decl @IndexWith.At [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At)] { -// CHECK:STDOUT: %self.patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.356) = binding_pattern self [concrete] -// CHECK:STDOUT: %self.param_patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.356) = value_param_pattern %self.patt, call_param0 [concrete] +// CHECK:STDOUT: %self.patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.a4e) = binding_pattern self [concrete] +// CHECK:STDOUT: %self.param_patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.a4e) = value_param_pattern %self.patt, call_param0 [concrete] // CHECK:STDOUT: %subscript.patt: @IndexWith.At.%pattern_type.loc5_21 (%pattern_type.7dc) = binding_pattern subscript [concrete] // CHECK:STDOUT: %subscript.param_patt: @IndexWith.At.%pattern_type.loc5_21 (%pattern_type.7dc) = value_param_pattern %subscript.patt, call_param1 [concrete] -// CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern [concrete] -// CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern %return.patt, call_param2 [concrete] +// CHECK:STDOUT: %return.patt: @IndexWith.At.%pattern_type.loc5_47 (%pattern_type.a32) = return_slot_pattern [concrete] +// CHECK:STDOUT: %return.param_patt: @IndexWith.At.%pattern_type.loc5_47 (%pattern_type.a32) = out_param_pattern %return.patt, call_param2 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc5_51.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc5_51.2: type = converted %.loc5_51.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, @IndexWith.%ElementType.loc4_43.2 [symbolic = %ElementType (constants.%ElementType)] // CHECK:STDOUT: %self.param: @IndexWith.At.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param call_param0 // CHECK:STDOUT: %.loc5_15.1: type = splice_block %.loc5_15.3 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] { -// CHECK:STDOUT: %.loc5_15.2: @IndexWith.At.%IndexWith.type (%IndexWith.type.06d) = specific_constant @IndexWith.%Self.1, @IndexWith(constants.%SubscriptType) [symbolic = %Self (constants.%Self)] -// CHECK:STDOUT: %Self.ref: @IndexWith.At.%IndexWith.type (%IndexWith.type.06d) = name_ref Self, %.loc5_15.2 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %.loc5_15.2: @IndexWith.At.%IndexWith.type (%IndexWith.type.472) = specific_constant @IndexWith.%Self.1, @IndexWith(constants.%SubscriptType, constants.%ElementType) [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %Self.ref: @IndexWith.At.%IndexWith.type (%IndexWith.type.472) = name_ref Self, %.loc5_15.2 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: %Self.as_type.loc5_15.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] // CHECK:STDOUT: %.loc5_15.3: type = converted %Self.ref, %Self.as_type.loc5_15.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] // CHECK:STDOUT: } @@ -225,76 +233,81 @@ fn F() { ()[()]; } // CHECK:STDOUT: %subscript.param: @IndexWith.At.%SubscriptType (%SubscriptType) = value_param call_param1 // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, @IndexWith.%SubscriptType.loc4_21.2 [symbolic = %SubscriptType (constants.%SubscriptType)] // CHECK:STDOUT: %subscript: @IndexWith.At.%SubscriptType (%SubscriptType) = bind_name subscript, %subscript.param -// CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param2 -// CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param +// CHECK:STDOUT: %return.param: ref @IndexWith.At.%ElementType (%ElementType) = out_param call_param2 +// CHECK:STDOUT: %return: ref @IndexWith.At.%ElementType (%ElementType) = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %assoc0.loc5_52.1: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_52.2 (constants.%assoc0)] +// CHECK:STDOUT: %assoc0.loc5_61.1: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_61.2 (constants.%assoc0)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self.1 // CHECK:STDOUT: .SubscriptType = -// CHECK:STDOUT: .At = %assoc0.loc5_52.1 +// CHECK:STDOUT: .ElementType = +// CHECK:STDOUT: .At = %assoc0.loc5_61.1 // CHECK:STDOUT: witness = (%IndexWith.At.decl) // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @IndexWith.At(@IndexWith.%SubscriptType.loc4_21.2: type, @IndexWith.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.06d)) { +// CHECK:STDOUT: generic fn @IndexWith.At(@IndexWith.%SubscriptType.loc4_21.2: type, @IndexWith.%ElementType.loc4_43.2: type, @IndexWith.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.472)) { // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)] -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.06d)] -// CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.06d) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)] +// CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.472)] +// CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.472) = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self)] // CHECK:STDOUT: %Self.as_type.loc5_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] -// CHECK:STDOUT: %pattern_type.loc5_9: type = pattern_type %Self.as_type.loc5_15.1 [symbolic = %pattern_type.loc5_9 (constants.%pattern_type.356)] +// CHECK:STDOUT: %pattern_type.loc5_9: type = pattern_type %Self.as_type.loc5_15.1 [symbolic = %pattern_type.loc5_9 (constants.%pattern_type.a4e)] // CHECK:STDOUT: %pattern_type.loc5_21: type = pattern_type %SubscriptType [symbolic = %pattern_type.loc5_21 (constants.%pattern_type.7dc)] +// CHECK:STDOUT: %pattern_type.loc5_47: type = pattern_type %ElementType [symbolic = %pattern_type.loc5_47 (constants.%pattern_type.a32)] // CHECK:STDOUT: -// CHECK:STDOUT: fn(%self.param: @IndexWith.At.%Self.as_type.loc5_15.1 (%Self.as_type), %subscript.param: @IndexWith.At.%SubscriptType (%SubscriptType)) -> %empty_tuple.type; +// CHECK:STDOUT: fn(%self.param: @IndexWith.At.%Self.as_type.loc5_15.1 (%Self.as_type), %subscript.param: @IndexWith.At.%SubscriptType (%SubscriptType)) -> @IndexWith.At.%ElementType (%ElementType); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType) { +// CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType, constants.%ElementType) { // CHECK:STDOUT: %SubscriptType.loc4_21.1 => constants.%SubscriptType +// CHECK:STDOUT: %ElementType.loc4_43.1 => constants.%ElementType // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%Self) { +// CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%ElementType, constants.%Self) { // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType -// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.06d +// CHECK:STDOUT: %ElementType => constants.%ElementType +// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.472 // CHECK:STDOUT: %Self => constants.%Self // CHECK:STDOUT: %Self.as_type.loc5_15.1 => constants.%Self.as_type -// CHECK:STDOUT: %pattern_type.loc5_9 => constants.%pattern_type.356 +// CHECK:STDOUT: %pattern_type.loc5_9 => constants.%pattern_type.a4e // CHECK:STDOUT: %pattern_type.loc5_21 => constants.%pattern_type.7dc +// CHECK:STDOUT: %pattern_type.loc5_47 => constants.%pattern_type.a32 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: --- wrong_arg_count.carbon +// CHECK:STDOUT: --- fail_wrong_arg_count.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete] // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete] +// CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic] // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic] -// CHECK:STDOUT: %IndexWith.type.e9b: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic] -// CHECK:STDOUT: %Self.c9a: %IndexWith.type.e9b = bind_symbolic_name Self, 1 [symbolic] -// CHECK:STDOUT: %IndexWith.At.type.cf4: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType) [symbolic] -// CHECK:STDOUT: %IndexWith.At.281: %IndexWith.At.type.cf4 = struct_value () [symbolic] -// CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete] -// CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.c9a [symbolic] -// CHECK:STDOUT: %pattern_type.853: type = pattern_type %Self.as_type [symbolic] +// CHECK:STDOUT: %IndexWith.type.433: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic] +// CHECK:STDOUT: %Self.0d0: %IndexWith.type.433 = bind_symbolic_name Self, 2 [symbolic] +// CHECK:STDOUT: %IndexWith.At.type.8ac: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType, %ElementType) [symbolic] +// CHECK:STDOUT: %IndexWith.At.7c9: %IndexWith.At.type.8ac = struct_value () [symbolic] +// CHECK:STDOUT: %pattern_type.a32: type = pattern_type %ElementType [symbolic] +// CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.0d0 [symbolic] +// CHECK:STDOUT: %pattern_type.51b: type = pattern_type %Self.as_type [symbolic] // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %SubscriptType [symbolic] -// CHECK:STDOUT: %IndexWith.assoc_type.290: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic] -// CHECK:STDOUT: %assoc0.af8: %IndexWith.assoc_type.290 = assoc_entity element0, imports.%Core.import_ref.e99 [symbolic] -// CHECK:STDOUT: %IndexWith.type.0f9: type = facet_type <@IndexWith, @IndexWith(%empty_tuple.type)> [concrete] -// CHECK:STDOUT: %Self.5e3: %IndexWith.type.0f9 = bind_symbolic_name Self, 1 [symbolic] -// CHECK:STDOUT: %IndexWith.At.type.969: type = fn_type @IndexWith.At, @IndexWith(%empty_tuple.type) [concrete] -// CHECK:STDOUT: %IndexWith.At.9b9: %IndexWith.At.type.969 = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.assoc_type.3d4: type = assoc_entity_type @IndexWith, @IndexWith(%empty_tuple.type) [concrete] -// CHECK:STDOUT: %assoc0.21b: %IndexWith.assoc_type.3d4 = assoc_entity element0, imports.%Core.import_ref.e99 [concrete] +// CHECK:STDOUT: %IndexWith.assoc_type.d60: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic] +// CHECK:STDOUT: %assoc0.b31: %IndexWith.assoc_type.d60 = assoc_entity element0, imports.%Core.import_ref.88c [symbolic] +// CHECK:STDOUT: %IndexWith.type.5ee: type = facet_type <@IndexWith, @IndexWith(%empty_tuple.type, %empty_tuple.type)> [concrete] +// CHECK:STDOUT: %Self.f42: %IndexWith.type.5ee = bind_symbolic_name Self, 2 [symbolic] +// CHECK:STDOUT: %IndexWith.At.type.1a9: type = fn_type @IndexWith.At, @IndexWith(%empty_tuple.type, %empty_tuple.type) [concrete] +// CHECK:STDOUT: %IndexWith.At.721: %IndexWith.At.type.1a9 = struct_value () [concrete] +// CHECK:STDOUT: %IndexWith.assoc_type.d10: type = assoc_entity_type @IndexWith, @IndexWith(%empty_tuple.type, %empty_tuple.type) [concrete] +// CHECK:STDOUT: %assoc0.239: %IndexWith.assoc_type.d10 = assoc_entity element0, imports.%Core.import_ref.88c [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness file.%IndexWith.impl_witness_table [concrete] +// CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete] // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.type: type = fn_type @empty_tuple.type.as.IndexWith.impl.At [concrete] // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At: %empty_tuple.type.as.IndexWith.impl.At.type = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.0f9 = facet_value %empty_tuple.type, (%IndexWith.impl_witness) [concrete] +// CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.5ee = facet_value %empty_tuple.type, (%IndexWith.impl_witness) [concrete] // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete] // CHECK:STDOUT: %F.type: type = fn_type @F [concrete] // CHECK:STDOUT: %F: %F.type = struct_value () [concrete] -// CHECK:STDOUT: %assoc0.e1e: %IndexWith.assoc_type.290 = assoc_entity element0, imports.%Core.import_ref.981 [symbolic] -// CHECK:STDOUT: %.8f5: type = fn_type_with_self_type %IndexWith.At.type.969, %IndexWith.facet [concrete] -// CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.bound: = bound_method %empty_tuple, %empty_tuple.type.as.IndexWith.impl.At [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -304,13 +317,14 @@ fn F() { ()[()]; } // CHECK:STDOUT: } // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//core_wrong_arg_count, IndexWith, loaded [concrete = constants.%IndexWith.generic] // CHECK:STDOUT: %Core.import_ref.5ab3ec.1: type = import_ref Core//core_wrong_arg_count, loc4_21, loaded [symbolic = @IndexWith.%SubscriptType (constants.%SubscriptType)] -// CHECK:STDOUT: %Core.import_ref.51b = import_ref Core//core_wrong_arg_count, inst28 [no loc], unloaded -// CHECK:STDOUT: %Core.import_ref.613: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.290) = import_ref Core//core_wrong_arg_count, loc5_52, loaded [symbolic = @IndexWith.%assoc0 (constants.%assoc0.e1e)] -// CHECK:STDOUT: %Core.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.cf4) = import_ref Core//core_wrong_arg_count, At, loaded [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At.281)] +// CHECK:STDOUT: %Core.import_ref.9483a2.1: type = import_ref Core//core_wrong_arg_count, loc4_43, loaded [symbolic = @IndexWith.%ElementType (constants.%ElementType)] +// CHECK:STDOUT: %Core.import_ref.e1e = import_ref Core//core_wrong_arg_count, inst33 [no loc], unloaded +// CHECK:STDOUT: %Core.import_ref.680 = import_ref Core//core_wrong_arg_count, loc5_61, unloaded +// CHECK:STDOUT: %Core.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.8ac) = import_ref Core//core_wrong_arg_count, At, loaded [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At.7c9)] // CHECK:STDOUT: %Core.import_ref.5ab3ec.2: type = import_ref Core//core_wrong_arg_count, loc4_21, loaded [symbolic = @IndexWith.%SubscriptType (constants.%SubscriptType)] -// CHECK:STDOUT: %Core.import_ref.341: @IndexWith.%IndexWith.type (%IndexWith.type.e9b) = import_ref Core//core_wrong_arg_count, inst28 [no loc], loaded [symbolic = @IndexWith.%Self (constants.%Self.c9a)] -// CHECK:STDOUT: %Core.import_ref.e99: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.cf4) = import_ref Core//core_wrong_arg_count, loc5_52, loaded [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At.281)] -// CHECK:STDOUT: %Core.import_ref.981 = import_ref Core//core_wrong_arg_count, loc5_52, unloaded +// CHECK:STDOUT: %Core.import_ref.9483a2.2: type = import_ref Core//core_wrong_arg_count, loc4_43, loaded [symbolic = @IndexWith.%ElementType (constants.%ElementType)] +// CHECK:STDOUT: %Core.import_ref.e58: @IndexWith.%IndexWith.type (%IndexWith.type.433) = import_ref Core//core_wrong_arg_count, inst33 [no loc], loaded [symbolic = @IndexWith.%Self (constants.%Self.0d0)] +// CHECK:STDOUT: %Core.import_ref.88c = import_ref Core//core_wrong_arg_count, loc5_61, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -325,29 +339,32 @@ fn F() { ()[()]; } // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic] // CHECK:STDOUT: %.loc6_28: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc6_29: type = converted %.loc6_28, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%empty_tuple.type)> [concrete = constants.%IndexWith.type.0f9] +// CHECK:STDOUT: %.loc6_32: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_33.1: type = converted %.loc6_28, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %.loc6_33.2: type = converted %.loc6_32, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%empty_tuple.type, constants.%empty_tuple.type)> [concrete = constants.%IndexWith.type.5ee] // CHECK:STDOUT: } // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@empty_tuple.type.as.IndexWith.impl.%empty_tuple.type.as.IndexWith.impl.At.decl), @empty_tuple.type.as.IndexWith.impl [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness] // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic interface @IndexWith(imports.%Core.import_ref.5ab3ec.1: type) [from "core_wrong_arg_count.carbon"] { +// CHECK:STDOUT: generic interface @IndexWith(imports.%Core.import_ref.5ab3ec.1: type, imports.%Core.import_ref.9483a2.1: type) [from "core_wrong_arg_count.carbon"] { // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)] +// CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.e9b)] -// CHECK:STDOUT: %Self: @IndexWith.%IndexWith.type (%IndexWith.type.e9b) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.c9a)] -// CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type.cf4)] -// CHECK:STDOUT: %IndexWith.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.cf4) = struct_value () [symbolic = %IndexWith.At (constants.%IndexWith.At.281)] -// CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type.290)] -// CHECK:STDOUT: %assoc0: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.290) = assoc_entity element0, imports.%Core.import_ref.e99 [symbolic = %assoc0 (constants.%assoc0.af8)] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.433)] +// CHECK:STDOUT: %Self: @IndexWith.%IndexWith.type (%IndexWith.type.433) = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.0d0)] +// CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type.8ac)] +// CHECK:STDOUT: %IndexWith.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.8ac) = struct_value () [symbolic = %IndexWith.At (constants.%IndexWith.At.7c9)] +// CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type.d60)] +// CHECK:STDOUT: %assoc0: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.d60) = assoc_entity element0, imports.%Core.import_ref.88c [symbolic = %assoc0 (constants.%assoc0.b31)] // CHECK:STDOUT: // CHECK:STDOUT: interface { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%Core.import_ref.51b -// CHECK:STDOUT: .At = imports.%Core.import_ref.613 +// CHECK:STDOUT: .Self = imports.%Core.import_ref.e1e +// CHECK:STDOUT: .At = imports.%Core.import_ref.680 // CHECK:STDOUT: witness = (imports.%Core.At) // CHECK:STDOUT: } // CHECK:STDOUT: } @@ -381,13 +398,15 @@ fn F() { ()[()]; } // CHECK:STDOUT: witness = file.%IndexWith.impl_witness // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @IndexWith.At(imports.%Core.import_ref.5ab3ec.2: type, imports.%Core.import_ref.341: @IndexWith.%IndexWith.type (%IndexWith.type.e9b)) [from "core_wrong_arg_count.carbon"] { +// CHECK:STDOUT: generic fn @IndexWith.At(imports.%Core.import_ref.5ab3ec.2: type, imports.%Core.import_ref.9483a2.2: type, imports.%Core.import_ref.e58: @IndexWith.%IndexWith.type (%IndexWith.type.433)) [from "core_wrong_arg_count.carbon"] { // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)] -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.e9b)] -// CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.e9b) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.c9a)] +// CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.433)] +// CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.433) = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.0d0)] // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type)] -// CHECK:STDOUT: %pattern_type.1: type = pattern_type %Self.as_type [symbolic = %pattern_type.1 (constants.%pattern_type.853)] +// CHECK:STDOUT: %pattern_type.1: type = pattern_type %Self.as_type [symbolic = %pattern_type.1 (constants.%pattern_type.51b)] // CHECK:STDOUT: %pattern_type.2: type = pattern_type %SubscriptType [symbolic = %pattern_type.2 (constants.%pattern_type.7dc)] +// CHECK:STDOUT: %pattern_type.3: type = pattern_type %ElementType [symbolic = %pattern_type.3 (constants.%pattern_type.a32)] // CHECK:STDOUT: // CHECK:STDOUT: fn; // CHECK:STDOUT: } @@ -402,49 +421,50 @@ fn F() { ()[()]; } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc12_11.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc12_14: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %empty_tuple.loc12_11: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = converted %.loc12_11.1, %empty_tuple.loc12_11 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %empty_tuple.loc12_14: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc12_15: %empty_tuple.type = converted %.loc12_14, %empty_tuple.loc12_14 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %impl.elem0: %.8f5 = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%empty_tuple.type.as.IndexWith.impl.At] -// CHECK:STDOUT: %bound_method: = bound_method %.loc12_11.2, %impl.elem0 [concrete = constants.%empty_tuple.type.as.IndexWith.impl.At.bound] -// CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.call: init %empty_tuple.type = call %bound_method(%.loc12_11.2, %.loc12_15) +// CHECK:STDOUT: %.loc20_11.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc20_14: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc20_11.2: %empty_tuple.type = converted %.loc20_11.1, %empty_tuple [concrete = constants.%empty_tuple] // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType) { +// CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType, constants.%ElementType) { // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType +// CHECK:STDOUT: %ElementType => constants.%ElementType // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%Self.c9a) { +// CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%ElementType, constants.%Self.0d0) { // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType -// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.e9b -// CHECK:STDOUT: %Self => constants.%Self.c9a +// CHECK:STDOUT: %ElementType => constants.%ElementType +// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.433 +// CHECK:STDOUT: %Self => constants.%Self.0d0 // CHECK:STDOUT: %Self.as_type => constants.%Self.as_type -// CHECK:STDOUT: %pattern_type.1 => constants.%pattern_type.853 +// CHECK:STDOUT: %pattern_type.1 => constants.%pattern_type.51b // CHECK:STDOUT: %pattern_type.2 => constants.%pattern_type.7dc +// CHECK:STDOUT: %pattern_type.3 => constants.%pattern_type.a32 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @IndexWith(constants.%empty_tuple.type) { +// CHECK:STDOUT: specific @IndexWith(constants.%empty_tuple.type, constants.%empty_tuple.type) { // CHECK:STDOUT: %SubscriptType => constants.%empty_tuple.type +// CHECK:STDOUT: %ElementType => constants.%empty_tuple.type // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.0f9 -// CHECK:STDOUT: %Self => constants.%Self.5e3 -// CHECK:STDOUT: %IndexWith.At.type => constants.%IndexWith.At.type.969 -// CHECK:STDOUT: %IndexWith.At => constants.%IndexWith.At.9b9 -// CHECK:STDOUT: %IndexWith.assoc_type => constants.%IndexWith.assoc_type.3d4 -// CHECK:STDOUT: %assoc0 => constants.%assoc0.21b +// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.5ee +// CHECK:STDOUT: %Self => constants.%Self.f42 +// CHECK:STDOUT: %IndexWith.At.type => constants.%IndexWith.At.type.1a9 +// CHECK:STDOUT: %IndexWith.At => constants.%IndexWith.At.721 +// CHECK:STDOUT: %IndexWith.assoc_type => constants.%IndexWith.assoc_type.d10 +// CHECK:STDOUT: %assoc0 => constants.%assoc0.239 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @IndexWith.At(constants.%empty_tuple.type, constants.%IndexWith.facet) { +// CHECK:STDOUT: specific @IndexWith.At(constants.%empty_tuple.type, constants.%empty_tuple.type, constants.%IndexWith.facet) { // CHECK:STDOUT: %SubscriptType => constants.%empty_tuple.type -// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.0f9 +// CHECK:STDOUT: %ElementType => constants.%empty_tuple.type +// CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.5ee // CHECK:STDOUT: %Self => constants.%IndexWith.facet // CHECK:STDOUT: %Self.as_type => constants.%empty_tuple.type // CHECK:STDOUT: %pattern_type.1 => constants.%pattern_type.cb1 // CHECK:STDOUT: %pattern_type.2 => constants.%pattern_type.cb1 +// CHECK:STDOUT: %pattern_type.3 => constants.%pattern_type.cb1 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/overloaded/index_with_prelude.carbon b/toolchain/check/testdata/operators/overloaded/index_with_prelude.carbon index 15b5d8b7e869..f7192307a2ac 100644 --- a/toolchain/check/testdata/operators/overloaded/index_with_prelude.carbon +++ b/toolchain/check/testdata/operators/overloaded/index_with_prelude.carbon @@ -20,7 +20,7 @@ class C {} class ElementType {} class SubscriptType {} -impl C as Core.IndexWith(SubscriptType, ElementType) { +impl C as Core.IndexWith(SubscriptType) where .ElementType = ElementType { fn At[self: Self](subscript: SubscriptType) -> ElementType { return {}; } @@ -34,8 +34,8 @@ let x: ElementType = c[s]; library "[[@TEST_NAME]]"; -impl (i32, i32) as Core.IndexWith(i32, i32) { - fn At[self: Self](subscript: i32) -> i32 { +impl (i32, i32) as Core.IndexWith(Core.IntLiteral()) where .ElementType = i32 { + fn At[self: Self](subscript: Core.IntLiteral()) -> i32 { return self.0; } } @@ -51,17 +51,14 @@ class C { } class ElementType {} class SubscriptType {} -impl C as Core.IndexWith(SubscriptType, ElementType) { +impl C as Core.IndexWith(SubscriptType) where .ElementType = ElementType { fn At[self: Self](subscript: SubscriptType) -> ElementType { return {}; } } let c: C = {}; -// CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+7]]:22: error: cannot implicitly convert expression of type `Core.IntLiteral` to `SubscriptType` [ConversionFailure] -// CHECK:STDERR: let x: ElementType = c[0]; -// CHECK:STDERR: ^~~~ -// CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+4]]:22: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(SubscriptType)` [MissingImplInMemberAccessNote] +// CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+4]]:22: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `C` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: let x: ElementType = c[0]; // CHECK:STDERR: ^~~~ // CHECK:STDERR: @@ -74,7 +71,7 @@ library "[[@TEST_NAME]]"; class C { } let c: C = {}; -// CHECK:STDERR: fail_index_with_not_implemented.carbon:[[@LINE+4]]:14: error: type `C` does not support indexing [TypeNotIndexable] +// CHECK:STDERR: fail_index_with_not_implemented.carbon:[[@LINE+4]]:14: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `C` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: let x: i32 = c[0]; // CHECK:STDERR: ^~~~ // CHECK:STDERR: @@ -87,23 +84,33 @@ let x: i32 = c[0]; // CHECK:STDOUT: %C: type = class_type @C [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %ElementType.e6b: type = class_type @ElementType [concrete] +// CHECK:STDOUT: %ElementType: type = class_type @ElementType.loc5 [concrete] // CHECK:STDOUT: %SubscriptType.8ee: type = class_type @SubscriptType [concrete] // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete] // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.type.191: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee, %ElementType.e6b)> [concrete] -// CHECK:STDOUT: %IndexWith.At.type.b3f: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType.8ee, %ElementType.e6b) [concrete] +// CHECK:STDOUT: %SubscriptType.8b3: type = bind_symbolic_name SubscriptType, 0 [symbolic] +// CHECK:STDOUT: %IndexWith.assoc_type.290: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.8b3) [symbolic] +// CHECK:STDOUT: %IndexWith.type.d2d: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee)> [concrete] +// CHECK:STDOUT: %.Self: %IndexWith.type.d2d = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %IndexWith.assoc_type.f8f: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.8ee) [concrete] +// CHECK:STDOUT: %assoc0.a51: %IndexWith.assoc_type.f8f = assoc_entity element0, imports.%Core.import_ref.156 [concrete] +// CHECK:STDOUT: %IndexWith.At.type.caa: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType.8ee) [concrete] +// CHECK:STDOUT: %assoc0.daf: %IndexWith.assoc_type.290 = assoc_entity element0, imports.%Core.import_ref.6c8 [symbolic] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %IndexWith.lookup_impl_witness.0ce: = lookup_impl_witness %.Self, @IndexWith, @IndexWith(%SubscriptType.8ee) [symbolic_self] +// CHECK:STDOUT: %impl.elem0.859: type = impl_witness_access %IndexWith.lookup_impl_witness.0ce, element0 [symbolic_self] +// CHECK:STDOUT: %IndexWith_where.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee) where %impl.elem0.859 = %ElementType> [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness file.%IndexWith.impl_witness_table [concrete] // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete] // CHECK:STDOUT: %pattern_type.df7: type = pattern_type %SubscriptType.8ee [concrete] -// CHECK:STDOUT: %pattern_type.c39: type = pattern_type %ElementType.e6b [concrete] +// CHECK:STDOUT: %pattern_type.c39: type = pattern_type %ElementType [concrete] // CHECK:STDOUT: %C.as.IndexWith.impl.At.type: type = fn_type @C.as.IndexWith.impl.At [concrete] // CHECK:STDOUT: %C.as.IndexWith.impl.At: %C.as.IndexWith.impl.At.type = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.191 = facet_value %C, (%IndexWith.impl_witness) [concrete] -// CHECK:STDOUT: %ElementType.val: %ElementType.e6b = struct_value () [concrete] +// CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.d2d = facet_value %C, (%IndexWith.impl_witness) [concrete] +// CHECK:STDOUT: %ElementType.val: %ElementType = struct_value () [concrete] // CHECK:STDOUT: %SubscriptType.val: %SubscriptType.8ee = struct_value () [concrete] // CHECK:STDOUT: %C.val: %C = struct_value () [concrete] -// CHECK:STDOUT: %.ae1: type = fn_type_with_self_type %IndexWith.At.type.b3f, %IndexWith.facet [concrete] +// CHECK:STDOUT: %.815: type = fn_type_with_self_type %IndexWith.At.type.caa, %IndexWith.facet [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -113,6 +120,10 @@ let x: i32 = c[0]; // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic] +// CHECK:STDOUT: %Core.import_ref.c50: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.290) = import_ref Core//prelude/operators/index, loc8_18, loaded [symbolic = @IndexWith.%assoc0 (constants.%assoc0.daf)] +// CHECK:STDOUT: %Core.import_ref.156: type = import_ref Core//prelude/operators/index, loc8_18, loaded [concrete = %ElementType] +// CHECK:STDOUT: %Core.import_ref.6c8 = import_ref Core//prelude/operators/index, loc8_18, unloaded +// CHECK:STDOUT: %ElementType: type = assoc_const_decl @ElementType.1 [concrete] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -127,18 +138,30 @@ let x: i32 = c[0]; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [concrete = constants.%ElementType.e6b] {} {} +// CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType.loc5 [concrete = constants.%ElementType] {} {} // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [concrete = constants.%SubscriptType.8ee] {} {} // CHECK:STDOUT: impl_decl @C.as.IndexWith.impl [concrete] {} { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic] // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee] -// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b] -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [concrete = constants.%IndexWith.type.191] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee)> [concrete = constants.%IndexWith.type.d2d] +// CHECK:STDOUT: %.Self: %IndexWith.type.d2d = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %IndexWith.type.d2d = name_ref .Self, %.Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.loc8_47.1: %IndexWith.assoc_type.f8f = specific_constant imports.%Core.import_ref.c50, @IndexWith(constants.%SubscriptType.8ee) [concrete = constants.%assoc0.a51] +// CHECK:STDOUT: %ElementType.ref.loc8_47: %IndexWith.assoc_type.f8f = name_ref ElementType, %.loc8_47.1 [concrete = constants.%assoc0.a51] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc8_47.2: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%IndexWith.lookup_impl_witness.0ce, element0 [symbolic_self = constants.%impl.elem0.859] +// CHECK:STDOUT: %ElementType.ref.loc8_62: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType] +// CHECK:STDOUT: %.loc8_41: type = where_expr %.Self [concrete = constants.%IndexWith_where.type] { +// CHECK:STDOUT: requirement_base_facet_type constants.%IndexWith.type.d2d +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %ElementType.ref.loc8_62 +// CHECK:STDOUT: } // CHECK:STDOUT: } -// CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@C.as.IndexWith.impl.%C.as.IndexWith.impl.At.decl), @C.as.IndexWith.impl [concrete] +// CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (%impl_witness_assoc_constant, @C.as.IndexWith.impl.%C.as.IndexWith.impl.At.decl), @C.as.IndexWith.impl [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness] +// CHECK:STDOUT: %impl_witness_assoc_constant: type = impl_witness_assoc_constant constants.%ElementType [concrete = constants.%ElementType] // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %s.patt: %pattern_type.df7 = binding_pattern s [concrete] // CHECK:STDOUT: } @@ -162,13 +185,13 @@ let x: i32 = c[0]; // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %x.patt: %pattern_type.c39 = binding_pattern x [concrete] // CHECK:STDOUT: } -// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType.e6b] -// CHECK:STDOUT: %.loc16_25.1: ref %ElementType.e6b = temporary @__global_init.%.loc16, @__global_init.%C.as.IndexWith.impl.At.call -// CHECK:STDOUT: %.loc16_25.2: %ElementType.e6b = bind_value %.loc16_25.1 -// CHECK:STDOUT: %x: %ElementType.e6b = bind_name x, %.loc16_25.2 +// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType] +// CHECK:STDOUT: %.loc16_25.1: ref %ElementType = temporary @__global_init.%.loc16, @__global_init.%C.as.IndexWith.impl.At.call +// CHECK:STDOUT: %.loc16_25.2: %ElementType = bind_value %.loc16_25.1 +// CHECK:STDOUT: %x: %ElementType = bind_name x, %.loc16_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @C.as.IndexWith.impl: %C.ref as %IndexWith.type { +// CHECK:STDOUT: impl @C.as.IndexWith.impl: %C.ref as %.loc8_41 { // CHECK:STDOUT: %C.as.IndexWith.impl.At.decl: %C.as.IndexWith.impl.At.type = fn_decl @C.as.IndexWith.impl.At [concrete = constants.%C.as.IndexWith.impl.At] { // CHECK:STDOUT: %self.patt: %pattern_type.c48 = binding_pattern self [concrete] // CHECK:STDOUT: %self.param_patt: %pattern_type.c48 = value_param_pattern %self.patt, call_param0 [concrete] @@ -177,15 +200,15 @@ let x: i32 = c[0]; // CHECK:STDOUT: %return.patt: %pattern_type.c39 = return_slot_pattern [concrete] // CHECK:STDOUT: %return.param_patt: %pattern_type.c39 = out_param_pattern %return.patt, call_param2 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b] +// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType] // CHECK:STDOUT: %self.param: %C = value_param call_param0 // CHECK:STDOUT: %Self.ref: type = name_ref Self, @C.as.IndexWith.impl.%C.ref [concrete = constants.%C] // CHECK:STDOUT: %self: %C = bind_name self, %self.param // CHECK:STDOUT: %subscript.param: %SubscriptType.8ee = value_param call_param1 // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee] // CHECK:STDOUT: %subscript: %SubscriptType.8ee = bind_name subscript, %subscript.param -// CHECK:STDOUT: %return.param: ref %ElementType.e6b = out_param call_param2 -// CHECK:STDOUT: %return: ref %ElementType.e6b = return_slot %return.param +// CHECK:STDOUT: %return.param: ref %ElementType = out_param call_param2 +// CHECK:STDOUT: %return: ref %ElementType = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -203,12 +226,12 @@ let x: i32 = c[0]; // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @ElementType { +// CHECK:STDOUT: class @ElementType.loc5 { // CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%ElementType.e6b +// CHECK:STDOUT: .Self = constants.%ElementType // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @SubscriptType { @@ -219,11 +242,11 @@ let x: i32 = c[0]; // CHECK:STDOUT: .Self = constants.%SubscriptType.8ee // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.IndexWith.impl.At(%self.param: %C, %subscript.param: %SubscriptType.8ee) -> %return.param: %ElementType.e6b { +// CHECK:STDOUT: fn @C.as.IndexWith.impl.At(%self.param: %C, %subscript.param: %SubscriptType.8ee) -> %return.param: %ElementType { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc10_13.2: init %ElementType.e6b = class_init (), %return [concrete = constants.%ElementType.val] -// CHECK:STDOUT: %.loc10_14: init %ElementType.e6b = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val] +// CHECK:STDOUT: %.loc10_13.2: init %ElementType = class_init (), %return [concrete = constants.%ElementType.val] +// CHECK:STDOUT: %.loc10_14: init %ElementType = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val] // CHECK:STDOUT: return %.loc10_14 to %return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -233,10 +256,10 @@ let x: i32 = c[0]; // CHECK:STDOUT: %.loc15: %empty_struct_type = struct_literal () // CHECK:STDOUT: %c.ref: %C = name_ref c, file.%c // CHECK:STDOUT: %s.ref: %SubscriptType.8ee = name_ref s, file.%s -// CHECK:STDOUT: %impl.elem0: %.ae1 = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%C.as.IndexWith.impl.At] -// CHECK:STDOUT: %bound_method: = bound_method %c.ref, %impl.elem0 -// CHECK:STDOUT: %.loc16: ref %ElementType.e6b = temporary_storage -// CHECK:STDOUT: %C.as.IndexWith.impl.At.call: init %ElementType.e6b = call %bound_method(%c.ref, %s.ref) to %.loc16 +// CHECK:STDOUT: %impl.elem1: %.815 = impl_witness_access constants.%IndexWith.impl_witness, element1 [concrete = constants.%C.as.IndexWith.impl.At] +// CHECK:STDOUT: %bound_method: = bound_method %c.ref, %impl.elem1 +// CHECK:STDOUT: %.loc16: ref %ElementType = temporary_storage +// CHECK:STDOUT: %C.as.IndexWith.impl.At.call: init %ElementType = call %bound_method(%c.ref, %s.ref) to %.loc16 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -247,20 +270,33 @@ let x: i32 = c[0]; // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete] // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete] // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic] +// CHECK:STDOUT: %pattern_type.dc0: type = pattern_type Core.IntLiteral [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete] // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete] // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete] // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.type.9ed: type = facet_type <@IndexWith, @IndexWith(%i32, %i32)> [concrete] -// CHECK:STDOUT: %IndexWith.At.type.d77: type = fn_type @IndexWith.At, @IndexWith(%i32, %i32) [concrete] +// CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic] +// CHECK:STDOUT: %IndexWith.assoc_type.290: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic] +// CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [concrete] +// CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [concrete] +// CHECK:STDOUT: %IndexWith.type.8ab: type = facet_type <@IndexWith, @IndexWith(Core.IntLiteral)> [concrete] +// CHECK:STDOUT: %.Self: %IndexWith.type.8ab = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %IndexWith.assoc_type.972: type = assoc_entity_type @IndexWith, @IndexWith(Core.IntLiteral) [concrete] +// CHECK:STDOUT: %assoc0.b5d: %IndexWith.assoc_type.972 = assoc_entity element0, imports.%Core.import_ref.156 [concrete] +// CHECK:STDOUT: %IndexWith.At.type.1ab: type = fn_type @IndexWith.At, @IndexWith(Core.IntLiteral) [concrete] +// CHECK:STDOUT: %assoc0.daf: %IndexWith.assoc_type.290 = assoc_entity element0, imports.%Core.import_ref.6c8 [symbolic] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %IndexWith.lookup_impl_witness.f46: = lookup_impl_witness %.Self, @IndexWith, @IndexWith(Core.IntLiteral) [symbolic_self] +// CHECK:STDOUT: %impl.elem0.87a: type = impl_witness_access %IndexWith.lookup_impl_witness.f46, element0 [symbolic_self] +// CHECK:STDOUT: %IndexWith_where.type: type = facet_type <@IndexWith, @IndexWith(Core.IntLiteral) where %impl.elem0.87a = %i32> [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness file.%IndexWith.impl_witness_table [concrete] // CHECK:STDOUT: %pattern_type.511: type = pattern_type %tuple.type.d07 [concrete] // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete] // CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At.type: type = fn_type @tuple.type.as.IndexWith.impl.At [concrete] // CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At: %tuple.type.as.IndexWith.impl.At.type = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.9ed = facet_value %tuple.type.d07, (%IndexWith.impl_witness) [concrete] -// CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete] +// CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.8ab = facet_value %tuple.type.d07, (%IndexWith.impl_witness) [concrete] +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete] // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete] // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete] // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.afd: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic] @@ -294,16 +330,14 @@ let x: i32 = c[0]; // CHECK:STDOUT: %bound_method.724: = bound_method %int_5.64b, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [concrete] // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_1.5d2, %int_5.0f6) [concrete] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.931: = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0 [concrete] -// CHECK:STDOUT: %bound_method.c25: = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete] -// CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete] -// CHECK:STDOUT: %.af7: type = fn_type_with_self_type %IndexWith.At.type.d77, %IndexWith.facet [concrete] +// CHECK:STDOUT: %.2e9: type = fn_type_with_self_type %IndexWith.At.type.1ab, %IndexWith.facet [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { // CHECK:STDOUT: .Int = %Core.Int // CHECK:STDOUT: .IndexWith = %Core.IndexWith +// CHECK:STDOUT: .IntLiteral = %Core.IntLiteral // CHECK:STDOUT: .Copy = %Core.Copy // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs // CHECK:STDOUT: import Core//prelude @@ -311,6 +345,11 @@ let x: i32 = c[0]; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic] // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic] +// CHECK:STDOUT: %Core.import_ref.c50: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.290) = import_ref Core//prelude/operators/index, loc8_18, loaded [symbolic = @IndexWith.%assoc0 (constants.%assoc0.daf)] +// CHECK:STDOUT: %Core.import_ref.156: type = import_ref Core//prelude/operators/index, loc8_18, loaded [concrete = %ElementType] +// CHECK:STDOUT: %Core.IntLiteral: %IntLiteral.type = import_ref Core//prelude/types/int_literal, IntLiteral, loaded [concrete = constants.%IntLiteral] +// CHECK:STDOUT: %Core.import_ref.6c8 = import_ref Core//prelude/operators/index, loc8_18, unloaded +// CHECK:STDOUT: %ElementType: type = assoc_const_decl @ElementType [concrete] {} // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/copy, Copy, loaded [concrete = constants.%Copy.type] // CHECK:STDOUT: %Core.import_ref.d0f6: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.afd) = import_ref Core//prelude/types/int, loc21_31, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.6cd)] // CHECK:STDOUT: %Copy.impl_witness_table.1ed = impl_witness_table (%Core.import_ref.d0f6), @Int.as.Copy.impl [concrete] @@ -333,16 +372,31 @@ let x: i32 = c[0]; // CHECK:STDOUT: %i32.loc4_12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %.loc4_15.1: %tuple.type.24b = tuple_literal (%i32.loc4_7, %i32.loc4_12) // CHECK:STDOUT: %.loc4_15.2: type = converted %.loc4_15.1, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07] -// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %Core.ref.loc4_20: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic] -// CHECK:STDOUT: %int_32.loc4_35: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc4_35: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %int_32.loc4_40: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc4_40: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%i32, constants.%i32)> [concrete = constants.%IndexWith.type.9ed] +// CHECK:STDOUT: %Core.ref.loc4_35: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [concrete = constants.%IntLiteral] +// CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc4_52.1: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc4_52.2: type = converted %IntLiteral.call, %.loc4_52.1 [concrete = Core.IntLiteral] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(Core.IntLiteral)> [concrete = constants.%IndexWith.type.8ab] +// CHECK:STDOUT: %.Self: %IndexWith.type.8ab = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %IndexWith.type.8ab = name_ref .Self, %.Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.loc4_60.1: %IndexWith.assoc_type.972 = specific_constant imports.%Core.import_ref.c50, @IndexWith(Core.IntLiteral) [concrete = constants.%assoc0.b5d] +// CHECK:STDOUT: %ElementType.ref: %IndexWith.assoc_type.972 = name_ref ElementType, %.loc4_60.1 [concrete = constants.%assoc0.b5d] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc4_60.2: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%IndexWith.lookup_impl_witness.f46, element0 [symbolic_self = constants.%impl.elem0.87a] +// CHECK:STDOUT: %int_32.loc4_75: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc4_75: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %.loc4_54: type = where_expr %.Self [concrete = constants.%IndexWith_where.type] { +// CHECK:STDOUT: requirement_base_facet_type constants.%IndexWith.type.8ab +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %i32.loc4_75 +// CHECK:STDOUT: } // CHECK:STDOUT: } -// CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@tuple.type.as.IndexWith.impl.%tuple.type.as.IndexWith.impl.At.decl), @tuple.type.as.IndexWith.impl [concrete] +// CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (%impl_witness_assoc_constant, @tuple.type.as.IndexWith.impl.%tuple.type.as.IndexWith.impl.At.decl), @tuple.type.as.IndexWith.impl [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness] +// CHECK:STDOUT: %impl_witness_assoc_constant: type = impl_witness_assoc_constant constants.%i32 [concrete = constants.%i32] // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %s.patt: %pattern_type.511 = binding_pattern s [concrete] // CHECK:STDOUT: } @@ -383,26 +437,29 @@ let x: i32 = c[0]; // CHECK:STDOUT: %e: %i32 = bind_name e, %.loc11_17.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @tuple.type.as.IndexWith.impl: %.loc4_15.2 as %IndexWith.type { +// CHECK:STDOUT: impl @tuple.type.as.IndexWith.impl: %.loc4_15.2 as %.loc4_54 { // CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At.decl: %tuple.type.as.IndexWith.impl.At.type = fn_decl @tuple.type.as.IndexWith.impl.At [concrete = constants.%tuple.type.as.IndexWith.impl.At] { // CHECK:STDOUT: %self.patt: %pattern_type.511 = binding_pattern self [concrete] // CHECK:STDOUT: %self.param_patt: %pattern_type.511 = value_param_pattern %self.patt, call_param0 [concrete] -// CHECK:STDOUT: %subscript.patt: %pattern_type.7ce = binding_pattern subscript [concrete] -// CHECK:STDOUT: %subscript.param_patt: %pattern_type.7ce = value_param_pattern %subscript.patt, call_param1 [concrete] +// CHECK:STDOUT: %subscript.patt: %pattern_type.dc0 = binding_pattern subscript [concrete] +// CHECK:STDOUT: %subscript.param_patt: %pattern_type.dc0 = value_param_pattern %subscript.patt, call_param1 [concrete] // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete] // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param2 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %int_32.loc5_40: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc5_40: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] // CHECK:STDOUT: %self.param: %tuple.type.d07 = value_param call_param0 // CHECK:STDOUT: %Self.ref: type = name_ref Self, @tuple.type.as.IndexWith.impl.%.loc4_15.2 [concrete = constants.%tuple.type.d07] // CHECK:STDOUT: %self: %tuple.type.d07 = bind_name self, %self.param -// CHECK:STDOUT: %subscript.param: %i32 = value_param call_param1 -// CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5_32 [concrete = constants.%i32] { -// CHECK:STDOUT: %int_32.loc5_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] -// CHECK:STDOUT: %i32.loc5_32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %subscript.param: Core.IntLiteral = value_param call_param1 +// CHECK:STDOUT: %.loc5_48.1: type = splice_block %.loc5_48.3 [concrete = Core.IntLiteral] { +// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] +// CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [concrete = constants.%IntLiteral] +// CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc5_48.2: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral] +// CHECK:STDOUT: %.loc5_48.3: type = converted %IntLiteral.call, %.loc5_48.2 [concrete = Core.IntLiteral] // CHECK:STDOUT: } -// CHECK:STDOUT: %subscript: %i32 = bind_name subscript, %subscript.param +// CHECK:STDOUT: %subscript: Core.IntLiteral = bind_name subscript, %subscript.param // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2 // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } @@ -412,10 +469,10 @@ let x: i32 = c[0]; // CHECK:STDOUT: witness = file.%IndexWith.impl_witness // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @tuple.type.as.IndexWith.impl.At(%self.param: %tuple.type.d07, %subscript.param: %i32) -> %i32 { +// CHECK:STDOUT: fn @tuple.type.as.IndexWith.impl.At(%self.param: %tuple.type.d07, %subscript.param: Core.IntLiteral) -> %i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %self.ref: %tuple.type.d07 = name_ref self, %self -// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] // CHECK:STDOUT: %tuple.elem0: %i32 = tuple_access %self.ref, element0 // CHECK:STDOUT: %impl.elem0: %.7fa = impl_witness_access constants.%Copy.impl_witness.a32, element0 [concrete = constants.%Int.as.Copy.impl.Op.f59] // CHECK:STDOUT: %bound_method.loc6_16.1: = bound_method %tuple.elem0, %impl.elem0 @@ -431,17 +488,10 @@ let x: i32 = c[0]; // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b] // CHECK:STDOUT: %.loc10: %tuple.type.f94 = tuple_literal (%int_1, %int_5) // CHECK:STDOUT: %s.ref: %tuple.type.d07 = name_ref s, file.%s -// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %impl.elem0.loc11_17.1: %.1df = impl_witness_access constants.%ImplicitAs.impl_witness.204, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0] -// CHECK:STDOUT: %bound_method.loc11_17.1: = bound_method %int_0, %impl.elem0.loc11_17.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.931] -// CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0.loc11_17.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc11_17.2: = bound_method %int_0, %specific_fn [concrete = constants.%bound_method.c25] -// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc11_17.2(%int_0) [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc11_17.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %.loc11_17.2: %i32 = converted %int_0, %.loc11_17.1 [concrete = constants.%int_0.6a9] -// CHECK:STDOUT: %impl.elem0.loc11_17.2: %.af7 = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%tuple.type.as.IndexWith.impl.At] -// CHECK:STDOUT: %bound_method.loc11_17.3: = bound_method %s.ref, %impl.elem0.loc11_17.2 -// CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At.call: init %i32 = call %bound_method.loc11_17.3(%s.ref, %.loc11_17.2) +// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] +// CHECK:STDOUT: %impl.elem1: %.2e9 = impl_witness_access constants.%IndexWith.impl_witness, element1 [concrete = constants.%tuple.type.as.IndexWith.impl.At] +// CHECK:STDOUT: %bound_method: = bound_method %s.ref, %impl.elem1 +// CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At.call: init %i32 = call %bound_method(%s.ref, %int_0) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -451,36 +501,43 @@ let x: i32 = c[0]; // CHECK:STDOUT: %C: type = class_type @C [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %ElementType.e6b: type = class_type @ElementType [concrete] +// CHECK:STDOUT: %ElementType: type = class_type @ElementType.loc5 [concrete] // CHECK:STDOUT: %SubscriptType.8ee: type = class_type @SubscriptType [concrete] // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete] // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.type.191: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee, %ElementType.e6b)> [concrete] -// CHECK:STDOUT: %IndexWith.At.type.b3f: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType.8ee, %ElementType.e6b) [concrete] +// CHECK:STDOUT: %SubscriptType.8b3: type = bind_symbolic_name SubscriptType, 0 [symbolic] +// CHECK:STDOUT: %IndexWith.assoc_type.290: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.8b3) [symbolic] +// CHECK:STDOUT: %IndexWith.type.d2d: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee)> [concrete] +// CHECK:STDOUT: %.Self: %IndexWith.type.d2d = bind_symbolic_name .Self [symbolic_self] +// CHECK:STDOUT: %IndexWith.assoc_type.f8f: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.8ee) [concrete] +// CHECK:STDOUT: %assoc0.a51: %IndexWith.assoc_type.f8f = assoc_entity element0, imports.%Core.import_ref.156 [concrete] +// CHECK:STDOUT: %assoc0.daf: %IndexWith.assoc_type.290 = assoc_entity element0, imports.%Core.import_ref.6c8 [symbolic] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self] +// CHECK:STDOUT: %IndexWith.lookup_impl_witness.0ce: = lookup_impl_witness %.Self, @IndexWith, @IndexWith(%SubscriptType.8ee) [symbolic_self] +// CHECK:STDOUT: %impl.elem0.859: type = impl_witness_access %IndexWith.lookup_impl_witness.0ce, element0 [symbolic_self] +// CHECK:STDOUT: %IndexWith_where.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee) where %impl.elem0.859 = %ElementType> [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness file.%IndexWith.impl_witness_table [concrete] // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete] // CHECK:STDOUT: %pattern_type.df7: type = pattern_type %SubscriptType.8ee [concrete] -// CHECK:STDOUT: %pattern_type.c39: type = pattern_type %ElementType.e6b [concrete] +// CHECK:STDOUT: %pattern_type.c39: type = pattern_type %ElementType [concrete] // CHECK:STDOUT: %C.as.IndexWith.impl.At.type: type = fn_type @C.as.IndexWith.impl.At [concrete] // CHECK:STDOUT: %C.as.IndexWith.impl.At: %C.as.IndexWith.impl.At.type = struct_value () [concrete] -// CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.191 = facet_value %C, (%IndexWith.impl_witness) [concrete] -// CHECK:STDOUT: %ElementType.val: %ElementType.e6b = struct_value () [concrete] +// CHECK:STDOUT: %ElementType.val: %ElementType = struct_value () [concrete] // CHECK:STDOUT: %C.val: %C = struct_value () [concrete] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete] -// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete] -// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete] -// CHECK:STDOUT: %.ae1: type = fn_type_with_self_type %IndexWith.At.type.b3f, %IndexWith.facet [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { // CHECK:STDOUT: .IndexWith = %Core.IndexWith -// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic] -// CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic] +// CHECK:STDOUT: %Core.import_ref.c50: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.290) = import_ref Core//prelude/operators/index, loc8_18, loaded [symbolic = @IndexWith.%assoc0 (constants.%assoc0.daf)] +// CHECK:STDOUT: %Core.import_ref.156: type = import_ref Core//prelude/operators/index, loc8_18, loaded [concrete = %ElementType] +// CHECK:STDOUT: %Core.import_ref.6c8 = import_ref Core//prelude/operators/index, loc8_18, unloaded +// CHECK:STDOUT: %ElementType: type = assoc_const_decl @ElementType.1 [concrete] {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -494,18 +551,30 @@ let x: i32 = c[0]; // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [concrete = constants.%ElementType.e6b] {} {} +// CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType.loc5 [concrete = constants.%ElementType] {} {} // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [concrete = constants.%SubscriptType.8ee] {} {} // CHECK:STDOUT: impl_decl @C.as.IndexWith.impl [concrete] {} { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic] // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee] -// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b] -// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [concrete = constants.%IndexWith.type.191] +// CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee)> [concrete = constants.%IndexWith.type.d2d] +// CHECK:STDOUT: %.Self: %IndexWith.type.d2d = bind_symbolic_name .Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.Self.ref: %IndexWith.type.d2d = name_ref .Self, %.Self [symbolic_self = constants.%.Self] +// CHECK:STDOUT: %.loc8_47.1: %IndexWith.assoc_type.f8f = specific_constant imports.%Core.import_ref.c50, @IndexWith(constants.%SubscriptType.8ee) [concrete = constants.%assoc0.a51] +// CHECK:STDOUT: %ElementType.ref.loc8_47: %IndexWith.assoc_type.f8f = name_ref ElementType, %.loc8_47.1 [concrete = constants.%assoc0.a51] +// CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %.loc8_47.2: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type] +// CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%IndexWith.lookup_impl_witness.0ce, element0 [symbolic_self = constants.%impl.elem0.859] +// CHECK:STDOUT: %ElementType.ref.loc8_62: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType] +// CHECK:STDOUT: %.loc8_41: type = where_expr %.Self [concrete = constants.%IndexWith_where.type] { +// CHECK:STDOUT: requirement_base_facet_type constants.%IndexWith.type.d2d +// CHECK:STDOUT: requirement_rewrite %impl.elem0, %ElementType.ref.loc8_62 +// CHECK:STDOUT: } // CHECK:STDOUT: } -// CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@C.as.IndexWith.impl.%C.as.IndexWith.impl.At.decl), @C.as.IndexWith.impl [concrete] +// CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (%impl_witness_assoc_constant, @C.as.IndexWith.impl.%C.as.IndexWith.impl.At.decl), @C.as.IndexWith.impl [concrete] // CHECK:STDOUT: %IndexWith.impl_witness: = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness] +// CHECK:STDOUT: %impl_witness_assoc_constant: type = impl_witness_assoc_constant constants.%ElementType [concrete = constants.%ElementType] // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %c.patt: %pattern_type.c48 = binding_pattern c [concrete] // CHECK:STDOUT: } @@ -519,13 +588,11 @@ let x: i32 = c[0]; // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %x.patt: %pattern_type.c39 = binding_pattern x [concrete] // CHECK:STDOUT: } -// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType.e6b] -// CHECK:STDOUT: %.loc22_25.1: ref %ElementType.e6b = temporary @__global_init.%.loc22_25.2, @__global_init.%C.as.IndexWith.impl.At.call -// CHECK:STDOUT: %.loc22_25.2: %ElementType.e6b = bind_value %.loc22_25.1 -// CHECK:STDOUT: %x: %ElementType.e6b = bind_name x, %.loc22_25.2 +// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType] +// CHECK:STDOUT: %x: %ElementType = bind_name x, [concrete = ] // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @C.as.IndexWith.impl: %C.ref as %IndexWith.type { +// CHECK:STDOUT: impl @C.as.IndexWith.impl: %C.ref as %.loc8_41 { // CHECK:STDOUT: %C.as.IndexWith.impl.At.decl: %C.as.IndexWith.impl.At.type = fn_decl @C.as.IndexWith.impl.At [concrete = constants.%C.as.IndexWith.impl.At] { // CHECK:STDOUT: %self.patt: %pattern_type.c48 = binding_pattern self [concrete] // CHECK:STDOUT: %self.param_patt: %pattern_type.c48 = value_param_pattern %self.patt, call_param0 [concrete] @@ -534,15 +601,15 @@ let x: i32 = c[0]; // CHECK:STDOUT: %return.patt: %pattern_type.c39 = return_slot_pattern [concrete] // CHECK:STDOUT: %return.param_patt: %pattern_type.c39 = out_param_pattern %return.patt, call_param2 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b] +// CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType] // CHECK:STDOUT: %self.param: %C = value_param call_param0 // CHECK:STDOUT: %Self.ref: type = name_ref Self, @C.as.IndexWith.impl.%C.ref [concrete = constants.%C] // CHECK:STDOUT: %self: %C = bind_name self, %self.param // CHECK:STDOUT: %subscript.param: %SubscriptType.8ee = value_param call_param1 // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee] // CHECK:STDOUT: %subscript: %SubscriptType.8ee = bind_name subscript, %subscript.param -// CHECK:STDOUT: %return.param: ref %ElementType.e6b = out_param call_param2 -// CHECK:STDOUT: %return: ref %ElementType.e6b = return_slot %return.param +// CHECK:STDOUT: %return.param: ref %ElementType = out_param call_param2 +// CHECK:STDOUT: %return: ref %ElementType = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -560,12 +627,12 @@ let x: i32 = c[0]; // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: class @ElementType { +// CHECK:STDOUT: class @ElementType.loc5 { // CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%ElementType.e6b +// CHECK:STDOUT: .Self = constants.%ElementType // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @SubscriptType { @@ -576,11 +643,11 @@ let x: i32 = c[0]; // CHECK:STDOUT: .Self = constants.%SubscriptType.8ee // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.IndexWith.impl.At(%self.param: %C, %subscript.param: %SubscriptType.8ee) -> %return.param: %ElementType.e6b { +// CHECK:STDOUT: fn @C.as.IndexWith.impl.At(%self.param: %C, %subscript.param: %SubscriptType.8ee) -> %return.param: %ElementType { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %.loc10_13.2: init %ElementType.e6b = class_init (), %return [concrete = constants.%ElementType.val] -// CHECK:STDOUT: %.loc10_14: init %ElementType.e6b = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val] +// CHECK:STDOUT: %.loc10_13.2: init %ElementType = class_init (), %return [concrete = constants.%ElementType.val] +// CHECK:STDOUT: %.loc10_14: init %ElementType = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val] // CHECK:STDOUT: return %.loc10_14 to %return // CHECK:STDOUT: } // CHECK:STDOUT: @@ -589,11 +656,6 @@ let x: i32 = c[0]; // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () // CHECK:STDOUT: %c.ref: %C = name_ref c, file.%c // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0] -// CHECK:STDOUT: %.loc22_25.1: %SubscriptType.8ee = converted %int_0, [concrete = ] -// CHECK:STDOUT: %impl.elem0: %.ae1 = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%C.as.IndexWith.impl.At] -// CHECK:STDOUT: %bound_method: = bound_method %c.ref, %impl.elem0 -// CHECK:STDOUT: %.loc22_25.2: ref %ElementType.e6b = temporary_storage -// CHECK:STDOUT: %C.as.IndexWith.impl.At.call: init %ElementType.e6b = call %bound_method(%c.ref, ) to %.loc22_25.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/diagnostics/diagnostic_kind.def b/toolchain/diagnostics/diagnostic_kind.def index 924b870ba8d4..ef27e1bf1f40 100644 --- a/toolchain/diagnostics/diagnostic_kind.def +++ b/toolchain/diagnostics/diagnostic_kind.def @@ -433,7 +433,6 @@ CARBON_DIAGNOSTIC_KIND(InvalidArrayExpr) CARBON_DIAGNOSTIC_KIND(NegativeIntInUnsignedType) CARBON_DIAGNOSTIC_KIND(NonConstantCallToCompTimeOnlyFunction) CARBON_DIAGNOSTIC_KIND(CompTimeOnlyFunctionHere) -CARBON_DIAGNOSTIC_KIND(TypeNotIndexable) CARBON_DIAGNOSTIC_KIND(SelfOutsideImplicitParamList) CARBON_DIAGNOSTIC_KIND(StringLiteralTooLong) CARBON_DIAGNOSTIC_KIND(StringLiteralTypeIncomplete)