From 288181453e6b863afcaaa5f68726c7316facb899 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 12 Mar 2025 14:35:03 -0400 Subject: [PATCH] Prevent BitAnd for facet types from matching non-type values (#5111) Currently this test fails with trying to access a comptime function with runtime values: ``` fn F() { let a: J = {} as J; let b: J = {} as J; // CHECK:STDERR: fail_bit_and_values_no_impl.carbon:[[@LINE+7]]:3: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction] // CHECK:STDERR: a & b; // CHECK:STDERR: ^~~~~ // CHECK:STDERR: core/prelude/operators/bitwise.carbon:96:3: note: compile-time-only function declared here [CompTimeOnlyFunctionHere] // CHECK:STDERR: fn Op[self: Self](other: Self) -> Self = "type.and"; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: a & b; } ``` The issue is that the BitAnd impl for facet types is matching on any value of any type: ``` impl forall [T:! type] T as BitAnd ``` What we really want is for it to match on facet types (which are type values), which is written as: ``` impl type as BitAnd ``` After this change, the error makes more sense in the above test: ``` fn F() { let a: J = {} as J; let b: J = {} as J; // CHECK:STDERR: fail_bit_and_values_no_impl.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Core.BitAnd` in type `J` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: a & b; // CHECK:STDERR: ^~~~~ // CHECK:STDERR: a & b; } ``` --- core/prelude/operators/bitwise.carbon | 2 +- .../value_with_type_through_access.carbon | 40 +++++----- .../testdata/class/generic/import.carbon | 6 +- toolchain/check/testdata/class/import.carbon | 2 +- .../testdata/facet/min_prelude/combine.carbon | 68 ----------------- .../function/generic/undefined.carbon | 2 +- .../if_expr/fail_not_in_function.carbon | 2 +- .../testdata/impl/use_assoc_const.carbon | 64 ++++++++-------- .../index/fail_negative_indexing.carbon | 4 +- .../testdata/operators/builtin/bit_and.carbon | 76 +++++++++++++++++++ .../overloaded/bit_complement.carbon | 8 +- toolchain/check/testdata/struct/import.carbon | 6 +- .../access/fail_negative_indexing.carbon | 4 +- toolchain/check/testdata/tuple/import.carbon | 6 +- .../testdata/where_expr/equal_rewrite.carbon | 16 ++-- 15 files changed, 157 insertions(+), 149 deletions(-) create mode 100644 toolchain/check/testdata/operators/builtin/bit_and.carbon diff --git a/core/prelude/operators/bitwise.carbon b/core/prelude/operators/bitwise.carbon index e20ddff73e50..23130c850b5d 100644 --- a/core/prelude/operators/bitwise.carbon +++ b/core/prelude/operators/bitwise.carbon @@ -92,6 +92,6 @@ impl IntLiteral() as RightShift { // associated library of its own. // Facet type combination. -impl forall [T:! type] T as BitAnd { +impl type as BitAnd { fn Op[self: Self](other: Self) -> Self = "type.and"; } diff --git a/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon b/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon index 4760e007b069..bf20e40c6d15 100644 --- a/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon +++ b/toolchain/check/testdata/builtin_conversions/value_with_type_through_access.carbon @@ -646,11 +646,11 @@ fn G() { // CHECK:STDOUT: constants { // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %array_type: type = array_type %int_1, type [concrete] -// CHECK:STDOUT: %T.eb6: %array_type = bind_symbolic_name T, 0 [symbolic] -// CHECK:STDOUT: %T.patt.226: %array_type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %T: %array_type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: %array_type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %HoldsType.type: type = generic_class_type @HoldsType [concrete] // CHECK:STDOUT: %HoldsType.generic: %HoldsType.type = struct_value () [concrete] -// CHECK:STDOUT: %HoldsType: type = class_type @HoldsType, @HoldsType(%T.eb6) [symbolic] +// CHECK:STDOUT: %HoldsType: type = class_type @HoldsType, @HoldsType(%T) [symbolic] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type.357: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete] @@ -696,16 +696,16 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %HoldsType.decl: %HoldsType.type = class_decl @HoldsType [concrete = constants.%HoldsType.generic] { -// CHECK:STDOUT: %T.patt.loc4_17.1: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt.226)] +// CHECK:STDOUT: %T.patt.loc4_17.1: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %.loc4: type = splice_block %array_type [concrete = constants.%array_type] { // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] // CHECK:STDOUT: %array_type: type = array_type %int_1, type [concrete = constants.%array_type] // CHECK:STDOUT: } -// CHECK:STDOUT: %T.loc4_17.1: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc4_17.2 (constants.%T.eb6)] +// CHECK:STDOUT: %T.loc4_17.1: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc4_17.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] { -// CHECK:STDOUT: %T.patt.loc12_6.1: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_6.2 (constants.%T.patt.226)] +// CHECK:STDOUT: %T.patt.loc12_6.1: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_6.2 (constants.%T.patt)] // CHECK:STDOUT: %x.patt: @F.%HoldsType.loc12_40.2 (%HoldsType) = binding_pattern x // CHECK:STDOUT: %x.param_patt: @F.%HoldsType.loc12_40.2 (%HoldsType) = value_param_pattern %x.patt, call_param0 // CHECK:STDOUT: %a.patt: = binding_pattern a @@ -715,17 +715,17 @@ fn G() { // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1] // CHECK:STDOUT: %array_type: type = array_type %int_1, type [concrete = constants.%array_type] // CHECK:STDOUT: } -// CHECK:STDOUT: %T.loc12_6.1: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc12_6.2 (constants.%T.eb6)] +// CHECK:STDOUT: %T.loc12_6.1: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc12_6.2 (constants.%T)] // CHECK:STDOUT: %x.param: @F.%HoldsType.loc12_40.2 (%HoldsType) = value_param call_param0 // CHECK:STDOUT: %.loc12_40: type = splice_block %HoldsType.loc12_40.1 [symbolic = %HoldsType.loc12_40.2 (constants.%HoldsType)] { // CHECK:STDOUT: %HoldsType.ref: %HoldsType.type = name_ref HoldsType, file.%HoldsType.decl [concrete = constants.%HoldsType.generic] -// CHECK:STDOUT: %T.ref.loc12_39: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T.eb6)] -// CHECK:STDOUT: %HoldsType.loc12_40.1: type = class_type @HoldsType, @HoldsType(constants.%T.eb6) [symbolic = %HoldsType.loc12_40.2 (constants.%HoldsType)] +// CHECK:STDOUT: %T.ref.loc12_39: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %HoldsType.loc12_40.1: type = class_type @HoldsType, @HoldsType(constants.%T) [symbolic = %HoldsType.loc12_40.2 (constants.%HoldsType)] // CHECK:STDOUT: } // CHECK:STDOUT: %x: @F.%HoldsType.loc12_40.2 (%HoldsType) = bind_name x, %x.param // CHECK:STDOUT: %a.param: = value_param call_param1 // CHECK:STDOUT: %.1: = splice_block [concrete = ] { -// CHECK:STDOUT: %T.ref.loc12_46: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T.eb6)] +// CHECK:STDOUT: %T.ref.loc12_46: %array_type = name_ref T, %T.loc12_6.1 [symbolic = %T.loc12_6.2 (constants.%T)] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] // 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] @@ -747,8 +747,8 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @HoldsType(%T.loc4_17.1: %array_type) { -// CHECK:STDOUT: %T.loc4_17.2: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc4_17.2 (constants.%T.eb6)] -// CHECK:STDOUT: %T.patt.loc4_17.2: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt.226)] +// CHECK:STDOUT: %T.loc4_17.2: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc4_17.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc4_17.2: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_17.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: @@ -770,8 +770,8 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @F(%T.loc12_6.1: %array_type) { -// CHECK:STDOUT: %T.loc12_6.2: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc12_6.2 (constants.%T.eb6)] -// CHECK:STDOUT: %T.patt.loc12_6.2: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_6.2 (constants.%T.patt.226)] +// CHECK:STDOUT: %T.loc12_6.2: %array_type = bind_symbolic_name T, 0 [symbolic = %T.loc12_6.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc12_6.2: %array_type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_6.2 (constants.%T.patt)] // CHECK:STDOUT: %HoldsType.loc12_40.2: type = class_type @HoldsType, @HoldsType(%T.loc12_6.2) [symbolic = %HoldsType.loc12_40.2 (constants.%HoldsType)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: @@ -804,16 +804,16 @@ fn G() { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @HoldsType(constants.%T.eb6) { -// CHECK:STDOUT: %T.loc4_17.2 => constants.%T.eb6 -// CHECK:STDOUT: %T.patt.loc4_17.2 => constants.%T.eb6 +// CHECK:STDOUT: specific @HoldsType(constants.%T) { +// CHECK:STDOUT: %T.loc4_17.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc4_17.2 => constants.%T // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @F(constants.%T.eb6) { -// CHECK:STDOUT: %T.loc12_6.2 => constants.%T.eb6 -// CHECK:STDOUT: %T.patt.loc12_6.2 => constants.%T.eb6 +// CHECK:STDOUT: specific @F(constants.%T) { +// CHECK:STDOUT: %T.loc12_6.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc12_6.2 => constants.%T // CHECK:STDOUT: %HoldsType.loc12_40.2 => constants.%HoldsType // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/class/generic/import.carbon b/toolchain/check/testdata/class/generic/import.carbon index 107e371dcd8e..8f5808d12e68 100644 --- a/toolchain/check/testdata/class/generic/import.carbon +++ b/toolchain/check/testdata/class/generic/import.carbon @@ -252,10 +252,10 @@ class Class(U:! type) { // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] -// CHECK:STDOUT: %require_complete.4ae: = require_complete_type %T [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [concrete] // CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [concrete] // CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic] +// CHECK:STDOUT: %require_complete.4ae: = require_complete_type %T [symbolic] // CHECK:STDOUT: %Class.elem: type = unbound_element_type %Class, %T [symbolic] // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %T} [symbolic] // CHECK:STDOUT: %complete_type.433: = complete_type_witness %struct_type.x [symbolic] @@ -776,12 +776,12 @@ class Class(U:! type) { // CHECK:STDOUT: --- fail_foo.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] -// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic] // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [concrete] // CHECK:STDOUT: %Class.generic: %Class.type = struct_value () [concrete] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %.type: type = generic_class_type @.1 [concrete] // CHECK:STDOUT: %.generic: %.type = struct_value () [concrete] // CHECK:STDOUT: %.e41: type = class_type @.1, @.1(%U) [symbolic] diff --git a/toolchain/check/testdata/class/import.carbon b/toolchain/check/testdata/class/import.carbon index f2fb13bb9ce1..b6b51aec2491 100644 --- a/toolchain/check/testdata/class/import.carbon +++ b/toolchain/check/testdata/class/import.carbon @@ -364,5 +364,5 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @F[%self.param_patt: %ForwardDeclared.7b34f2.1]() [from "a.carbon"]; // CHECK:STDOUT: -// CHECK:STDOUT: fn @G[addr .inst1158: %ptr.6cf]() [from "a.carbon"]; +// CHECK:STDOUT: fn @G[addr .inst1134: %ptr.6cf]() [from "a.carbon"]; // CHECK:STDOUT: diff --git a/toolchain/check/testdata/facet/min_prelude/combine.carbon b/toolchain/check/testdata/facet/min_prelude/combine.carbon index 51c56d985be7..2f156e2908d8 100644 --- a/toolchain/check/testdata/facet/min_prelude/combine.carbon +++ b/toolchain/check/testdata/facet/min_prelude/combine.carbon @@ -11,74 +11,6 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/min_prelude/combine.carbon -// --- fail_combine_with_non_facet_type.carbon -library "[[@TEST_NAME]]"; - -interface A {} -class C {} - -// CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+4]]:11: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] -// CHECK:STDERR: fn AC[T:! A & C](t: T) {} -// CHECK:STDERR: ^~~~~ -// CHECK:STDERR: -fn AC[T:! A & C](t: T) {} -// CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+4]]:11: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] -// CHECK:STDERR: fn CA[T:! C & A](t: T) {} -// CHECK:STDERR: ^~~~~ -// CHECK:STDERR: -fn CA[T:! C & A](t: T) {} -// CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+8]]:11: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] -// CHECK:STDERR: fn CC[T:! C & C](t: T) {} -// CHECK:STDERR: ^~~~~ -// CHECK:STDERR: -// CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+4]]:11: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] -// CHECK:STDERR: fn CC[T:! C & C](t: T) {} -// CHECK:STDERR: ^~~~~ -// CHECK:STDERR: -fn CC[T:! C & C](t: T) {} - -fn F() { - // CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+4]]:23: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] - // CHECK:STDERR: ({} as C) as (C as (A & C)); - // CHECK:STDERR: ^~~~~ - // CHECK:STDERR: - ({} as C) as (C as (A & C)); - // CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+4]]:23: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] - // CHECK:STDERR: ({} as C) as (C as (C & A)); - // CHECK:STDERR: ^~~~~ - // CHECK:STDERR: - ({} as C) as (C as (C & A)); - // CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+8]]:23: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] - // CHECK:STDERR: ({} as C) as (C as (C & C)); - // CHECK:STDERR: ^~~~~ - // CHECK:STDERR: - // CHECK:STDERR: fail_combine_with_non_facet_type.carbon:[[@LINE+4]]:23: error: non-facet type `C` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] - // CHECK:STDERR: ({} as C) as (C as (C & C)); - // CHECK:STDERR: ^~~~~ - // CHECK:STDERR: - ({} as C) as (C as (C & C)); - - AC({} as C); - CA({} as C); - CC({} as C); -} - -// --- same.carbon -library "[[@TEST_NAME]]"; - -interface A {} - -class C {} -impl C as A {} - -fn AA[T:! A & A](t: T) {} - -fn F() { - ({} as C) as (C as (A & A)); - - AA({} as C); -} - // --- fail_name_collision.carbon library "[[@TEST_NAME]]"; diff --git a/toolchain/check/testdata/function/generic/undefined.carbon b/toolchain/check/testdata/function/generic/undefined.carbon index 3c66f97a911b..3cc80c1f0bd3 100644 --- a/toolchain/check/testdata/function/generic/undefined.carbon +++ b/toolchain/check/testdata/function/generic/undefined.carbon @@ -185,7 +185,6 @@ fn CallUndefined() -> i32 { // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete] // CHECK:STDOUT: %As.type.fd4: type = facet_type <@As, @As(%i32)> [concrete] // CHECK:STDOUT: %Convert.type.99b: type = fn_type @Convert.1, @As(%i32) [concrete] -// CHECK:STDOUT: %require_complete.4ae: = require_complete_type %T [symbolic] // CHECK:STDOUT: %impl_witness.882: = impl_witness (imports.%Core.import_ref.78a), @impl.686(%int_32) [concrete] // CHECK:STDOUT: %Convert.type.4fd: type = fn_type @Convert.5, @impl.686(%int_32) [concrete] // CHECK:STDOUT: %Convert.197: %Convert.type.4fd = struct_value () [concrete] @@ -196,6 +195,7 @@ fn CallUndefined() -> i32 { // CHECK:STDOUT: %bound_method: = bound_method %int_0.5c6, %Convert.specific_fn [concrete] // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete] // CHECK:STDOUT: %Defined.specific_fn: = specific_function %Defined, @Defined(%i32) [concrete] +// CHECK:STDOUT: %require_complete.4ae: = require_complete_type %T [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { diff --git a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon index c9d1a572a1d3..186ae13425da 100644 --- a/toolchain/check/testdata/if_expr/fail_not_in_function.carbon +++ b/toolchain/check/testdata/if_expr/fail_not_in_function.carbon @@ -94,7 +94,7 @@ class C { // 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: } -// CHECK:STDOUT: %x: %i32 = bind_name x, .inst1080.loc27_14 +// CHECK:STDOUT: %x: %i32 = bind_name x, .inst1056.loc27_14 // CHECK:STDOUT: name_binding_decl { // CHECK:STDOUT: %y.patt: %i32 = binding_pattern y // CHECK:STDOUT: %.loc37: %i32 = var_pattern %y.patt diff --git a/toolchain/check/testdata/impl/use_assoc_const.carbon b/toolchain/check/testdata/impl/use_assoc_const.carbon index 9acdbbb27b73..4b14e5630375 100644 --- a/toolchain/check/testdata/impl/use_assoc_const.carbon +++ b/toolchain/check/testdata/impl/use_assoc_const.carbon @@ -935,10 +935,10 @@ impl () as I where .N = 2 { // CHECK:STDOUT: %Convert.bound.ce9: = bound_method %int_6.462, %Convert.956 [concrete] // CHECK:STDOUT: %bound_method.efa: = bound_method %int_6.462, %Convert.specific_fn [concrete] // CHECK:STDOUT: %int_6.e56: %i32 = int_value 6 [concrete] -// CHECK:STDOUT: %T.ccd: %J.type = bind_symbolic_name T, 0 [symbolic] -// CHECK:STDOUT: %T.patt.371: %J.type = symbolic_binding_pattern T, 0 [symbolic] -// CHECK:STDOUT: %T.as_type: type = facet_access_type %T.ccd [symbolic] -// CHECK:STDOUT: %T.as_wit.iface0: = facet_access_witness %T.ccd, element0 [symbolic] +// CHECK:STDOUT: %T: %J.type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: %J.type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic] +// CHECK:STDOUT: %T.as_wit.iface0: = facet_access_witness %T, element0 [symbolic] // CHECK:STDOUT: %J.facet.085e97.2: %J.type = facet_value %T.as_type, (%T.as_wit.iface0) [symbolic] // CHECK:STDOUT: %impl.elem0.d9c3a6.2: type = impl_witness_access %T.as_wit.iface0, element0 [symbolic] // CHECK:STDOUT: %GenericCallF.type: type = fn_type @GenericCallF [concrete] @@ -991,7 +991,7 @@ impl () as I where .N = 2 { // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %GenericCallF.decl: %GenericCallF.type = fn_decl @GenericCallF [concrete = constants.%GenericCallF] { -// CHECK:STDOUT: %T.patt.loc24_17.1: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc24_17.2 (constants.%T.patt.371)] +// CHECK:STDOUT: %T.patt.loc24_17.1: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc24_17.2 (constants.%T.patt)] // CHECK:STDOUT: %t.patt: @GenericCallF.%T.as_type.loc24_27.2 (%T.as_type) = binding_pattern t // CHECK:STDOUT: %t.param_patt: @GenericCallF.%T.as_type.loc24_27.2 (%T.as_type) = value_param_pattern %t.patt, call_param0 // CHECK:STDOUT: %u.patt: @GenericCallF.%impl.elem0.loc24_34.2 (%impl.elem0.d9c3a6.2) = binding_pattern u @@ -999,24 +999,24 @@ impl () as I where .N = 2 { // CHECK:STDOUT: %return.patt: @GenericCallF.%impl.elem0.loc24_34.2 (%impl.elem0.d9c3a6.2) = return_slot_pattern // CHECK:STDOUT: %return.param_patt: @GenericCallF.%impl.elem0.loc24_34.2 (%impl.elem0.d9c3a6.2) = out_param_pattern %return.patt, call_param2 // CHECK:STDOUT: } { -// CHECK:STDOUT: %T.ref.loc24_41: %J.type = name_ref T, %T.loc24_17.1 [symbolic = %T.loc24_17.2 (constants.%T.ccd)] +// CHECK:STDOUT: %T.ref.loc24_41: %J.type = name_ref T, %T.loc24_17.1 [symbolic = %T.loc24_17.2 (constants.%T)] // CHECK:STDOUT: %U.ref.loc24_42: %J.assoc_type = name_ref U, @U.%assoc0 [concrete = constants.%assoc0.1e6] // CHECK:STDOUT: %T.as_type.loc24_42: type = facet_access_type %T.ref.loc24_41 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] // CHECK:STDOUT: %.loc24_42: type = converted %T.ref.loc24_41, %T.as_type.loc24_42 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] // CHECK:STDOUT: %T.as_wit.iface0.loc24_42: = facet_access_witness %T.ref.loc24_41, element0 [symbolic = %T.as_wit.iface0.loc24_34.2 (constants.%T.as_wit.iface0)] // CHECK:STDOUT: %impl.elem0.loc24_42: type = impl_witness_access %T.as_wit.iface0.loc24_42, element0 [symbolic = %impl.elem0.loc24_34.2 (constants.%impl.elem0.d9c3a6.2)] // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [concrete = constants.%J.type] -// CHECK:STDOUT: %T.loc24_17.1: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc24_17.2 (constants.%T.ccd)] +// CHECK:STDOUT: %T.loc24_17.1: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc24_17.2 (constants.%T)] // CHECK:STDOUT: %t.param: @GenericCallF.%T.as_type.loc24_27.2 (%T.as_type) = value_param call_param0 // CHECK:STDOUT: %.loc24_27.1: type = splice_block %.loc24_27.2 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] { -// CHECK:STDOUT: %T.ref.loc24_27: %J.type = name_ref T, %T.loc24_17.1 [symbolic = %T.loc24_17.2 (constants.%T.ccd)] +// CHECK:STDOUT: %T.ref.loc24_27: %J.type = name_ref T, %T.loc24_17.1 [symbolic = %T.loc24_17.2 (constants.%T)] // CHECK:STDOUT: %T.as_type.loc24_27.1: type = facet_access_type %T.ref.loc24_27 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] // CHECK:STDOUT: %.loc24_27.2: type = converted %T.ref.loc24_27, %T.as_type.loc24_27.1 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] // CHECK:STDOUT: } // CHECK:STDOUT: %t: @GenericCallF.%T.as_type.loc24_27.2 (%T.as_type) = bind_name t, %t.param // CHECK:STDOUT: %u.param: @GenericCallF.%impl.elem0.loc24_34.2 (%impl.elem0.d9c3a6.2) = value_param call_param1 // CHECK:STDOUT: %.loc24_34.1: type = splice_block %impl.elem0.loc24_34.1 [symbolic = %impl.elem0.loc24_34.2 (constants.%impl.elem0.d9c3a6.2)] { -// CHECK:STDOUT: %T.ref.loc24_33: %J.type = name_ref T, %T.loc24_17.1 [symbolic = %T.loc24_17.2 (constants.%T.ccd)] +// CHECK:STDOUT: %T.ref.loc24_33: %J.type = name_ref T, %T.loc24_17.1 [symbolic = %T.loc24_17.2 (constants.%T)] // CHECK:STDOUT: %U.ref.loc24_34: %J.assoc_type = name_ref U, @U.%assoc0 [concrete = constants.%assoc0.1e6] // CHECK:STDOUT: %T.as_type.loc24_34: type = facet_access_type %T.ref.loc24_33 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] // CHECK:STDOUT: %.loc24_34.2: type = converted %T.ref.loc24_33, %T.as_type.loc24_34 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] @@ -1354,8 +1354,8 @@ impl () as I where .N = 2 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @GenericCallF(%T.loc24_17.1: %J.type) { -// CHECK:STDOUT: %T.loc24_17.2: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc24_17.2 (constants.%T.ccd)] -// CHECK:STDOUT: %T.patt.loc24_17.2: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc24_17.2 (constants.%T.patt.371)] +// CHECK:STDOUT: %T.loc24_17.2: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc24_17.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc24_17.2: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc24_17.2 (constants.%T.patt)] // CHECK:STDOUT: %T.as_type.loc24_27.2: type = facet_access_type %T.loc24_17.2 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] // CHECK:STDOUT: %T.as_wit.iface0.loc24_34.2: = facet_access_witness %T.loc24_17.2, element0 [symbolic = %T.as_wit.iface0.loc24_34.2 (constants.%T.as_wit.iface0)] // CHECK:STDOUT: %impl.elem0.loc24_34.2: type = impl_witness_access %T.as_wit.iface0.loc24_34.2, element0 [symbolic = %impl.elem0.loc24_34.2 (constants.%impl.elem0.d9c3a6.2)] @@ -1372,9 +1372,9 @@ impl () as I where .N = 2 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %t.ref: @GenericCallF.%T.as_type.loc24_27.2 (%T.as_type) = name_ref t, %t // CHECK:STDOUT: %F.ref: %J.assoc_type = name_ref F, @J.%assoc1 [concrete = constants.%assoc1] -// CHECK:STDOUT: %T.as_type.loc25: type = facet_access_type constants.%T.ccd [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] -// CHECK:STDOUT: %.loc25_11.1: type = converted constants.%T.ccd, %T.as_type.loc25 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] -// CHECK:STDOUT: %T.as_wit.iface0.loc25: = facet_access_witness constants.%T.ccd, element0 [symbolic = %T.as_wit.iface0.loc24_34.2 (constants.%T.as_wit.iface0)] +// CHECK:STDOUT: %T.as_type.loc25: type = facet_access_type constants.%T [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] +// CHECK:STDOUT: %.loc25_11.1: type = converted constants.%T, %T.as_type.loc25 [symbolic = %T.as_type.loc24_27.2 (constants.%T.as_type)] +// CHECK:STDOUT: %T.as_wit.iface0.loc25: = facet_access_witness constants.%T, element0 [symbolic = %T.as_wit.iface0.loc24_34.2 (constants.%T.as_wit.iface0)] // CHECK:STDOUT: %impl.elem1.loc25_11.1: @GenericCallF.%.loc25_11.2 (%.4d2) = impl_witness_access %T.as_wit.iface0.loc25, element1 [symbolic = %impl.elem1.loc25_11.2 (constants.%impl.elem1)] // CHECK:STDOUT: %u.ref: @GenericCallF.%impl.elem0.loc24_34.2 (%impl.elem0.d9c3a6.2) = name_ref u, %u // CHECK:STDOUT: %specific_fn.loc25_11.1: = specific_function %impl.elem1.loc25_11.1, @F.1(constants.%J.facet.085e97.2) [symbolic = %specific_fn.loc25_11.2 (constants.%specific_fn)] @@ -1442,9 +1442,9 @@ impl () as I where .N = 2 { // CHECK:STDOUT: // CHECK:STDOUT: specific @U(constants.%J.facet.085e97.2) {} // CHECK:STDOUT: -// CHECK:STDOUT: specific @GenericCallF(constants.%T.ccd) { -// CHECK:STDOUT: %T.loc24_17.2 => constants.%T.ccd -// CHECK:STDOUT: %T.patt.loc24_17.2 => constants.%T.ccd +// CHECK:STDOUT: specific @GenericCallF(constants.%T) { +// CHECK:STDOUT: %T.loc24_17.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc24_17.2 => constants.%T // CHECK:STDOUT: %T.as_type.loc24_27.2 => constants.%T.as_type // CHECK:STDOUT: %T.as_wit.iface0.loc24_34.2 => constants.%T.as_wit.iface0 // CHECK:STDOUT: %impl.elem0.loc24_34.2 => constants.%impl.elem0.d9c3a6.2 @@ -1889,13 +1889,13 @@ impl () as I where .N = 2 { // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] // CHECK:STDOUT: %J_where.type: type = facet_type <@J where %impl.elem0.53a = %i32> [concrete] -// CHECK:STDOUT: %T.0b2: %J_where.type = bind_symbolic_name T, 0 [symbolic] -// CHECK:STDOUT: %T.patt.bc6: %J_where.type = symbolic_binding_pattern T, 0 [symbolic] -// CHECK:STDOUT: %T.as_type: type = facet_access_type %T.0b2 [symbolic] +// CHECK:STDOUT: %T: %J_where.type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: %J_where.type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic] // CHECK:STDOUT: %GenericCallFI32.type: type = fn_type @GenericCallFI32 [concrete] // CHECK:STDOUT: %GenericCallFI32: %GenericCallFI32.type = struct_value () [concrete] // CHECK:STDOUT: %require_complete.3e7: = require_complete_type %T.as_type [symbolic] -// CHECK:STDOUT: %T.as_wit.iface0: = facet_access_witness %T.0b2, element0 [symbolic] +// CHECK:STDOUT: %T.as_wit.iface0: = facet_access_witness %T, element0 [symbolic] // CHECK:STDOUT: %J.facet.869: %J.type = facet_value %T.as_type, (%T.as_wit.iface0) [symbolic] // CHECK:STDOUT: %.861: type = fn_type_with_self_type %F.type, %J.facet.869 [symbolic] // CHECK:STDOUT: %impl.elem1: %.861 = impl_witness_access %T.as_wit.iface0, element1 [symbolic] @@ -1925,7 +1925,7 @@ impl () as I where .N = 2 { // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %J.decl: type = interface_decl @J [concrete = constants.%J.type] {} {} // CHECK:STDOUT: %GenericCallFI32.decl: %GenericCallFI32.type = fn_decl @GenericCallFI32 [concrete = constants.%GenericCallFI32] { -// CHECK:STDOUT: %T.patt.loc8_20.1: %J_where.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_20.2 (constants.%T.patt.bc6)] +// CHECK:STDOUT: %T.patt.loc8_20.1: %J_where.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_20.2 (constants.%T.patt)] // CHECK:STDOUT: %t.patt: @GenericCallFI32.%T.as_type.loc8_45.2 (%T.as_type) = binding_pattern t // CHECK:STDOUT: %t.param_patt: @GenericCallFI32.%T.as_type.loc8_45.2 (%T.as_type) = value_param_pattern %t.patt, call_param0 // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern @@ -1948,10 +1948,10 @@ impl () as I where .N = 2 { // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc8, %i32.loc8_37 // CHECK:STDOUT: } // CHECK:STDOUT: } -// CHECK:STDOUT: %T.loc8_20.1: %J_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_20.2 (constants.%T.0b2)] +// CHECK:STDOUT: %T.loc8_20.1: %J_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_20.2 (constants.%T)] // CHECK:STDOUT: %t.param: @GenericCallFI32.%T.as_type.loc8_45.2 (%T.as_type) = value_param call_param0 // CHECK:STDOUT: %.loc8_45.1: type = splice_block %.loc8_45.2 [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] { -// CHECK:STDOUT: %T.ref: %J_where.type = name_ref T, %T.loc8_20.1 [symbolic = %T.loc8_20.2 (constants.%T.0b2)] +// CHECK:STDOUT: %T.ref: %J_where.type = name_ref T, %T.loc8_20.1 [symbolic = %T.loc8_20.2 (constants.%T)] // CHECK:STDOUT: %T.as_type.loc8_45.1: type = facet_access_type %T.ref [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] // CHECK:STDOUT: %.loc8_45.2: type = converted %T.ref, %T.as_type.loc8_45.1 [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] // CHECK:STDOUT: } @@ -2007,8 +2007,8 @@ impl () as I where .N = 2 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @GenericCallFI32(%T.loc8_20.1: %J_where.type) { -// CHECK:STDOUT: %T.loc8_20.2: %J_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_20.2 (constants.%T.0b2)] -// CHECK:STDOUT: %T.patt.loc8_20.2: %J_where.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_20.2 (constants.%T.patt.bc6)] +// CHECK:STDOUT: %T.loc8_20.2: %J_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_20.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc8_20.2: %J_where.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_20.2 (constants.%T.patt)] // CHECK:STDOUT: %T.as_type.loc8_45.2: type = facet_access_type %T.loc8_20.2 [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: @@ -2027,9 +2027,9 @@ impl () as I where .N = 2 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %t.ref: @GenericCallFI32.%T.as_type.loc8_45.2 (%T.as_type) = name_ref t, %t // CHECK:STDOUT: %F.ref: %J.assoc_type = name_ref F, @J.%assoc1 [concrete = constants.%assoc1] -// CHECK:STDOUT: %T.as_type.loc26: type = facet_access_type constants.%T.0b2 [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] -// CHECK:STDOUT: %.loc26_11.1: type = converted constants.%T.0b2, %T.as_type.loc26 [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] -// CHECK:STDOUT: %T.as_wit.iface0.loc26_11.1: = facet_access_witness constants.%T.0b2, element0 [symbolic = %T.as_wit.iface0.loc26_11.2 (constants.%T.as_wit.iface0)] +// CHECK:STDOUT: %T.as_type.loc26: type = facet_access_type constants.%T [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] +// CHECK:STDOUT: %.loc26_11.1: type = converted constants.%T, %T.as_type.loc26 [symbolic = %T.as_type.loc8_45.2 (constants.%T.as_type)] +// CHECK:STDOUT: %T.as_wit.iface0.loc26_11.1: = facet_access_witness constants.%T, element0 [symbolic = %T.as_wit.iface0.loc26_11.2 (constants.%T.as_wit.iface0)] // CHECK:STDOUT: %impl.elem1.loc26_11.1: @GenericCallFI32.%.loc26_11.2 (%.861) = impl_witness_access %T.as_wit.iface0.loc26_11.1, element1 [symbolic = %impl.elem1.loc26_11.2 (constants.%impl.elem1)] // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2] // CHECK:STDOUT: %specific_fn.loc26_11.1: = specific_function %impl.elem1.loc26_11.1, @F(constants.%J.facet.869) [symbolic = %specific_fn.loc26_11.2 (constants.%specific_fn)] @@ -2052,9 +2052,9 @@ impl () as I where .N = 2 { // CHECK:STDOUT: // CHECK:STDOUT: specific @U(constants.%J.facet.28c) {} // CHECK:STDOUT: -// CHECK:STDOUT: specific @GenericCallFI32(constants.%T.0b2) { -// CHECK:STDOUT: %T.loc8_20.2 => constants.%T.0b2 -// CHECK:STDOUT: %T.patt.loc8_20.2 => constants.%T.0b2 +// CHECK:STDOUT: specific @GenericCallFI32(constants.%T) { +// CHECK:STDOUT: %T.loc8_20.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc8_20.2 => constants.%T // CHECK:STDOUT: %T.as_type.loc8_45.2 => constants.%T.as_type // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/index/fail_negative_indexing.carbon b/toolchain/check/testdata/index/fail_negative_indexing.carbon index 2c8bd8dab622..782c8d51acbd 100644 --- a/toolchain/check/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/index/fail_negative_indexing.carbon @@ -41,11 +41,11 @@ var d: i32 = c[-10]; // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete] // CHECK:STDOUT: %array: %array_type = tuple_value (%int_42.c68, %int_42.c68) [concrete] // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [concrete] -// CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.14 [concrete] +// CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.13 [concrete] // CHECK:STDOUT: %impl_witness.0f6: = impl_witness (imports.%Core.import_ref.c15) [concrete] // CHECK:STDOUT: %Negate.facet: %Negate.type = facet_value Core.IntLiteral, (%impl_witness.0f6) [concrete] // CHECK:STDOUT: %.690: type = fn_type_with_self_type %Op.type.e42, %Negate.facet [concrete] -// CHECK:STDOUT: %Op.type.1be: type = fn_type @Op.15 [concrete] +// CHECK:STDOUT: %Op.type.1be: type = fn_type @Op.14 [concrete] // CHECK:STDOUT: %Op.bba: %Op.type.1be = struct_value () [concrete] // CHECK:STDOUT: %Op.bound: = bound_method %int_10, %Op.bba [concrete] // CHECK:STDOUT: %int_-10.06d: Core.IntLiteral = int_value -10 [concrete] diff --git a/toolchain/check/testdata/operators/builtin/bit_and.carbon b/toolchain/check/testdata/operators/builtin/bit_and.carbon new file mode 100644 index 000000000000..6609b2f4744c --- /dev/null +++ b/toolchain/check/testdata/operators/builtin/bit_and.carbon @@ -0,0 +1,76 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// EXTRA-ARGS: --no-dump-sem-ir +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/builtin/bit_and.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/bit_and.carbon + +// --- bit_and_facet_types.carbon +library "[[@TEST_NAME]]"; + +interface I {} +interface J {} + +fn F1[T:! I & J](t: T) {} +fn F2[T:! I & I](t: T) {} + +// --- fail_bit_and_non_facet_types.carbon +library "[[@TEST_NAME]]"; + +interface I {} +class J {} +class K {} + +// CHECK:STDERR: fail_bit_and_non_facet_types.carbon:[[@LINE+4]]:11: error: non-facet type `J` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] +// CHECK:STDERR: fn F1[T:! I & J](t: T) {} +// CHECK:STDERR: ^~~~~ +// CHECK:STDERR: +fn F1[T:! I & J](t: T) {} +// CHECK:STDERR: fail_bit_and_non_facet_types.carbon:[[@LINE+4]]:11: error: non-facet type `J` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] +// CHECK:STDERR: fn F2[T:! J & I](t: T) {} +// CHECK:STDERR: ^~~~~ +// CHECK:STDERR: +fn F2[T:! J & I](t: T) {} +// CHECK:STDERR: fail_bit_and_non_facet_types.carbon:[[@LINE+8]]:11: error: non-facet type `J` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] +// CHECK:STDERR: fn F3[T:! J & K](t: T) {} +// CHECK:STDERR: ^~~~~ +// CHECK:STDERR: +// CHECK:STDERR: fail_bit_and_non_facet_types.carbon:[[@LINE+4]]:11: error: non-facet type `K` combined with `&` operator [FacetTypeRequiredForTypeAndOperator] +// CHECK:STDERR: fn F3[T:! J & K](t: T) {} +// CHECK:STDERR: ^~~~~ +// CHECK:STDERR: +fn F3[T:! J & K](t: T) {} + +// --- bit_and_values_with_impl.carbon +library "[[@TEST_NAME]]"; + +class J { adapt {}; } +impl J as Core.BitAnd { + fn Op[self: Self](other: Self) -> Self { return {} as J; } +} + +fn F() { + let a: J = {} as J; + let b: J = {} as J; + a & b; +} + +// --- fail_bit_and_values_no_impl.carbon +library "[[@TEST_NAME]]"; + +class J { adapt {}; } + +fn F() { + let a: J = {} as J; + let b: J = {} as J; + // CHECK:STDERR: fail_bit_and_values_no_impl.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Core.BitAnd` in type `J` that does not implement that interface [MissingImplInMemberAccess] + // CHECK:STDERR: a & b; + // CHECK:STDERR: ^~~~~ + // CHECK:STDERR: + a & b; +} diff --git a/toolchain/check/testdata/operators/overloaded/bit_complement.carbon b/toolchain/check/testdata/operators/overloaded/bit_complement.carbon index e84298d7fedd..5f024961aa1f 100644 --- a/toolchain/check/testdata/operators/overloaded/bit_complement.carbon +++ b/toolchain/check/testdata/operators/overloaded/bit_complement.carbon @@ -32,10 +32,10 @@ fn TestOp(a: C) -> C { // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %BitComplement.type: type = facet_type <@BitComplement> [concrete] // CHECK:STDOUT: %Op.type.f25: type = fn_type @Op.1 [concrete] -// CHECK:STDOUT: %impl_witness.40c: = impl_witness (@impl.5a3.%Op.decl) [concrete] +// CHECK:STDOUT: %impl_witness: = impl_witness (@impl.5a3.%Op.decl) [concrete] // CHECK:STDOUT: %Op.type.544: type = fn_type @Op.2 [concrete] // CHECK:STDOUT: %Op.bf2: %Op.type.544 = struct_value () [concrete] -// CHECK:STDOUT: %BitComplement.facet: %BitComplement.type = facet_value %C, (%impl_witness.40c) [concrete] +// CHECK:STDOUT: %BitComplement.facet: %BitComplement.type = facet_value %C, (%impl_witness) [concrete] // CHECK:STDOUT: %C.val: %C = struct_value () [concrete] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [concrete] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [concrete] @@ -64,7 +64,7 @@ fn TestOp(a: C) -> C { // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %BitComplement.ref: type = name_ref BitComplement, imports.%Core.BitComplement [concrete = constants.%BitComplement.type] // CHECK:STDOUT: } -// CHECK:STDOUT: %impl_witness: = impl_witness (@impl.5a3.%Op.decl) [concrete = constants.%impl_witness.40c] +// CHECK:STDOUT: %impl_witness: = impl_witness (@impl.5a3.%Op.decl) [concrete = constants.%impl_witness] // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [concrete = constants.%TestOp] { // CHECK:STDOUT: %a.patt: %C = binding_pattern a // CHECK:STDOUT: %a.param_patt: %C = value_param_pattern %a.patt, call_param0 @@ -120,7 +120,7 @@ fn TestOp(a: C) -> C { // CHECK:STDOUT: fn @TestOp(%a.param_patt: %C) -> %return.param_patt: %C { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %impl.elem0: %.f35 = impl_witness_access constants.%impl_witness.40c, element0 [concrete = constants.%Op.bf2] +// CHECK:STDOUT: %impl.elem0: %.f35 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%Op.bf2] // CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem0 // CHECK:STDOUT: %.loc23: ref %C = splice_block %return {} // CHECK:STDOUT: %Op.call: init %C = call %bound_method(%a.ref) to %.loc23 diff --git a/toolchain/check/testdata/struct/import.carbon b/toolchain/check/testdata/struct/import.carbon index e18d22a1303c..f64d42c48fba 100644 --- a/toolchain/check/testdata/struct/import.carbon +++ b/toolchain/check/testdata/struct/import.carbon @@ -328,7 +328,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import_ref.c81: %struct_type.a.b.5ca = import_ref Implicit//default, loc8_9, loaded [symbolic = @C.%S (constants.%S)] // CHECK:STDOUT: %Implicit.import_ref.8f2: = import_ref Implicit//default, loc8_34, loaded [concrete = constants.%complete_type.357] -// CHECK:STDOUT: %Implicit.import_ref.b8b = import_ref Implicit//default, inst1155 [no loc], unloaded +// CHECK:STDOUT: %Implicit.import_ref.b8b = import_ref Implicit//default, inst1131 [no loc], unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -505,7 +505,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import_ref.c81: %struct_type.a.b = import_ref Implicit//default, loc8_9, loaded [symbolic = @C.%S (constants.%S)] // CHECK:STDOUT: %Implicit.import_ref.8f2: = import_ref Implicit//default, loc8_34, loaded [concrete = constants.%complete_type.357] -// CHECK:STDOUT: %Implicit.import_ref.b8b = import_ref Implicit//default, inst1155 [no loc], unloaded +// CHECK:STDOUT: %Implicit.import_ref.b8b = import_ref Implicit//default, inst1131 [no loc], unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -622,7 +622,7 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import_ref.c81: %struct_type.a.b.5ca = import_ref Implicit//default, loc8_9, loaded [symbolic = @C.%S (constants.%S)] // CHECK:STDOUT: %Implicit.import_ref.8f2: = import_ref Implicit//default, loc8_34, loaded [concrete = constants.%complete_type.357] -// CHECK:STDOUT: %Implicit.import_ref.b8b = import_ref Implicit//default, inst1155 [no loc], unloaded +// CHECK:STDOUT: %Implicit.import_ref.b8b = import_ref Implicit//default, inst1131 [no loc], unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon b/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon index 2ae6292fc2bc..d1d33cb153b8 100644 --- a/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon +++ b/toolchain/check/testdata/tuple/access/fail_negative_indexing.carbon @@ -42,11 +42,11 @@ var b: i32 = a.(-10); // CHECK:STDOUT: %int_6.e56: %i32 = int_value 6 [concrete] // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_12.1e1, %int_6.e56) [concrete] // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [concrete] -// CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.14 [concrete] +// CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.13 [concrete] // CHECK:STDOUT: %impl_witness.0f6: = impl_witness (imports.%Core.import_ref.c15) [concrete] // CHECK:STDOUT: %Negate.facet: %Negate.type = facet_value Core.IntLiteral, (%impl_witness.0f6) [concrete] // CHECK:STDOUT: %.690: type = fn_type_with_self_type %Op.type.e42, %Negate.facet [concrete] -// CHECK:STDOUT: %Op.type.1be: type = fn_type @Op.15 [concrete] +// CHECK:STDOUT: %Op.type.1be: type = fn_type @Op.14 [concrete] // CHECK:STDOUT: %Op.bba: %Op.type.1be = struct_value () [concrete] // CHECK:STDOUT: %Op.bound: = bound_method %int_10, %Op.bba [concrete] // CHECK:STDOUT: %int_-10: Core.IntLiteral = int_value -10 [concrete] diff --git a/toolchain/check/testdata/tuple/import.carbon b/toolchain/check/testdata/tuple/import.carbon index b95fa8787f26..65c7266893ab 100644 --- a/toolchain/check/testdata/tuple/import.carbon +++ b/toolchain/check/testdata/tuple/import.carbon @@ -358,7 +358,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import_ref.48d: %tuple.type.c2c = import_ref Implicit//default, loc7_9, loaded [symbolic = @C.%X (constants.%X)] // CHECK:STDOUT: %Implicit.import_ref.8f2: = import_ref Implicit//default, loc7_26, loaded [concrete = constants.%complete_type.357] -// CHECK:STDOUT: %Implicit.import_ref.964 = import_ref Implicit//default, inst1191 [no loc], unloaded +// CHECK:STDOUT: %Implicit.import_ref.964 = import_ref Implicit//default, inst1167 [no loc], unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -551,7 +551,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import_ref.48d: %tuple.type.c2c = import_ref Implicit//default, loc7_9, loaded [symbolic = @C.%X (constants.%X)] // CHECK:STDOUT: %Implicit.import_ref.8f2: = import_ref Implicit//default, loc7_26, loaded [concrete = constants.%complete_type.357] -// CHECK:STDOUT: %Implicit.import_ref.964 = import_ref Implicit//default, inst1191 [no loc], unloaded +// CHECK:STDOUT: %Implicit.import_ref.964 = import_ref Implicit//default, inst1167 [no loc], unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -669,7 +669,7 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: } // CHECK:STDOUT: %Implicit.import_ref.48d: %tuple.type.c2c = import_ref Implicit//default, loc7_9, loaded [symbolic = @C.%X (constants.%X)] // CHECK:STDOUT: %Implicit.import_ref.8f2: = import_ref Implicit//default, loc7_26, loaded [concrete = constants.%complete_type.357] -// CHECK:STDOUT: %Implicit.import_ref.964 = import_ref Implicit//default, inst1191 [no loc], unloaded +// CHECK:STDOUT: %Implicit.import_ref.964 = import_ref Implicit//default, inst1167 [no loc], unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { diff --git a/toolchain/check/testdata/where_expr/equal_rewrite.carbon b/toolchain/check/testdata/where_expr/equal_rewrite.carbon index b0515aae3751..d3d6f739d1f0 100644 --- a/toolchain/check/testdata/where_expr/equal_rewrite.carbon +++ b/toolchain/check/testdata/where_expr/equal_rewrite.carbon @@ -1163,8 +1163,8 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: %.Self.as_wit.iface0.e75: = facet_access_witness %.Self.9aa, element0 [symbolic_self] // CHECK:STDOUT: %impl.elem0.a31: type = impl_witness_access %.Self.as_wit.iface0.e75, element0 [symbolic_self] // CHECK:STDOUT: %N_where.type: type = facet_type <@N where %impl.elem0.a31 = %empty_struct_type> [concrete] -// CHECK:STDOUT: %T.patt.68f: %N_where.type = symbolic_binding_pattern T, 0 [symbolic] -// CHECK:STDOUT: %T.8dd: %N_where.type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: %N_where.type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %T: %N_where.type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete] // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete] // CHECK:STDOUT: %NestedRewrite.type: type = fn_type @NestedRewrite [concrete] @@ -1199,7 +1199,7 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: %Main.import_ref.169 = import_ref Main//equal_constraint, inst17 [no loc], unloaded // CHECK:STDOUT: %Main.import_ref.020 = import_ref Main//equal_constraint, loc5_8, unloaded // CHECK:STDOUT: %Main.P = import_ref Main//equal_constraint, P, unloaded -// CHECK:STDOUT: %Main.import_ref.3bc: %N_where.type = import_ref Main//equal_constraint, loc8_10, loaded [symbolic = @Equal.1.%T (constants.%T.8dd)] +// CHECK:STDOUT: %Main.import_ref.3bc: %N_where.type = import_ref Main//equal_constraint, loc8_10, loaded [symbolic = @Equal.1.%T (constants.%T)] // CHECK:STDOUT: %Main.import_ref.b61 = import_ref Main//nested_rewrites, inst17 [no loc], unloaded // CHECK:STDOUT: %Main.import_ref.91a = import_ref Main//nested_rewrites, loc5_8, unloaded // CHECK:STDOUT: %Main.import_ref.55d = import_ref Main//nested_rewrites, loc6_8, unloaded @@ -1250,8 +1250,8 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @Equal.1(imports.%Main.import_ref.3bc: %N_where.type) [from "equal_constraint.carbon"] { -// CHECK:STDOUT: %T: %N_where.type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T.8dd)] -// CHECK:STDOUT: %T.patt.2: %N_where.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.2 (constants.%T.patt.68f)] +// CHECK:STDOUT: %T: %N_where.type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %T.patt.2: %N_where.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.2 (constants.%T.patt)] // CHECK:STDOUT: // CHECK:STDOUT: fn(%T.patt.1: %N_where.type); // CHECK:STDOUT: } @@ -1263,9 +1263,9 @@ let K: (E where .F = .Self.G) = bool; // CHECK:STDOUT: fn(%D.patt.1: %A_where.type.248); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @Equal.1(constants.%T.8dd) { -// CHECK:STDOUT: %T => constants.%T.8dd -// CHECK:STDOUT: %T.patt.2 => constants.%T.8dd +// CHECK:STDOUT: specific @Equal.1(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt.2 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @NestedRewrite(constants.%D) {