From 2c013ada42652fde20d93bbadce4747f0b20fb86 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Thu, 22 May 2025 15:34:12 -0700 Subject: [PATCH] Update choice tests for ranges (#5525) Note the amount of IR excluded is pretty small, but non-zero (mainly prelude-related, due to the way a choice depends on `UInt`) Renaming fail_todo_params.carbon to just params.carbon, and folding in fail_invalid.carbon. --- toolchain/check/testdata/choice/basic.carbon | 368 +++++++----------- .../check/testdata/choice/fail_invalid.carbon | 77 ---- .../testdata/choice/fail_todo_params.carbon | 268 ------------- .../check/testdata/choice/generic.carbon | 47 +-- toolchain/check/testdata/choice/params.carbon | 59 +++ 5 files changed, 210 insertions(+), 609 deletions(-) delete mode 100644 toolchain/check/testdata/choice/fail_invalid.carbon delete mode 100644 toolchain/check/testdata/choice/fail_todo_params.carbon create mode 100644 toolchain/check/testdata/choice/params.carbon diff --git a/toolchain/check/testdata/choice/basic.carbon b/toolchain/check/testdata/choice/basic.carbon index cc1af6a373c2..4181188fc0b7 100644 --- a/toolchain/check/testdata/choice/basic.carbon +++ b/toolchain/check/testdata/choice/basic.carbon @@ -2,6 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // +// EXTRA-ARGS: --dump-sem-ir-ranges=only +// // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/choice/basic.carbon @@ -11,22 +13,25 @@ // --- no_alternative.carbon library "[[@TEST_NAME]]"; +//@dump-sem-ir-begin choice Never {} +//@dump-sem-ir-end // --- one_alternative.carbon library "[[@TEST_NAME]]"; +//@dump-sem-ir-begin choice Always { Sunny } -fn G() { - let mood: Always = Always.Sunny; -} +let mood: Always = Always.Sunny; +//@dump-sem-ir-end // --- multiple_alternatives.carbon library "[[@TEST_NAME]]"; +//@dump-sem-ir-begin choice Ordering { Less, Equivalent, @@ -34,27 +39,23 @@ choice Ordering { Incomparable } -fn H() { - let less: Ordering = Ordering.Less; - let equiv: Ordering = Ordering.Equivalent; - let greater: Ordering = Ordering.Greater; - let inc: Ordering = Ordering.Incomparable; -} +let less: Ordering = Ordering.Less; +let equiv: Ordering = Ordering.Equivalent; +let greater: Ordering = Ordering.Greater; +let inc: Ordering = Ordering.Incomparable; +//@dump-sem-ir-end -// --- fail_todo_empty_params.carbon +// --- fail_no_alternative_construct.carbon library "[[@TEST_NAME]]"; -choice Always { - // CHECK:STDERR: fail_todo_empty_params.carbon:[[@LINE+4]]:8: error: semantics TODO: `empty parameter list should make a member function` [SemanticsTodo] - // CHECK:STDERR: Sunny() - // CHECK:STDERR: ^~ - // CHECK:STDERR: - Sunny() -} +choice Never {} -fn G() { - let mood: Always = Always.Sunny; -} +// TODO: Can we produce a better diagnostic? +// CHECK:STDERR: fail_no_alternative_construct.carbon:[[@LINE+4]]:20: error: cannot initialize class with 1 field from struct with 0 fields [StructInitElementCountMismatch] +// CHECK:STDERR: let never: Never = {}; +// CHECK:STDERR: ^~ +// CHECK:STDERR: +let never: Never = {}; // CHECK:STDOUT: --- no_alternative.carbon // CHECK:STDOUT: @@ -66,18 +67,9 @@ fn G() { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .Never = %Never.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Never.decl: type = class_decl @Never [concrete = constants.%Never] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: @@ -98,44 +90,36 @@ fn G() { // CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.discriminant [concrete] // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete] // CHECK:STDOUT: %Always.val: %Always = struct_value (%empty_tuple) [concrete] -// CHECK:STDOUT: %G.type: type = fn_type @G [concrete] -// CHECK:STDOUT: %G: %G.type = struct_value () [concrete] // CHECK:STDOUT: %pattern_type: type = pattern_type %Always [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .Always = %Always.decl -// CHECK:STDOUT: .G = %G.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Always.decl: type = class_decl @Always [concrete = constants.%Always] {} {} -// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %mood.patt: %pattern_type = binding_pattern mood [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %Always.ref: type = name_ref Always, %Always.decl [concrete = constants.%Always] +// CHECK:STDOUT: %mood: %Always = bind_name mood, @__global_init.%Sunny.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Always { // CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type] -// CHECK:STDOUT: %.loc5_1.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc6_1.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc5_1.2: %empty_tuple.type = converted %.loc5_1.1, %empty_tuple [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc5_1.3: %struct_type.discriminant = struct_literal (%.loc5_1.2) -// CHECK:STDOUT: %.loc5_1.4: ref %Always = temporary_storage -// CHECK:STDOUT: %.loc5_1.5: ref %empty_tuple.type = class_element_access %.loc5_1.4, element0 -// CHECK:STDOUT: %.loc5_1.6: init %empty_tuple.type = tuple_init () to %.loc5_1.5 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc5_1.7: init %empty_tuple.type = converted %.loc5_1.2, %.loc5_1.6 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc5_1.8: init %Always = class_init (%.loc5_1.7), %.loc5_1.4 [concrete = constants.%Always.val] -// CHECK:STDOUT: %.loc5_1.9: ref %Always = temporary %.loc5_1.4, %.loc5_1.8 -// CHECK:STDOUT: %.loc5_1.10: ref %Always = converted %.loc5_1.3, %.loc5_1.9 -// CHECK:STDOUT: %.loc5_1.11: %Always = bind_value %.loc5_1.10 -// CHECK:STDOUT: %Sunny: %Always = bind_name Sunny, %.loc5_1.11 +// CHECK:STDOUT: %.loc6_1.2: %empty_tuple.type = converted %.loc6_1.1, %empty_tuple [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc6_1.3: %struct_type.discriminant = struct_literal (%.loc6_1.2) +// CHECK:STDOUT: %.loc6_1.4: ref %Always = temporary_storage +// CHECK:STDOUT: %.loc6_1.5: ref %empty_tuple.type = class_element_access %.loc6_1.4, element0 +// CHECK:STDOUT: %.loc6_1.6: init %empty_tuple.type = tuple_init () to %.loc6_1.5 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc6_1.7: init %empty_tuple.type = converted %.loc6_1.2, %.loc6_1.6 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc6_1.8: init %Always = class_init (%.loc6_1.7), %.loc6_1.4 [concrete = constants.%Always.val] +// CHECK:STDOUT: %.loc6_1.9: ref %Always = temporary %.loc6_1.4, %.loc6_1.8 +// CHECK:STDOUT: %.loc6_1.10: ref %Always = converted %.loc6_1.3, %.loc6_1.9 +// CHECK:STDOUT: %.loc6_1.11: %Always = bind_value %.loc6_1.10 +// CHECK:STDOUT: %Sunny: %Always = bind_name Sunny, %.loc6_1.11 // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -143,16 +127,11 @@ fn G() { // CHECK:STDOUT: .Sunny = %Sunny // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() { +// CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %mood.patt: %pattern_type = binding_pattern mood [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: %Always.ref.loc8_22: type = name_ref Always, file.%Always.decl [concrete = constants.%Always] +// CHECK:STDOUT: %Always.ref: type = name_ref Always, file.%Always.decl [concrete = constants.%Always] // CHECK:STDOUT: %Sunny.ref: %Always = name_ref Sunny, @Always.%Sunny -// CHECK:STDOUT: %Always.ref.loc8_13: type = name_ref Always, file.%Always.decl [concrete = constants.%Always] -// CHECK:STDOUT: %mood: %Always = bind_name mood, %Sunny.ref -// CHECK:STDOUT: return +// CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- multiple_alternatives.carbon @@ -160,14 +139,10 @@ fn G() { // CHECK:STDOUT: constants { // CHECK:STDOUT: %Ordering: type = class_type @Ordering [concrete] // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete] -// CHECK:STDOUT: %UInt.type: type = generic_class_type @UInt [concrete] -// CHECK:STDOUT: %UInt.generic: %UInt.type = struct_value () [concrete] // CHECK:STDOUT: %u2: type = class_type @UInt, @UInt(%int_2.ecc) [concrete] // CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %u2} [concrete] // CHECK:STDOUT: %complete_type.de2: = complete_type_witness %struct_type.discriminant [concrete] // CHECK:STDOUT: %int_0.5c6: 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: %ImplicitAs.type.54b: type = facet_type <@ImplicitAs, @ImplicitAs(%u2)> [concrete] // CHECK:STDOUT: %Convert.type.f0e: type = fn_type @Convert.1, @ImplicitAs(%u2) [concrete] // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] @@ -197,107 +172,110 @@ fn G() { // CHECK:STDOUT: %bound_method.c7e: = bound_method %int_3.1ba, %Convert.specific_fn [concrete] // CHECK:STDOUT: %int_3.975: %u2 = int_value 3 [concrete] // CHECK:STDOUT: %Ordering.val.8a7: %Ordering = struct_value (%int_3.975) [concrete] -// CHECK:STDOUT: %H.type: type = fn_type @H [concrete] -// CHECK:STDOUT: %H: %H.type = struct_value () [concrete] // CHECK:STDOUT: %pattern_type.308: type = pattern_type %Ordering [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .UInt = %Core.UInt -// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.UInt: %UInt.type = import_ref Core//prelude/types/uint, UInt, loaded [concrete = constants.%UInt.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.c3d: @impl.86e.%Convert.type (%Convert.type.30e) = import_ref Core//prelude/types/uint, loc20_40, loaded [symbolic = @impl.86e.%Convert (constants.%Convert.d1a)] // CHECK:STDOUT: %ImplicitAs.impl_witness_table.bb8 = impl_witness_table (%Core.import_ref.c3d), @impl.86e [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .Ordering = %Ordering.decl -// CHECK:STDOUT: .H = %H.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Ordering.decl: type = class_decl @Ordering [concrete = constants.%Ordering] {} {} -// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {} {} +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %less.patt: %pattern_type.308 = binding_pattern less [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %Ordering.ref.loc11: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %less: %Ordering = bind_name less, @__global_init.%Less.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %equiv.patt: %pattern_type.308 = binding_pattern equiv [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %Ordering.ref.loc12: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %equiv: %Ordering = bind_name equiv, @__global_init.%Equivalent.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %greater.patt: %pattern_type.308 = binding_pattern greater [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %Ordering.ref.loc13: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %greater: %Ordering = bind_name greater, @__global_init.%Greater.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %inc.patt: %pattern_type.308 = binding_pattern inc [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %Ordering.ref.loc14: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %inc: %Ordering = bind_name inc, @__global_init.%Incomparable.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Ordering { -// CHECK:STDOUT: %int_2.loc8: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %int_2.loc9: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] // CHECK:STDOUT: %u2: type = class_type @UInt, @UInt(constants.%int_2.ecc) [concrete = constants.%u2] // CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type.de2] // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %impl.elem0.loc4: %.3e0 = impl_witness_access constants.%ImplicitAs.impl_witness.801, element0 [concrete = constants.%Convert.474] -// CHECK:STDOUT: %bound_method.loc4_7.1: = bound_method %int_0, %impl.elem0.loc4 [concrete = constants.%Convert.bound.5bb] -// CHECK:STDOUT: %specific_fn.loc4: = specific_function %impl.elem0.loc4, @Convert.2(constants.%int_2.ecc) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc4_7.2: = bound_method %int_0, %specific_fn.loc4 [concrete = constants.%bound_method.d36] -// CHECK:STDOUT: %int.convert_checked.loc4: init %u2 = call %bound_method.loc4_7.2(%int_0) [concrete = constants.%int_0.9fd] -// CHECK:STDOUT: %.loc4_7.1: %u2 = value_of_initializer %int.convert_checked.loc4 [concrete = constants.%int_0.9fd] -// CHECK:STDOUT: %.loc4_7.2: %u2 = converted %int_0, %.loc4_7.1 [concrete = constants.%int_0.9fd] -// CHECK:STDOUT: %.loc4_7.3: %struct_type.discriminant = struct_literal (%.loc4_7.2) -// CHECK:STDOUT: %.loc4_7.4: ref %Ordering = temporary_storage -// CHECK:STDOUT: %.loc4_7.5: ref %u2 = class_element_access %.loc4_7.4, element0 -// CHECK:STDOUT: %.loc4_7.6: init %u2 = initialize_from %.loc4_7.2 to %.loc4_7.5 [concrete = constants.%int_0.9fd] -// CHECK:STDOUT: %.loc4_7.7: init %Ordering = class_init (%.loc4_7.6), %.loc4_7.4 [concrete = constants.%Ordering.val.a29] -// CHECK:STDOUT: %.loc4_7.8: ref %Ordering = temporary %.loc4_7.4, %.loc4_7.7 -// CHECK:STDOUT: %.loc4_7.9: ref %Ordering = converted %.loc4_7.3, %.loc4_7.8 -// CHECK:STDOUT: %.loc4_7.10: %Ordering = bind_value %.loc4_7.9 -// CHECK:STDOUT: %Less: %Ordering = bind_name Less, %.loc4_7.10 -// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc5: %.3e0 = impl_witness_access constants.%ImplicitAs.impl_witness.801, element0 [concrete = constants.%Convert.474] -// CHECK:STDOUT: %bound_method.loc5_13.1: = bound_method %int_1, %impl.elem0.loc5 [concrete = constants.%Convert.bound.0dd] +// CHECK:STDOUT: %bound_method.loc5_7.1: = bound_method %int_0, %impl.elem0.loc5 [concrete = constants.%Convert.bound.5bb] // CHECK:STDOUT: %specific_fn.loc5: = specific_function %impl.elem0.loc5, @Convert.2(constants.%int_2.ecc) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc5_13.2: = bound_method %int_1, %specific_fn.loc5 [concrete = constants.%bound_method.6bf] -// CHECK:STDOUT: %int.convert_checked.loc5: init %u2 = call %bound_method.loc5_13.2(%int_1) [concrete = constants.%int_1.b2c] -// CHECK:STDOUT: %.loc5_13.1: %u2 = value_of_initializer %int.convert_checked.loc5 [concrete = constants.%int_1.b2c] -// CHECK:STDOUT: %.loc5_13.2: %u2 = converted %int_1, %.loc5_13.1 [concrete = constants.%int_1.b2c] -// CHECK:STDOUT: %.loc5_13.3: %struct_type.discriminant = struct_literal (%.loc5_13.2) -// CHECK:STDOUT: %.loc5_13.4: ref %Ordering = temporary_storage -// CHECK:STDOUT: %.loc5_13.5: ref %u2 = class_element_access %.loc5_13.4, element0 -// CHECK:STDOUT: %.loc5_13.6: init %u2 = initialize_from %.loc5_13.2 to %.loc5_13.5 [concrete = constants.%int_1.b2c] -// CHECK:STDOUT: %.loc5_13.7: init %Ordering = class_init (%.loc5_13.6), %.loc5_13.4 [concrete = constants.%Ordering.val.927] -// CHECK:STDOUT: %.loc5_13.8: ref %Ordering = temporary %.loc5_13.4, %.loc5_13.7 -// CHECK:STDOUT: %.loc5_13.9: ref %Ordering = converted %.loc5_13.3, %.loc5_13.8 -// CHECK:STDOUT: %.loc5_13.10: %Ordering = bind_value %.loc5_13.9 -// CHECK:STDOUT: %Equivalent: %Ordering = bind_name Equivalent, %.loc5_13.10 -// CHECK:STDOUT: %int_2.loc6: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %bound_method.loc5_7.2: = bound_method %int_0, %specific_fn.loc5 [concrete = constants.%bound_method.d36] +// CHECK:STDOUT: %int.convert_checked.loc5: init %u2 = call %bound_method.loc5_7.2(%int_0) [concrete = constants.%int_0.9fd] +// CHECK:STDOUT: %.loc5_7.1: %u2 = value_of_initializer %int.convert_checked.loc5 [concrete = constants.%int_0.9fd] +// CHECK:STDOUT: %.loc5_7.2: %u2 = converted %int_0, %.loc5_7.1 [concrete = constants.%int_0.9fd] +// CHECK:STDOUT: %.loc5_7.3: %struct_type.discriminant = struct_literal (%.loc5_7.2) +// CHECK:STDOUT: %.loc5_7.4: ref %Ordering = temporary_storage +// CHECK:STDOUT: %.loc5_7.5: ref %u2 = class_element_access %.loc5_7.4, element0 +// CHECK:STDOUT: %.loc5_7.6: init %u2 = initialize_from %.loc5_7.2 to %.loc5_7.5 [concrete = constants.%int_0.9fd] +// CHECK:STDOUT: %.loc5_7.7: init %Ordering = class_init (%.loc5_7.6), %.loc5_7.4 [concrete = constants.%Ordering.val.a29] +// CHECK:STDOUT: %.loc5_7.8: ref %Ordering = temporary %.loc5_7.4, %.loc5_7.7 +// CHECK:STDOUT: %.loc5_7.9: ref %Ordering = converted %.loc5_7.3, %.loc5_7.8 +// CHECK:STDOUT: %.loc5_7.10: %Ordering = bind_value %.loc5_7.9 +// CHECK:STDOUT: %Less: %Ordering = bind_name Less, %.loc5_7.10 +// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] // CHECK:STDOUT: %impl.elem0.loc6: %.3e0 = impl_witness_access constants.%ImplicitAs.impl_witness.801, element0 [concrete = constants.%Convert.474] -// CHECK:STDOUT: %bound_method.loc6_10.1: = bound_method %int_2.loc6, %impl.elem0.loc6 [concrete = constants.%Convert.bound.122] +// CHECK:STDOUT: %bound_method.loc6_13.1: = bound_method %int_1, %impl.elem0.loc6 [concrete = constants.%Convert.bound.0dd] // CHECK:STDOUT: %specific_fn.loc6: = specific_function %impl.elem0.loc6, @Convert.2(constants.%int_2.ecc) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc6_10.2: = bound_method %int_2.loc6, %specific_fn.loc6 [concrete = constants.%bound_method.f7d] -// CHECK:STDOUT: %int.convert_checked.loc6: init %u2 = call %bound_method.loc6_10.2(%int_2.loc6) [concrete = constants.%int_2.788] -// CHECK:STDOUT: %.loc6_10.1: %u2 = value_of_initializer %int.convert_checked.loc6 [concrete = constants.%int_2.788] -// CHECK:STDOUT: %.loc6_10.2: %u2 = converted %int_2.loc6, %.loc6_10.1 [concrete = constants.%int_2.788] -// CHECK:STDOUT: %.loc6_10.3: %struct_type.discriminant = struct_literal (%.loc6_10.2) -// CHECK:STDOUT: %.loc6_10.4: ref %Ordering = temporary_storage -// CHECK:STDOUT: %.loc6_10.5: ref %u2 = class_element_access %.loc6_10.4, element0 -// CHECK:STDOUT: %.loc6_10.6: init %u2 = initialize_from %.loc6_10.2 to %.loc6_10.5 [concrete = constants.%int_2.788] -// CHECK:STDOUT: %.loc6_10.7: init %Ordering = class_init (%.loc6_10.6), %.loc6_10.4 [concrete = constants.%Ordering.val.968] -// CHECK:STDOUT: %.loc6_10.8: ref %Ordering = temporary %.loc6_10.4, %.loc6_10.7 -// CHECK:STDOUT: %.loc6_10.9: ref %Ordering = converted %.loc6_10.3, %.loc6_10.8 -// CHECK:STDOUT: %.loc6_10.10: %Ordering = bind_value %.loc6_10.9 -// CHECK:STDOUT: %Greater: %Ordering = bind_name Greater, %.loc6_10.10 +// CHECK:STDOUT: %bound_method.loc6_13.2: = bound_method %int_1, %specific_fn.loc6 [concrete = constants.%bound_method.6bf] +// CHECK:STDOUT: %int.convert_checked.loc6: init %u2 = call %bound_method.loc6_13.2(%int_1) [concrete = constants.%int_1.b2c] +// CHECK:STDOUT: %.loc6_13.1: %u2 = value_of_initializer %int.convert_checked.loc6 [concrete = constants.%int_1.b2c] +// CHECK:STDOUT: %.loc6_13.2: %u2 = converted %int_1, %.loc6_13.1 [concrete = constants.%int_1.b2c] +// CHECK:STDOUT: %.loc6_13.3: %struct_type.discriminant = struct_literal (%.loc6_13.2) +// CHECK:STDOUT: %.loc6_13.4: ref %Ordering = temporary_storage +// CHECK:STDOUT: %.loc6_13.5: ref %u2 = class_element_access %.loc6_13.4, element0 +// CHECK:STDOUT: %.loc6_13.6: init %u2 = initialize_from %.loc6_13.2 to %.loc6_13.5 [concrete = constants.%int_1.b2c] +// CHECK:STDOUT: %.loc6_13.7: init %Ordering = class_init (%.loc6_13.6), %.loc6_13.4 [concrete = constants.%Ordering.val.927] +// CHECK:STDOUT: %.loc6_13.8: ref %Ordering = temporary %.loc6_13.4, %.loc6_13.7 +// CHECK:STDOUT: %.loc6_13.9: ref %Ordering = converted %.loc6_13.3, %.loc6_13.8 +// CHECK:STDOUT: %.loc6_13.10: %Ordering = bind_value %.loc6_13.9 +// CHECK:STDOUT: %Equivalent: %Ordering = bind_name Equivalent, %.loc6_13.10 +// CHECK:STDOUT: %int_2.loc7: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc] +// CHECK:STDOUT: %impl.elem0.loc7: %.3e0 = impl_witness_access constants.%ImplicitAs.impl_witness.801, element0 [concrete = constants.%Convert.474] +// CHECK:STDOUT: %bound_method.loc7_10.1: = bound_method %int_2.loc7, %impl.elem0.loc7 [concrete = constants.%Convert.bound.122] +// CHECK:STDOUT: %specific_fn.loc7: = specific_function %impl.elem0.loc7, @Convert.2(constants.%int_2.ecc) [concrete = constants.%Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc7_10.2: = bound_method %int_2.loc7, %specific_fn.loc7 [concrete = constants.%bound_method.f7d] +// CHECK:STDOUT: %int.convert_checked.loc7: init %u2 = call %bound_method.loc7_10.2(%int_2.loc7) [concrete = constants.%int_2.788] +// CHECK:STDOUT: %.loc7_10.1: %u2 = value_of_initializer %int.convert_checked.loc7 [concrete = constants.%int_2.788] +// CHECK:STDOUT: %.loc7_10.2: %u2 = converted %int_2.loc7, %.loc7_10.1 [concrete = constants.%int_2.788] +// CHECK:STDOUT: %.loc7_10.3: %struct_type.discriminant = struct_literal (%.loc7_10.2) +// CHECK:STDOUT: %.loc7_10.4: ref %Ordering = temporary_storage +// CHECK:STDOUT: %.loc7_10.5: ref %u2 = class_element_access %.loc7_10.4, element0 +// CHECK:STDOUT: %.loc7_10.6: init %u2 = initialize_from %.loc7_10.2 to %.loc7_10.5 [concrete = constants.%int_2.788] +// CHECK:STDOUT: %.loc7_10.7: init %Ordering = class_init (%.loc7_10.6), %.loc7_10.4 [concrete = constants.%Ordering.val.968] +// CHECK:STDOUT: %.loc7_10.8: ref %Ordering = temporary %.loc7_10.4, %.loc7_10.7 +// CHECK:STDOUT: %.loc7_10.9: ref %Ordering = converted %.loc7_10.3, %.loc7_10.8 +// CHECK:STDOUT: %.loc7_10.10: %Ordering = bind_value %.loc7_10.9 +// CHECK:STDOUT: %Greater: %Ordering = bind_name Greater, %.loc7_10.10 // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba] -// CHECK:STDOUT: %impl.elem0.loc8: %.3e0 = impl_witness_access constants.%ImplicitAs.impl_witness.801, element0 [concrete = constants.%Convert.474] -// CHECK:STDOUT: %bound_method.loc8_1.1: = bound_method %int_3, %impl.elem0.loc8 [concrete = constants.%Convert.bound.a5c] -// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Convert.2(constants.%int_2.ecc) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc8_1.2: = bound_method %int_3, %specific_fn.loc8 [concrete = constants.%bound_method.c7e] -// CHECK:STDOUT: %int.convert_checked.loc8: init %u2 = call %bound_method.loc8_1.2(%int_3) [concrete = constants.%int_3.975] -// CHECK:STDOUT: %.loc8_1.1: %u2 = value_of_initializer %int.convert_checked.loc8 [concrete = constants.%int_3.975] -// CHECK:STDOUT: %.loc8_1.2: %u2 = converted %int_3, %.loc8_1.1 [concrete = constants.%int_3.975] -// CHECK:STDOUT: %.loc8_1.3: %struct_type.discriminant = struct_literal (%.loc8_1.2) -// CHECK:STDOUT: %.loc8_1.4: ref %Ordering = temporary_storage -// CHECK:STDOUT: %.loc8_1.5: ref %u2 = class_element_access %.loc8_1.4, element0 -// CHECK:STDOUT: %.loc8_1.6: init %u2 = initialize_from %.loc8_1.2 to %.loc8_1.5 [concrete = constants.%int_3.975] -// CHECK:STDOUT: %.loc8_1.7: init %Ordering = class_init (%.loc8_1.6), %.loc8_1.4 [concrete = constants.%Ordering.val.8a7] -// CHECK:STDOUT: %.loc8_1.8: ref %Ordering = temporary %.loc8_1.4, %.loc8_1.7 -// CHECK:STDOUT: %.loc8_1.9: ref %Ordering = converted %.loc8_1.3, %.loc8_1.8 -// CHECK:STDOUT: %.loc8_1.10: %Ordering = bind_value %.loc8_1.9 -// CHECK:STDOUT: %Incomparable: %Ordering = bind_name Incomparable, %.loc8_1.10 +// CHECK:STDOUT: %impl.elem0.loc9: %.3e0 = impl_witness_access constants.%ImplicitAs.impl_witness.801, element0 [concrete = constants.%Convert.474] +// CHECK:STDOUT: %bound_method.loc9_1.1: = bound_method %int_3, %impl.elem0.loc9 [concrete = constants.%Convert.bound.a5c] +// CHECK:STDOUT: %specific_fn.loc9: = specific_function %impl.elem0.loc9, @Convert.2(constants.%int_2.ecc) [concrete = constants.%Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc9_1.2: = bound_method %int_3, %specific_fn.loc9 [concrete = constants.%bound_method.c7e] +// CHECK:STDOUT: %int.convert_checked.loc9: init %u2 = call %bound_method.loc9_1.2(%int_3) [concrete = constants.%int_3.975] +// CHECK:STDOUT: %.loc9_1.1: %u2 = value_of_initializer %int.convert_checked.loc9 [concrete = constants.%int_3.975] +// CHECK:STDOUT: %.loc9_1.2: %u2 = converted %int_3, %.loc9_1.1 [concrete = constants.%int_3.975] +// CHECK:STDOUT: %.loc9_1.3: %struct_type.discriminant = struct_literal (%.loc9_1.2) +// CHECK:STDOUT: %.loc9_1.4: ref %Ordering = temporary_storage +// CHECK:STDOUT: %.loc9_1.5: ref %u2 = class_element_access %.loc9_1.4, element0 +// CHECK:STDOUT: %.loc9_1.6: init %u2 = initialize_from %.loc9_1.2 to %.loc9_1.5 [concrete = constants.%int_3.975] +// CHECK:STDOUT: %.loc9_1.7: init %Ordering = class_init (%.loc9_1.6), %.loc9_1.4 [concrete = constants.%Ordering.val.8a7] +// CHECK:STDOUT: %.loc9_1.8: ref %Ordering = temporary %.loc9_1.4, %.loc9_1.7 +// CHECK:STDOUT: %.loc9_1.9: ref %Ordering = converted %.loc9_1.3, %.loc9_1.8 +// CHECK:STDOUT: %.loc9_1.10: %Ordering = bind_value %.loc9_1.9 +// CHECK:STDOUT: %Incomparable: %Ordering = bind_name Incomparable, %.loc9_1.10 // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -308,102 +286,16 @@ fn G() { // CHECK:STDOUT: .Incomparable = %Incomparable // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @H() { +// CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %less.patt: %pattern_type.308 = binding_pattern less [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: %Ordering.ref.loc11_24: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %Ordering.ref.loc11: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] // CHECK:STDOUT: %Less.ref: %Ordering = name_ref Less, @Ordering.%Less -// CHECK:STDOUT: %Ordering.ref.loc11_13: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] -// CHECK:STDOUT: %less: %Ordering = bind_name less, %Less.ref -// CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %equiv.patt: %pattern_type.308 = binding_pattern equiv [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: %Ordering.ref.loc12_25: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %Ordering.ref.loc12: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] // CHECK:STDOUT: %Equivalent.ref: %Ordering = name_ref Equivalent, @Ordering.%Equivalent -// CHECK:STDOUT: %Ordering.ref.loc12_14: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] -// CHECK:STDOUT: %equiv: %Ordering = bind_name equiv, %Equivalent.ref -// CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %greater.patt: %pattern_type.308 = binding_pattern greater [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: %Ordering.ref.loc13_27: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %Ordering.ref.loc13: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] // CHECK:STDOUT: %Greater.ref: %Ordering = name_ref Greater, @Ordering.%Greater -// CHECK:STDOUT: %Ordering.ref.loc13_16: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] -// CHECK:STDOUT: %greater: %Ordering = bind_name greater, %Greater.ref -// CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %inc.patt: %pattern_type.308 = binding_pattern inc [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: %Ordering.ref.loc14_23: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] +// CHECK:STDOUT: %Ordering.ref.loc14: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] // CHECK:STDOUT: %Incomparable.ref: %Ordering = name_ref Incomparable, @Ordering.%Incomparable -// CHECK:STDOUT: %Ordering.ref.loc14_12: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering] -// CHECK:STDOUT: %inc: %Ordering = bind_name inc, %Incomparable.ref -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_empty_params.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %Always: type = class_type @Always [concrete] -// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] -// CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %empty_tuple.type} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.discriminant [concrete] -// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete] -// CHECK:STDOUT: %Always.val: %Always = struct_value (%empty_tuple) [concrete] -// CHECK:STDOUT: %G.type: type = fn_type @G [concrete] -// CHECK:STDOUT: %G: %G.type = struct_value () [concrete] -// CHECK:STDOUT: %pattern_type: type = pattern_type %Always [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .Always = %Always.decl -// CHECK:STDOUT: .G = %G.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Always.decl: type = class_decl @Always [concrete = constants.%Always] {} {} -// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @Always { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type] -// CHECK:STDOUT: %.loc9_1.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc9_1.2: %empty_tuple.type = converted %.loc9_1.1, %empty_tuple [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc9_1.3: %struct_type.discriminant = struct_literal (%.loc9_1.2) -// CHECK:STDOUT: %.loc9_1.4: ref %Always = temporary_storage -// CHECK:STDOUT: %.loc9_1.5: ref %empty_tuple.type = class_element_access %.loc9_1.4, element0 -// CHECK:STDOUT: %.loc9_1.6: init %empty_tuple.type = tuple_init () to %.loc9_1.5 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc9_1.7: init %empty_tuple.type = converted %.loc9_1.2, %.loc9_1.6 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc9_1.8: init %Always = class_init (%.loc9_1.7), %.loc9_1.4 [concrete = constants.%Always.val] -// CHECK:STDOUT: %.loc9_1.9: ref %Always = temporary %.loc9_1.4, %.loc9_1.8 -// CHECK:STDOUT: %.loc9_1.10: ref %Always = converted %.loc9_1.3, %.loc9_1.9 -// CHECK:STDOUT: %.loc9_1.11: %Always = bind_value %.loc9_1.10 -// CHECK:STDOUT: %Sunny: %Always = bind_name Sunny, %.loc9_1.11 -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Always -// CHECK:STDOUT: .Sunny = %Sunny -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @G() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %mood.patt: %pattern_type = binding_pattern mood [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: %Always.ref.loc12_22: type = name_ref Always, file.%Always.decl [concrete = constants.%Always] -// CHECK:STDOUT: %Sunny.ref: %Always = name_ref Sunny, @Always.%Sunny -// CHECK:STDOUT: %Always.ref.loc12_13: type = name_ref Always, file.%Always.decl [concrete = constants.%Always] -// CHECK:STDOUT: %mood: %Always = bind_name mood, %Sunny.ref -// CHECK:STDOUT: return +// CHECK:STDOUT: // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/choice/fail_invalid.carbon b/toolchain/check/testdata/choice/fail_invalid.carbon deleted file mode 100644 index e960cc576650..000000000000 --- a/toolchain/check/testdata/choice/fail_invalid.carbon +++ /dev/null @@ -1,77 +0,0 @@ -// 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 -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/choice/fail_invalid.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/choice/fail_invalid.carbon - -// --- fail_no_alternative_construct.carbon -library "[[@TEST_NAME]]"; - -choice Never {} - -fn F() { - // TODO: Can we produce a better diagnostic? - // CHECK:STDERR: fail_no_alternative_construct.carbon:[[@LINE+4]]:22: error: cannot initialize class with 1 field from struct with 0 fields [StructInitElementCountMismatch] - // CHECK:STDERR: let never: Never = {}; - // CHECK:STDERR: ^~ - // CHECK:STDERR: - let never: Never = {}; -} - -// CHECK:STDOUT: --- fail_no_alternative_construct.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %Never: type = class_type @Never [concrete] -// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] -// CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %empty_tuple.type} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.discriminant [concrete] -// CHECK:STDOUT: %F.type: type = fn_type @F [concrete] -// CHECK:STDOUT: %F: %F.type = struct_value () [concrete] -// CHECK:STDOUT: %pattern_type: type = pattern_type %Never [concrete] -// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .Never = %Never.decl -// CHECK:STDOUT: .F = %F.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %Never.decl: type = class_decl @Never [concrete = constants.%Never] {} {} -// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @Never { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%Never -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @F() { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: name_binding_decl { -// CHECK:STDOUT: %never.patt: %pattern_type = binding_pattern never [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: %.loc11_23.1: %empty_struct_type = struct_literal () -// CHECK:STDOUT: %Never.ref: type = name_ref Never, file.%Never.decl [concrete = constants.%Never] -// CHECK:STDOUT: %.loc11_23.2: ref %Never = temporary_storage -// CHECK:STDOUT: %.loc11_23.3: ref %Never = temporary %.loc11_23.2, [concrete = ] -// CHECK:STDOUT: %.loc11_23.4: ref %Never = converted %.loc11_23.1, %.loc11_23.3 [concrete = ] -// CHECK:STDOUT: %never: ref %Never = bind_name never, %.loc11_23.4 -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/choice/fail_todo_params.carbon b/toolchain/check/testdata/choice/fail_todo_params.carbon deleted file mode 100644 index 6961ac1f52b0..000000000000 --- a/toolchain/check/testdata/choice/fail_todo_params.carbon +++ /dev/null @@ -1,268 +0,0 @@ -// 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 -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/choice/fail_todo_params.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/choice/fail_todo_params.carbon - -// --- fail_todo_params.carbon -library "[[@TEST_NAME]]"; - -choice C { - Alt1, - // CHECK:STDERR: fail_todo_params.carbon:[[@LINE+4]]:7: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo] - // CHECK:STDERR: Alt2(a: i32, b: i64), - // CHECK:STDERR: ^~~~~~~~~~~~~~~~ - // CHECK:STDERR: - Alt2(a: i32, b: i64), - Alt3, -} - -// --- fail_todo_generic_params.carbon -library "[[@TEST_NAME]]"; - -choice C(T:! type) { - // CHECK:STDERR: fail_todo_generic_params.carbon:[[@LINE+4]]:6: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo] - // CHECK:STDERR: Alt(a: T) - // CHECK:STDERR: ^~~~~~ - // CHECK:STDERR: - Alt(a: T) -} - -// --- fail_todo_self_param.carbon -library "[[@TEST_NAME]]"; - -choice C { - // CHECK:STDERR: fail_todo_self_param.carbon:[[@LINE+4]]:6: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo] - // CHECK:STDERR: Alt(a: Self*) - // CHECK:STDERR: ^~~~~~~~~~ - // CHECK:STDERR: - Alt(a: Self*) -} - -// CHECK:STDOUT: --- fail_todo_params.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %C: type = class_type @C [concrete] -// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] -// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete] -// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete] -// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] -// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] -// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete] -// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] -// CHECK:STDOUT: %UInt.type: type = generic_class_type @UInt [concrete] -// CHECK:STDOUT: %UInt.generic: %UInt.type = struct_value () [concrete] -// CHECK:STDOUT: %u1: type = class_type @UInt, @UInt(%int_1.5b8) [concrete] -// CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %u1} [concrete] -// CHECK:STDOUT: %complete_type.df6: = complete_type_witness %struct_type.discriminant [concrete] -// CHECK:STDOUT: %int_0.5c6: 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: %ImplicitAs.type.766: type = facet_type <@ImplicitAs, @ImplicitAs(%u1)> [concrete] -// CHECK:STDOUT: %Convert.type.5a2: type = fn_type @Convert.1, @ImplicitAs(%u1) [concrete] -// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] -// CHECK:STDOUT: %Convert.type.30e: type = fn_type @Convert.2, @impl.86e(%To.c80) [symbolic] -// CHECK:STDOUT: %Convert.d1a: %Convert.type.30e = struct_value () [symbolic] -// CHECK:STDOUT: %ImplicitAs.impl_witness.123: = impl_witness imports.%ImplicitAs.impl_witness_table.bb8, @impl.86e(%int_1.5b8) [concrete] -// CHECK:STDOUT: %Convert.type.f9b: type = fn_type @Convert.2, @impl.86e(%int_1.5b8) [concrete] -// CHECK:STDOUT: %Convert.84e: %Convert.type.f9b = struct_value () [concrete] -// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.766 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.123) [concrete] -// CHECK:STDOUT: %.48b: type = fn_type_with_self_type %Convert.type.5a2, %ImplicitAs.facet [concrete] -// CHECK:STDOUT: %Convert.bound.db0: = bound_method %int_0.5c6, %Convert.84e [concrete] -// CHECK:STDOUT: %Convert.specific_fn: = specific_function %Convert.84e, @Convert.2(%int_1.5b8) [concrete] -// CHECK:STDOUT: %bound_method.06f: = bound_method %int_0.5c6, %Convert.specific_fn [concrete] -// CHECK:STDOUT: %int_0.cd3: %u1 = int_value 0 [concrete] -// CHECK:STDOUT: %C.val.6ef: %C = struct_value (%int_0.cd3) [concrete] -// CHECK:STDOUT: %Convert.bound.1f9: = bound_method %int_1.5b8, %Convert.84e [concrete] -// CHECK:STDOUT: %bound_method.734: = bound_method %int_1.5b8, %Convert.specific_fn [concrete] -// CHECK:STDOUT: %int_1.ae4: %u1 = int_value 1 [concrete] -// CHECK:STDOUT: %C.val.5bf: %C = struct_value (%int_1.ae4) [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .Int = %Core.Int -// CHECK:STDOUT: .UInt = %Core.UInt -// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic] -// CHECK:STDOUT: %Core.UInt: %UInt.type = import_ref Core//prelude/types/uint, UInt, loaded [concrete = constants.%UInt.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.c3d: @impl.86e.%Convert.type (%Convert.type.30e) = import_ref Core//prelude/types/uint, loc20_40, loaded [symbolic = @impl.86e.%Convert (constants.%Convert.d1a)] -// CHECK:STDOUT: %ImplicitAs.impl_witness_table.bb8 = impl_witness_table (%Core.import_ref.c3d), @impl.86e [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: %a.param: %i32 = value_param call_param0 -// CHECK:STDOUT: %.loc9_11: type = splice_block %i32 [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: } -// CHECK:STDOUT: %a: %i32 = bind_name a, %a.param -// CHECK:STDOUT: %b.param: %i64 = value_param call_param1 -// CHECK:STDOUT: %.loc9_19: type = splice_block %i64 [concrete = constants.%i64] { -// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] -// CHECK:STDOUT: %i64: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] -// CHECK:STDOUT: } -// CHECK:STDOUT: %b: %i64 = bind_name b, %b.param -// CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %u1: type = class_type @UInt, @UInt(constants.%int_1.5b8) [concrete = constants.%u1] -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type.df6] -// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6] -// CHECK:STDOUT: %impl.elem0.loc4: %.48b = impl_witness_access constants.%ImplicitAs.impl_witness.123, element0 [concrete = constants.%Convert.84e] -// CHECK:STDOUT: %bound_method.loc4_7.1: = bound_method %int_0, %impl.elem0.loc4 [concrete = constants.%Convert.bound.db0] -// CHECK:STDOUT: %specific_fn.loc4: = specific_function %impl.elem0.loc4, @Convert.2(constants.%int_1.5b8) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc4_7.2: = bound_method %int_0, %specific_fn.loc4 [concrete = constants.%bound_method.06f] -// CHECK:STDOUT: %int.convert_checked.loc4: init %u1 = call %bound_method.loc4_7.2(%int_0) [concrete = constants.%int_0.cd3] -// CHECK:STDOUT: %.loc4_7.1: %u1 = value_of_initializer %int.convert_checked.loc4 [concrete = constants.%int_0.cd3] -// CHECK:STDOUT: %.loc4_7.2: %u1 = converted %int_0, %.loc4_7.1 [concrete = constants.%int_0.cd3] -// CHECK:STDOUT: %.loc4_7.3: %struct_type.discriminant = struct_literal (%.loc4_7.2) -// CHECK:STDOUT: %.loc4_7.4: ref %C = temporary_storage -// CHECK:STDOUT: %.loc4_7.5: ref %u1 = class_element_access %.loc4_7.4, element0 -// CHECK:STDOUT: %.loc4_7.6: init %u1 = initialize_from %.loc4_7.2 to %.loc4_7.5 [concrete = constants.%int_0.cd3] -// CHECK:STDOUT: %.loc4_7.7: init %C = class_init (%.loc4_7.6), %.loc4_7.4 [concrete = constants.%C.val.6ef] -// CHECK:STDOUT: %.loc4_7.8: ref %C = temporary %.loc4_7.4, %.loc4_7.7 -// CHECK:STDOUT: %.loc4_7.9: ref %C = converted %.loc4_7.3, %.loc4_7.8 -// CHECK:STDOUT: %.loc4_7.10: %C = bind_value %.loc4_7.9 -// CHECK:STDOUT: %Alt1: %C = bind_name Alt1, %.loc4_7.10 -// CHECK:STDOUT: %int_1.loc10: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] -// CHECK:STDOUT: %impl.elem0.loc10: %.48b = impl_witness_access constants.%ImplicitAs.impl_witness.123, element0 [concrete = constants.%Convert.84e] -// CHECK:STDOUT: %bound_method.loc10_7.1: = bound_method %int_1.loc10, %impl.elem0.loc10 [concrete = constants.%Convert.bound.1f9] -// CHECK:STDOUT: %specific_fn.loc10: = specific_function %impl.elem0.loc10, @Convert.2(constants.%int_1.5b8) [concrete = constants.%Convert.specific_fn] -// CHECK:STDOUT: %bound_method.loc10_7.2: = bound_method %int_1.loc10, %specific_fn.loc10 [concrete = constants.%bound_method.734] -// CHECK:STDOUT: %int.convert_checked.loc10: init %u1 = call %bound_method.loc10_7.2(%int_1.loc10) [concrete = constants.%int_1.ae4] -// CHECK:STDOUT: %.loc10_7.1: %u1 = value_of_initializer %int.convert_checked.loc10 [concrete = constants.%int_1.ae4] -// CHECK:STDOUT: %.loc10_7.2: %u1 = converted %int_1.loc10, %.loc10_7.1 [concrete = constants.%int_1.ae4] -// CHECK:STDOUT: %.loc10_7.3: %struct_type.discriminant = struct_literal (%.loc10_7.2) -// CHECK:STDOUT: %.loc10_7.4: ref %C = temporary_storage -// CHECK:STDOUT: %.loc10_7.5: ref %u1 = class_element_access %.loc10_7.4, element0 -// CHECK:STDOUT: %.loc10_7.6: init %u1 = initialize_from %.loc10_7.2 to %.loc10_7.5 [concrete = constants.%int_1.ae4] -// CHECK:STDOUT: %.loc10_7.7: init %C = class_init (%.loc10_7.6), %.loc10_7.4 [concrete = constants.%C.val.5bf] -// CHECK:STDOUT: %.loc10_7.8: ref %C = temporary %.loc10_7.4, %.loc10_7.7 -// CHECK:STDOUT: %.loc10_7.9: ref %C = converted %.loc10_7.3, %.loc10_7.8 -// CHECK:STDOUT: %.loc10_7.10: %C = bind_value %.loc10_7.9 -// CHECK:STDOUT: %Alt3: %C = bind_name Alt3, %.loc10_7.10 -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .a = %a -// CHECK:STDOUT: .b = %b -// CHECK:STDOUT: .Alt1 = %Alt1 -// CHECK:STDOUT: .Alt3 = %Alt3 -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_generic_params.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] -// CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete] -// CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete] -// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] -// CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete] -// CHECK:STDOUT: %C: type = class_type @C, @C(%T) [symbolic] -// CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T [symbolic] -// CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %empty_tuple.type} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.discriminant [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %C.decl: %C.type = class_decl @C [concrete = constants.%C.generic] { -// CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %T.loc3_10.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc3_10.2 (constants.%T)] -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: generic class @C(%T.loc3_10.1: type) { -// CHECK:STDOUT: %T.loc3_10.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc3_10.2 (constants.%T)] -// CHECK:STDOUT: -// CHECK:STDOUT: !definition: -// CHECK:STDOUT: %pattern_type: type = pattern_type %T.loc3_10.2 [symbolic = %pattern_type (constants.%pattern_type.7dc)] -// CHECK:STDOUT: -// CHECK:STDOUT: class { -// CHECK:STDOUT: %a.param: @C.%T.loc3_10.2 (%T) = value_param call_param0 -// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc3_10.1 [symbolic = %T.loc3_10.2 (constants.%T)] -// CHECK:STDOUT: %a: @C.%T.loc3_10.2 (%T) = bind_name a, %a.param -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .T = -// CHECK:STDOUT: .a = %a -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: specific @C(constants.%T) { -// CHECK:STDOUT: %T.loc3_10.2 => constants.%T -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_self_param.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %C: type = class_type @C [concrete] -// CHECK:STDOUT: %ptr: type = ptr_type %C [concrete] -// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] -// CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %empty_tuple.type} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %struct_type.discriminant [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: %a.param: %ptr = value_param call_param0 -// CHECK:STDOUT: %.loc8: type = splice_block %ptr [concrete = constants.%ptr] { -// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C] -// CHECK:STDOUT: %ptr: type = ptr_type %Self.ref [concrete = constants.%ptr] -// CHECK:STDOUT: } -// CHECK:STDOUT: %a: %ptr = bind_name a, %a.param -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: .a = %a -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/choice/generic.carbon b/toolchain/check/testdata/choice/generic.carbon index cae06e64a148..5506e02abf01 100644 --- a/toolchain/check/testdata/choice/generic.carbon +++ b/toolchain/check/testdata/choice/generic.carbon @@ -2,15 +2,19 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // +// EXTRA-ARGS: --dump-sem-ir-ranges=only +// // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/choice/generic.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/choice/generic.carbon +//@dump-sem-ir-begin choice Always(T:! type) { Sunny } +//@dump-sem-ir-end // CHECK:STDOUT: --- generic.carbon // CHECK:STDOUT: @@ -29,48 +33,39 @@ choice Always(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .Always = %Always.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Always.decl: %Always.type = class_decl @Always [concrete = constants.%Always.generic] { // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete] // CHECK:STDOUT: } { -// CHECK:STDOUT: %T.loc11_15.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_15.2 (constants.%T)] +// CHECK:STDOUT: %T.loc14_15.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc14_15.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic class @Always(%T.loc11_15.1: type) { -// CHECK:STDOUT: %T.loc11_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_15.2 (constants.%T)] +// CHECK:STDOUT: generic class @Always(%T.loc14_15.1: type) { +// CHECK:STDOUT: %T.loc14_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc14_15.2 (constants.%T)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: -// CHECK:STDOUT: %Always: type = class_type @Always, @Always(%T.loc11_15.2) [symbolic = %Always (constants.%Always)] +// CHECK:STDOUT: %Always: type = class_type @Always, @Always(%T.loc14_15.2) [symbolic = %Always (constants.%Always)] // CHECK:STDOUT: %require_complete: = require_complete_type %Always [symbolic = %require_complete (constants.%require_complete)] // CHECK:STDOUT: %Always.val: @Always.%Always (%Always) = struct_value (constants.%empty_tuple) [symbolic = %Always.val (constants.%Always.val)] // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: %complete_type: = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type] -// CHECK:STDOUT: %.loc13_1.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc16_1.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_1.2: %empty_tuple.type = converted %.loc13_1.1, %empty_tuple [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_1.3: %struct_type.discriminant = struct_literal (%.loc13_1.2) -// CHECK:STDOUT: %.loc13_1.4: ref @Always.%Always (%Always) = temporary_storage -// CHECK:STDOUT: %.loc13_1.5: ref %empty_tuple.type = class_element_access %.loc13_1.4, element0 -// CHECK:STDOUT: %.loc13_1.6: init %empty_tuple.type = tuple_init () to %.loc13_1.5 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_1.7: init %empty_tuple.type = converted %.loc13_1.2, %.loc13_1.6 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc13_1.8: init @Always.%Always (%Always) = class_init (%.loc13_1.7), %.loc13_1.4 [symbolic = %Always.val (constants.%Always.val)] -// CHECK:STDOUT: %.loc13_1.9: ref @Always.%Always (%Always) = temporary %.loc13_1.4, %.loc13_1.8 -// CHECK:STDOUT: %.loc13_1.10: ref @Always.%Always (%Always) = converted %.loc13_1.3, %.loc13_1.9 -// CHECK:STDOUT: %.loc13_1.11: @Always.%Always (%Always) = bind_value %.loc13_1.10 -// CHECK:STDOUT: %Sunny: @Always.%Always (%Always) = bind_name Sunny, %.loc13_1.11 +// CHECK:STDOUT: %.loc16_1.2: %empty_tuple.type = converted %.loc16_1.1, %empty_tuple [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc16_1.3: %struct_type.discriminant = struct_literal (%.loc16_1.2) +// CHECK:STDOUT: %.loc16_1.4: ref @Always.%Always (%Always) = temporary_storage +// CHECK:STDOUT: %.loc16_1.5: ref %empty_tuple.type = class_element_access %.loc16_1.4, element0 +// CHECK:STDOUT: %.loc16_1.6: init %empty_tuple.type = tuple_init () to %.loc16_1.5 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc16_1.7: init %empty_tuple.type = converted %.loc16_1.2, %.loc16_1.6 [concrete = constants.%empty_tuple] +// CHECK:STDOUT: %.loc16_1.8: init @Always.%Always (%Always) = class_init (%.loc16_1.7), %.loc16_1.4 [symbolic = %Always.val (constants.%Always.val)] +// CHECK:STDOUT: %.loc16_1.9: ref @Always.%Always (%Always) = temporary %.loc16_1.4, %.loc16_1.8 +// CHECK:STDOUT: %.loc16_1.10: ref @Always.%Always (%Always) = converted %.loc16_1.3, %.loc16_1.9 +// CHECK:STDOUT: %.loc16_1.11: @Always.%Always (%Always) = bind_value %.loc16_1.10 +// CHECK:STDOUT: %Sunny: @Always.%Always (%Always) = bind_name Sunny, %.loc16_1.11 // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: @@ -80,6 +75,6 @@ choice Always(T:! type) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Always(constants.%T) { -// CHECK:STDOUT: %T.loc11_15.2 => constants.%T +// CHECK:STDOUT: %T.loc14_15.2 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/choice/params.carbon b/toolchain/check/testdata/choice/params.carbon new file mode 100644 index 000000000000..c02b07a33088 --- /dev/null +++ b/toolchain/check/testdata/choice/params.carbon @@ -0,0 +1,59 @@ +// 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: --dump-sem-ir-ranges=only +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/choice/params.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/choice/params.carbon + +// --- fail_todo_empty_params.carbon +library "[[@TEST_NAME]]"; + +choice Always { + // CHECK:STDERR: fail_todo_empty_params.carbon:[[@LINE+4]]:8: error: semantics TODO: `empty parameter list should make a member function` [SemanticsTodo] + // CHECK:STDERR: Sunny() + // CHECK:STDERR: ^~ + // CHECK:STDERR: + Sunny() +} + +let mood: Always = Always.Sunny; + +// --- fail_todo_params.carbon +library "[[@TEST_NAME]]"; + +choice C { + Alt1, + // CHECK:STDERR: fail_todo_params.carbon:[[@LINE+4]]:7: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo] + // CHECK:STDERR: Alt2(a: i32, b: i64), + // CHECK:STDERR: ^~~~~~~~~~~~~~~~ + // CHECK:STDERR: + Alt2(a: i32, b: i64), + Alt3, +} + +// --- fail_todo_generic_params.carbon +library "[[@TEST_NAME]]"; + +choice C(T:! type) { + // CHECK:STDERR: fail_todo_generic_params.carbon:[[@LINE+4]]:6: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo] + // CHECK:STDERR: Alt(a: T) + // CHECK:STDERR: ^~~~~~ + // CHECK:STDERR: + Alt(a: T) +} + +// --- fail_todo_self_param.carbon +library "[[@TEST_NAME]]"; + +choice C { + // CHECK:STDERR: fail_todo_self_param.carbon:[[@LINE+4]]:6: error: semantics TODO: `choice alternatives with parameters are not yet supported` [SemanticsTodo] + // CHECK:STDERR: Alt(a: Self*) + // CHECK:STDERR: ^~~~~~~~~~ + // CHECK:STDERR: + Alt(a: Self*) +}