Update array tests for ranges, splits, and min_prelude (#5507)

Updating tests in the style of #5455.

array indexing requires integers, so this is a more prelude-dependent
area than some. But as it turns out, writing something like `3` never
references `Core.IntLiteral` so seeing if I can roll with more minimal
preludes.
This commit is contained in:
Jon Ross-Perkins
2025-05-21 19:12:02 +00:00
committed by GitHub
parent 0091c699a9
commit c1eea8f2eb
22 changed files with 880 additions and 2748 deletions
-113
View File
@@ -1,113 +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/array/array_in_place.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/array_in_place.carbon
fn F() -> (i32, i32, i32);
fn G() {
var v: array((i32, i32, i32), 2) = (F(), F());
}
// CHECK:STDOUT: --- array_in_place.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
// CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [concrete]
// CHECK:STDOUT: %pattern_type.b5a: type = pattern_type %tuple.type.189 [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_2, %tuple.type.189 [concrete]
// CHECK:STDOUT: %pattern_type.b65: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %tuple.type.99b: type = tuple_type (%tuple.type.189, %tuple.type.189) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %return.patt: %pattern_type.b5a = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.b5a = out_param_pattern %return.patt, call_param0 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32.loc11_12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc11_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc11_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc11_25.1: %tuple.type.ff9 = tuple_literal (%i32.loc11_12, %i32.loc11_17, %i32.loc11_22)
// CHECK:STDOUT: %.loc11_25.2: type = converted %.loc11_25.1, constants.%tuple.type.189 [concrete = constants.%tuple.type.189]
// CHECK:STDOUT: %return.param: ref %tuple.type.189 = out_param call_param0
// CHECK:STDOUT: %return: ref %tuple.type.189 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %return.param: %tuple.type.189;
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %v.patt: %pattern_type.b65 = binding_pattern v [concrete]
// CHECK:STDOUT: %v.var_patt: %pattern_type.b65 = var_pattern %v.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %v.var: ref %array_type = var %v.var_patt
// CHECK:STDOUT: %F.ref.loc14_39: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %.loc14_47.1: ref %tuple.type.189 = splice_block %.loc14_47.2 {
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc14_47.2: ref %tuple.type.189 = array_index %v.var, %int_0
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.call.loc14_41: init %tuple.type.189 = call %F.ref.loc14_39() to %.loc14_47.1
// CHECK:STDOUT: %F.ref.loc14_44: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %.loc14_47.3: ref %tuple.type.189 = splice_block %.loc14_47.4 {
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %.loc14_47.4: ref %tuple.type.189 = array_index %v.var, %int_1
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.call.loc14_46: init %tuple.type.189 = call %F.ref.loc14_44() to %.loc14_47.3
// CHECK:STDOUT: %.loc14_47.5: %tuple.type.99b = tuple_literal (%F.call.loc14_41, %F.call.loc14_46)
// CHECK:STDOUT: %.loc14_47.6: init %array_type = array_init (%F.call.loc14_41, %F.call.loc14_46) to %v.var
// CHECK:STDOUT: %.loc14_3: init %array_type = converted %.loc14_47.5, %.loc14_47.6
// CHECK:STDOUT: assign %v.var, %.loc14_3
// CHECK:STDOUT: %.loc14_34: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc14_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc14_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc14_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc14_30.1: %tuple.type.ff9 = tuple_literal (%i32.loc14_17, %i32.loc14_22, %i32.loc14_27)
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc14_30.2: type = converted %.loc14_30.1, constants.%tuple.type.189 [concrete = constants.%tuple.type.189]
// CHECK:STDOUT: %array_type: type = array_type %int_2, %.loc14_30.2 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %v: ref %array_type = bind_name v, %v.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
-181
View File
@@ -1,181 +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/array/array_vs_tuple.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/array_vs_tuple.carbon
fn G() {
// These should have two different constant values.
var a: array(i32, 3) = (1, 2, 3);
var b: (i32, i32, i32) = (1, 2, 3);
}
// CHECK:STDOUT: --- array_vs_tuple.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
// CHECK:STDOUT: %G: %G.type = struct_value () [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_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %tuple.type.37f: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
// CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
// CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [concrete]
// CHECK:STDOUT: %pattern_type.b5a: type = pattern_type %tuple.type.189 [concrete]
// CHECK:STDOUT: %tuple: %tuple.type.189 = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.5d8 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.5d8 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt
// CHECK:STDOUT: %int_1.loc13_27: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc13_30: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3.loc13_33: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc13_34.1: %tuple.type.37f = tuple_literal (%int_1.loc13_27, %int_2.loc13_30, %int_3.loc13_33)
// CHECK:STDOUT: %impl.elem0.loc13_34.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc13_34.1: <bound method> = bound_method %int_1.loc13_27, %impl.elem0.loc13_34.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc13_34.1: <specific function> = specific_function %impl.elem0.loc13_34.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc13_34.2: <bound method> = bound_method %int_1.loc13_27, %specific_fn.loc13_34.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc13_34.1: init %i32 = call %bound_method.loc13_34.2(%int_1.loc13_27) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc13_34.2: init %i32 = converted %int_1.loc13_27, %int.convert_checked.loc13_34.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc13_34.3: ref %i32 = array_index %a.var, %int_0
// CHECK:STDOUT: %.loc13_34.4: init %i32 = initialize_from %.loc13_34.2 to %.loc13_34.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc13_34.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc13_34.3: <bound method> = bound_method %int_2.loc13_30, %impl.elem0.loc13_34.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc13_34.2: <specific function> = specific_function %impl.elem0.loc13_34.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc13_34.4: <bound method> = bound_method %int_2.loc13_30, %specific_fn.loc13_34.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc13_34.2: init %i32 = call %bound_method.loc13_34.4(%int_2.loc13_30) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc13_34.5: init %i32 = converted %int_2.loc13_30, %int.convert_checked.loc13_34.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int_1.loc13_34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc13_34.6: ref %i32 = array_index %a.var, %int_1.loc13_34
// CHECK:STDOUT: %.loc13_34.7: init %i32 = initialize_from %.loc13_34.5 to %.loc13_34.6 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc13_34.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc13_34.5: <bound method> = bound_method %int_3.loc13_33, %impl.elem0.loc13_34.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc13_34.3: <specific function> = specific_function %impl.elem0.loc13_34.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc13_34.6: <bound method> = bound_method %int_3.loc13_33, %specific_fn.loc13_34.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc13_34.3: init %i32 = call %bound_method.loc13_34.6(%int_3.loc13_33) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc13_34.8: init %i32 = converted %int_3.loc13_33, %int.convert_checked.loc13_34.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int_2.loc13_34: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc13_34.9: ref %i32 = array_index %a.var, %int_2.loc13_34
// CHECK:STDOUT: %.loc13_34.10: init %i32 = initialize_from %.loc13_34.8 to %.loc13_34.9 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc13_34.11: init %array_type = array_init (%.loc13_34.4, %.loc13_34.7, %.loc13_34.10) to %a.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc13_3: init %array_type = converted %.loc13_34.1, %.loc13_34.11 [concrete = constants.%array]
// CHECK:STDOUT: assign %a.var, %.loc13_3
// CHECK:STDOUT: %.loc13_22: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3.loc13_21: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type: type = array_type %int_3.loc13_21, %i32.loc13 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.b5a = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.b5a = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %tuple.type.189 = var %b.var_patt
// CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc14: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3.loc14: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc14_36.1: %tuple.type.37f = tuple_literal (%int_1.loc14, %int_2.loc14, %int_3.loc14)
// CHECK:STDOUT: %impl.elem0.loc14_36.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_36.1: <bound method> = bound_method %int_1.loc14, %impl.elem0.loc14_36.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc14_36.1: <specific function> = specific_function %impl.elem0.loc14_36.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc14_36.2: <bound method> = bound_method %int_1.loc14, %specific_fn.loc14_36.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc14_36.1: init %i32 = call %bound_method.loc14_36.2(%int_1.loc14) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc14_36.2: init %i32 = converted %int_1.loc14, %int.convert_checked.loc14_36.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %b.var, element0
// CHECK:STDOUT: %.loc14_36.3: init %i32 = initialize_from %.loc14_36.2 to %tuple.elem0 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc14_36.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_36.3: <bound method> = bound_method %int_2.loc14, %impl.elem0.loc14_36.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc14_36.2: <specific function> = specific_function %impl.elem0.loc14_36.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc14_36.4: <bound method> = bound_method %int_2.loc14, %specific_fn.loc14_36.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc14_36.2: init %i32 = call %bound_method.loc14_36.4(%int_2.loc14) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc14_36.4: init %i32 = converted %int_2.loc14, %int.convert_checked.loc14_36.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access %b.var, element1
// CHECK:STDOUT: %.loc14_36.5: init %i32 = initialize_from %.loc14_36.4 to %tuple.elem1 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc14_36.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_36.5: <bound method> = bound_method %int_3.loc14, %impl.elem0.loc14_36.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc14_36.3: <specific function> = specific_function %impl.elem0.loc14_36.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc14_36.6: <bound method> = bound_method %int_3.loc14, %specific_fn.loc14_36.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc14_36.3: init %i32 = call %bound_method.loc14_36.6(%int_3.loc14) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc14_36.6: init %i32 = converted %int_3.loc14, %int.convert_checked.loc14_36.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access %b.var, element2
// CHECK:STDOUT: %.loc14_36.7: init %i32 = initialize_from %.loc14_36.6 to %tuple.elem2 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc14_36.8: init %tuple.type.189 = tuple_init (%.loc14_36.3, %.loc14_36.5, %.loc14_36.7) to %b.var [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc14_3: init %tuple.type.189 = converted %.loc14_36.1, %.loc14_36.8 [concrete = constants.%tuple]
// CHECK:STDOUT: assign %b.var, %.loc14_3
// CHECK:STDOUT: %.loc14_24.1: type = splice_block %.loc14_24.3 [concrete = constants.%tuple.type.189] {
// CHECK:STDOUT: %int_32.loc14_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc14_16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc14_21: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc14_21: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc14_24.2: %tuple.type.ff9 = tuple_literal (%i32.loc14_11, %i32.loc14_16, %i32.loc14_21)
// CHECK:STDOUT: %.loc14_24.3: type = converted %.loc14_24.2, constants.%tuple.type.189 [concrete = constants.%tuple.type.189]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %tuple.type.189 = bind_name b, %b.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1,133 +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/array/assign_return_value.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/assign_return_value.carbon
fn F() -> (i32,) { return (0,); }
fn Run() {
var t: array(i32, 1) = F();
}
// CHECK:STDOUT: --- assign_return_value.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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: %tuple.type.85c: type = tuple_type (type) [concrete]
// CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [concrete]
// CHECK:STDOUT: %pattern_type.b74: type = pattern_type %tuple.type.a1c [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [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.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.5c6, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_0.5c6, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
// CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_0.6a9) [concrete]
// CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
// CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.a98: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: .Run = %Run.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %return.patt: %pattern_type.b74 = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.b74 = out_param_pattern %return.patt, call_param0 [concrete]
// CHECK:STDOUT: } {
// 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: %.loc11_16.1: %tuple.type.85c = tuple_literal (%i32)
// CHECK:STDOUT: %.loc11_16.2: type = converted %.loc11_16.1, constants.%tuple.type.a1c [concrete = constants.%tuple.type.a1c]
// CHECK:STDOUT: %return.param: ref %tuple.type.a1c = out_param call_param0
// CHECK:STDOUT: %return: ref %tuple.type.a1c = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %tuple.type.a1c {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
// CHECK:STDOUT: %.loc11_30.1: %tuple.type.985 = tuple_literal (%int_0)
// CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_30.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_30.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc11_30.2(%int_0) [concrete = constants.%int_0.6a9]
// CHECK:STDOUT: %.loc11_30.2: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9]
// CHECK:STDOUT: %.loc11_30.3: %i32 = converted %int_0, %.loc11_30.2 [concrete = constants.%int_0.6a9]
// CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%.loc11_30.3) [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc11_31: %tuple.type.a1c = converted %.loc11_30.1, %tuple [concrete = constants.%tuple]
// CHECK:STDOUT: return %.loc11_31
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %t.patt: %pattern_type.a98 = binding_pattern t [concrete]
// CHECK:STDOUT: %t.var_patt: %pattern_type.a98 = var_pattern %t.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t.var: ref %array_type = var %t.var_patt
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %F.call: init %tuple.type.a1c = call %F.ref()
// CHECK:STDOUT: %.loc14_28.1: ref %tuple.type.a1c = temporary_storage
// CHECK:STDOUT: %.loc14_28.2: ref %tuple.type.a1c = temporary %.loc14_28.1, %F.call
// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %.loc14_28.2, element0
// CHECK:STDOUT: %.loc14_28.3: %i32 = bind_value %tuple.elem0
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
// CHECK:STDOUT: %.loc14_28.4: ref %i32 = array_index %t.var, %int_0
// CHECK:STDOUT: %.loc14_28.5: init %i32 = initialize_from %.loc14_28.3 to %.loc14_28.4
// CHECK:STDOUT: %.loc14_28.6: init %array_type = array_init (%.loc14_28.5) to %t.var
// CHECK:STDOUT: %.loc14_3: init %array_type = converted %F.call, %.loc14_28.6
// CHECK:STDOUT: assign %t.var, %.loc14_3
// CHECK:STDOUT: %.loc14_22: type = splice_block %array_type [concrete = constants.%array_type] {
// 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: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t: ref %array_type = bind_name t, %t.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
-163
View File
@@ -1,163 +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/array/assign_var.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/assign_var.carbon
var a: (i32, i32, i32) = (1, 2, 3);
var b: array(i32, 3) = a;
// CHECK:STDOUT: --- assign_var.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
// CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [concrete]
// CHECK:STDOUT: %pattern_type.b5a: type = pattern_type %tuple.type.189 [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %tuple.type.37f: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access file.%a.var, element0 [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.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access file.%a.var, element1 [concrete]
// CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
// CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access file.%a.var, element2 [concrete]
// CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %tuple: %tuple.type.189 = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.b5a = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.b5a = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %tuple.type.189 = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc11_22.1: type = splice_block %.loc11_22.3 [concrete = constants.%tuple.type.189] {
// CHECK:STDOUT: %int_32.loc11_9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc11_22.2: %tuple.type.ff9 = tuple_literal (%i32.loc11_9, %i32.loc11_14, %i32.loc11_19)
// CHECK:STDOUT: %.loc11_22.3: type = converted %.loc11_22.2, constants.%tuple.type.189 [concrete = constants.%tuple.type.189]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %tuple.type.189 = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.5d8 = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.5d8 = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %array_type = var %b.var_patt [concrete]
// CHECK:STDOUT: %.loc12: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32.loc12 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %array_type = bind_name b, %b.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc11: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc11_34.1: %tuple.type.37f = tuple_literal (%int_1.loc11, %int_2.loc11, %int_3)
// CHECK:STDOUT: %impl.elem0.loc11_34.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_34.1: <bound method> = bound_method %int_1.loc11, %impl.elem0.loc11_34.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc11_34.1: <specific function> = specific_function %impl.elem0.loc11_34.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_34.2: <bound method> = bound_method %int_1.loc11, %specific_fn.loc11_34.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc11_34.1: init %i32 = call %bound_method.loc11_34.2(%int_1.loc11) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc11_34.2: init %i32 = converted %int_1.loc11, %int.convert_checked.loc11_34.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %tuple.elem0.loc11: ref %i32 = tuple_access file.%a.var, element0 [concrete = constants.%tuple.elem0]
// CHECK:STDOUT: %.loc11_34.3: init %i32 = initialize_from %.loc11_34.2 to %tuple.elem0.loc11 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc11_34.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_34.3: <bound method> = bound_method %int_2.loc11, %impl.elem0.loc11_34.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc11_34.2: <specific function> = specific_function %impl.elem0.loc11_34.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_34.4: <bound method> = bound_method %int_2.loc11, %specific_fn.loc11_34.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc11_34.2: init %i32 = call %bound_method.loc11_34.4(%int_2.loc11) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc11_34.4: init %i32 = converted %int_2.loc11, %int.convert_checked.loc11_34.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %tuple.elem1.loc11: ref %i32 = tuple_access file.%a.var, element1 [concrete = constants.%tuple.elem1]
// CHECK:STDOUT: %.loc11_34.5: init %i32 = initialize_from %.loc11_34.4 to %tuple.elem1.loc11 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc11_34.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_34.5: <bound method> = bound_method %int_3, %impl.elem0.loc11_34.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc11_34.3: <specific function> = specific_function %impl.elem0.loc11_34.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_34.6: <bound method> = bound_method %int_3, %specific_fn.loc11_34.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc11_34.3: init %i32 = call %bound_method.loc11_34.6(%int_3) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc11_34.6: init %i32 = converted %int_3, %int.convert_checked.loc11_34.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %tuple.elem2.loc11: ref %i32 = tuple_access file.%a.var, element2 [concrete = constants.%tuple.elem2]
// CHECK:STDOUT: %.loc11_34.7: init %i32 = initialize_from %.loc11_34.6 to %tuple.elem2.loc11 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc11_34.8: init %tuple.type.189 = tuple_init (%.loc11_34.3, %.loc11_34.5, %.loc11_34.7) to file.%a.var [concrete = constants.%tuple]
// CHECK:STDOUT: %.loc11_1: init %tuple.type.189 = converted %.loc11_34.1, %.loc11_34.8 [concrete = constants.%tuple]
// CHECK:STDOUT: assign file.%a.var, %.loc11_1
// CHECK:STDOUT: %a.ref: ref %tuple.type.189 = name_ref a, file.%a
// CHECK:STDOUT: %tuple.elem0.loc12: ref %i32 = tuple_access %a.ref, element0
// CHECK:STDOUT: %.loc12_24.1: %i32 = bind_value %tuple.elem0.loc12
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc12_24.2: ref %i32 = array_index file.%b.var, %int_0
// CHECK:STDOUT: %.loc12_24.3: init %i32 = initialize_from %.loc12_24.1 to %.loc12_24.2
// CHECK:STDOUT: %tuple.elem1.loc12: ref %i32 = tuple_access %a.ref, element1
// CHECK:STDOUT: %.loc12_24.4: %i32 = bind_value %tuple.elem1.loc12
// CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc12_24.5: ref %i32 = array_index file.%b.var, %int_1.loc12
// CHECK:STDOUT: %.loc12_24.6: init %i32 = initialize_from %.loc12_24.4 to %.loc12_24.5
// CHECK:STDOUT: %tuple.elem2.loc12: ref %i32 = tuple_access %a.ref, element2
// CHECK:STDOUT: %.loc12_24.7: %i32 = bind_value %tuple.elem2.loc12
// CHECK:STDOUT: %int_2.loc12: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc12_24.8: ref %i32 = array_index file.%b.var, %int_2.loc12
// CHECK:STDOUT: %.loc12_24.9: init %i32 = initialize_from %.loc12_24.7 to %.loc12_24.8
// CHECK:STDOUT: %.loc12_24.10: init %array_type = array_init (%.loc12_24.3, %.loc12_24.6, %.loc12_24.9) to file.%b.var
// CHECK:STDOUT: %.loc12_1: init %array_type = converted %a.ref, %.loc12_24.10
// CHECK:STDOUT: assign file.%b.var, %.loc12_1
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
-187
View File
@@ -1,187 +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/array/base.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/base.carbon
var a: array(i32, 1) = (1,);
var b: array(f64, 2) = (11.1, 2.2,);
var c: array((), 5) = ((), (), (), (), (),);
// CHECK:STDOUT: --- base.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %array_type.0cb: type = array_type %int_1.5b8, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.a98: type = pattern_type %array_type.0cb [concrete]
// CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %array.237: %array_type.0cb = tuple_value (%int_1.5d2) [concrete]
// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
// CHECK:STDOUT: %Float.type: type = fn_type @Float [concrete]
// CHECK:STDOUT: %Float: %Float.type = struct_value () [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %array_type.ce7: type = array_type %int_2, f64 [concrete]
// CHECK:STDOUT: %pattern_type.e85: type = pattern_type %array_type.ce7 [concrete]
// CHECK:STDOUT: %float.6e4: f64 = float_literal 11.100000000000001 [concrete]
// CHECK:STDOUT: %float.9f7: f64 = float_literal 2.2000000000000002 [concrete]
// CHECK:STDOUT: %tuple.type.bdb: type = tuple_type (f64, f64) [concrete]
// CHECK:STDOUT: %array.6a2: %array_type.ce7 = tuple_value (%float.6e4, %float.9f7) [concrete]
// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete]
// CHECK:STDOUT: %array_type.c13: type = array_type %int_5, %empty_tuple.type [concrete]
// CHECK:STDOUT: %pattern_type.d84: type = pattern_type %array_type.c13 [concrete]
// CHECK:STDOUT: %tuple.type.5b2: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete]
// CHECK:STDOUT: %array.1cb: %array_type.c13 = tuple_value (%empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
// CHECK:STDOUT: .Float = %Core.Float
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: %Core.Float: %Float.type = import_ref Core//prelude/types, Float, loaded [concrete = constants.%Float]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: .c = %c
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.a98 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.a98 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type.0cb = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc11: type = splice_block %array_type.loc11 [concrete = constants.%array_type.0cb] {
// 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: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %array_type.loc11: type = array_type %int_1, %i32 [concrete = constants.%array_type.0cb]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type.0cb = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.e85 = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.e85 = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %array_type.ce7 = var %b.var_patt [concrete]
// CHECK:STDOUT: %.loc12_20: type = splice_block %array_type.loc12 [concrete = constants.%array_type.ce7] {
// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64]
// CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [concrete = f64]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc12_14.1: type = value_of_initializer %float.make_type [concrete = f64]
// CHECK:STDOUT: %.loc12_14.2: type = converted %float.make_type, %.loc12_14.1 [concrete = f64]
// CHECK:STDOUT: %array_type.loc12: type = array_type %int_2, %.loc12_14.2 [concrete = constants.%array_type.ce7]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %array_type.ce7 = bind_name b, %b.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %c.patt: %pattern_type.d84 = binding_pattern c [concrete]
// CHECK:STDOUT: %c.var_patt: %pattern_type.d84 = var_pattern %c.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c.var: ref %array_type.c13 = var %c.var_patt [concrete]
// CHECK:STDOUT: %.loc13_19: type = splice_block %array_type.loc13 [concrete = constants.%array_type.c13] {
// CHECK:STDOUT: %.loc13_15.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5]
// CHECK:STDOUT: %.loc13_15.2: type = converted %.loc13_15.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %array_type.loc13: type = array_type %int_5, %.loc13_15.2 [concrete = constants.%array_type.c13]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c: ref %array_type.c13 = bind_name c, %c.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc11_27.1: %tuple.type.985 = tuple_literal (%int_1.loc11)
// CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_27.1: <bound method> = bound_method %int_1.loc11, %impl.elem0 [concrete = constants.%Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_27.2: <bound method> = bound_method %int_1.loc11, %specific_fn [concrete = constants.%bound_method]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc11_27.2(%int_1.loc11) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_1.loc11, %int.convert_checked [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %int_0.loc11: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc11_27.3: ref %i32 = array_index file.%a.var, %int_0.loc11
// CHECK:STDOUT: %.loc11_27.4: init %i32 = initialize_from %.loc11_27.2 to %.loc11_27.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc11_27.5: init %array_type.0cb = array_init (%.loc11_27.4) to file.%a.var [concrete = constants.%array.237]
// CHECK:STDOUT: %.loc11_1: init %array_type.0cb = converted %.loc11_27.1, %.loc11_27.5 [concrete = constants.%array.237]
// CHECK:STDOUT: assign file.%a.var, %.loc11_1
// CHECK:STDOUT: %float.loc12_25: f64 = float_literal 11.100000000000001 [concrete = constants.%float.6e4]
// CHECK:STDOUT: %float.loc12_31: f64 = float_literal 2.2000000000000002 [concrete = constants.%float.9f7]
// CHECK:STDOUT: %.loc12_35.1: %tuple.type.bdb = tuple_literal (%float.loc12_25, %float.loc12_31)
// CHECK:STDOUT: %int_0.loc12: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc12_35.2: ref f64 = array_index file.%b.var, %int_0.loc12
// CHECK:STDOUT: %.loc12_35.3: init f64 = initialize_from %float.loc12_25 to %.loc12_35.2 [concrete = constants.%float.6e4]
// CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc12_35.4: ref f64 = array_index file.%b.var, %int_1.loc12
// CHECK:STDOUT: %.loc12_35.5: init f64 = initialize_from %float.loc12_31 to %.loc12_35.4 [concrete = constants.%float.9f7]
// CHECK:STDOUT: %.loc12_35.6: init %array_type.ce7 = array_init (%.loc12_35.3, %.loc12_35.5) to file.%b.var [concrete = constants.%array.6a2]
// CHECK:STDOUT: %.loc12_1: init %array_type.ce7 = converted %.loc12_35.1, %.loc12_35.6 [concrete = constants.%array.6a2]
// CHECK:STDOUT: assign file.%b.var, %.loc12_1
// CHECK:STDOUT: %.loc13_25.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc13_29.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc13_33.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc13_37.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc13_41.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc13_43.1: %tuple.type.5b2 = tuple_literal (%.loc13_25.1, %.loc13_29.1, %.loc13_33.1, %.loc13_37.1, %.loc13_41.1)
// CHECK:STDOUT: %int_0.loc13: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc13_43.2: ref %empty_tuple.type = array_index file.%c.var, %int_0.loc13
// CHECK:STDOUT: %.loc13_25.2: init %empty_tuple.type = tuple_init () to %.loc13_43.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc13_43.3: init %empty_tuple.type = converted %.loc13_25.1, %.loc13_25.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc13_43.4: ref %empty_tuple.type = array_index file.%c.var, %int_1.loc13
// CHECK:STDOUT: %.loc13_29.2: init %empty_tuple.type = tuple_init () to %.loc13_43.4 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc13_43.5: init %empty_tuple.type = converted %.loc13_29.1, %.loc13_29.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc13_43.6: ref %empty_tuple.type = array_index file.%c.var, %int_2
// CHECK:STDOUT: %.loc13_33.2: init %empty_tuple.type = tuple_init () to %.loc13_43.6 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc13_43.7: init %empty_tuple.type = converted %.loc13_33.1, %.loc13_33.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc13_43.8: ref %empty_tuple.type = array_index file.%c.var, %int_3
// CHECK:STDOUT: %.loc13_37.2: init %empty_tuple.type = tuple_init () to %.loc13_43.8 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc13_43.9: init %empty_tuple.type = converted %.loc13_37.1, %.loc13_37.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4]
// CHECK:STDOUT: %.loc13_43.10: ref %empty_tuple.type = array_index file.%c.var, %int_4
// CHECK:STDOUT: %.loc13_41.2: init %empty_tuple.type = tuple_init () to %.loc13_43.10 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc13_43.11: init %empty_tuple.type = converted %.loc13_41.1, %.loc13_41.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc13_43.12: init %array_type.c13 = array_init (%.loc13_43.3, %.loc13_43.5, %.loc13_43.7, %.loc13_43.9, %.loc13_43.11) to file.%c.var [concrete = constants.%array.1cb]
// CHECK:STDOUT: %.loc13_1: init %array_type.c13 = converted %.loc13_43.1, %.loc13_43.12 [concrete = constants.%array.1cb]
// CHECK:STDOUT: assign file.%c.var, %.loc13_1
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+185
View File
@@ -0,0 +1,185 @@
// 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/array/bound_values.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/bound_values.carbon
// --- addition.carbon
library "[[@TEST_NAME]]";
var a:
//@dump-sem-ir-begin
array(i32, 1 + 2)
//@dump-sem-ir-end
= (1, 2, 3);
let b: array(i32, 3)* = &a;
// --- unsigned.carbon
library "[[@TEST_NAME]]";
var a:
//@dump-sem-ir-begin
array(i32, 3 as u32)
//@dump-sem-ir-end
= (1, 2, 3);
let b: array(i32, 3)* = &a;
// --- fail_negative.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_negative.carbon:[[@LINE+4]]:19: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: var a: array(i32, -1);
// CHECK:STDERR: ^~
// CHECK:STDERR:
var a: array(i32, -1);
// --- fail_overflow.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_overflow.carbon:[[@LINE+4]]:19: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge]
// CHECK:STDERR: var a: array(i32, 39999999999999999993);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(i32, 39999999999999999993);
// --- fail_invalid_type_with_overflow.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_invalid_type_with_overflow.carbon:[[@LINE+7]]:14: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: var b: array(1, 39999999999999999993);
// CHECK:STDERR: ^
// CHECK:STDERR: fail_invalid_type_with_overflow.carbon:[[@LINE+4]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var b: array(1, 39999999999999999993);
// CHECK:STDERR: ^
// CHECK:STDERR:
var b: array(1, 39999999999999999993);
// CHECK:STDOUT: --- addition.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %Add.type: type = facet_type <@Add> [concrete]
// CHECK:STDOUT: %Op.type.545: type = fn_type @Op.1 [concrete]
// CHECK:STDOUT: %Add.impl_witness.b91: <witness> = impl_witness imports.%Add.impl_witness_table.5a4 [concrete]
// CHECK:STDOUT: %Add.facet: %Add.type = facet_value Core.IntLiteral, (%Add.impl_witness.b91) [concrete]
// CHECK:STDOUT: %.066: type = fn_type_with_self_type %Op.type.545, %Add.facet [concrete]
// CHECK:STDOUT: %Op.type.f28: type = fn_type @Op.2 [concrete]
// CHECK:STDOUT: %Op.d0f: %Op.type.f28 = struct_value () [concrete]
// CHECK:STDOUT: %Op.bound: <bound method> = bound_method %int_1.5b8, %Op.d0f [concrete]
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core.import_ref.3e4: %Op.type.f28 = import_ref Core//prelude/operators/arithmetic, loc78_42, loaded [concrete = constants.%Op.d0f]
// CHECK:STDOUT: %Add.impl_witness_table.5a4 = impl_witness_table (%Core.import_ref.3e4), @impl.9e0 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: %.loc6_21: type = splice_block %array_type.loc6 [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %impl.elem0: %.066 = impl_witness_access constants.%Add.impl_witness.b91, element0 [concrete = constants.%Op.d0f]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Op.bound]
// CHECK:STDOUT: %int.sadd: init Core.IntLiteral = call %bound_method(%int_1, %int_2) [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc6_18.1: Core.IntLiteral = value_of_initializer %int.sadd [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc6_18.2: Core.IntLiteral = converted %int.sadd, %.loc6_18.1 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type.loc6: type = array_type %.loc6_18.2, %i32.loc6 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- unsigned.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete]
// CHECK:STDOUT: %As.type.ce0: type = facet_type <@As, @As(%u32)> [concrete]
// CHECK:STDOUT: %Convert.type.b94: type = fn_type @Convert.1, @As(%u32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %ImplicitAs.type.2fd: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
// CHECK:STDOUT: %From: Core.IntLiteral = bind_symbolic_name From, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.002: type = fn_type @Convert.4, @impl.750(%From) [symbolic]
// CHECK:STDOUT: %Convert.819: %Convert.type.002 = struct_value () [symbolic]
// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.2, @ImplicitAs(Core.IntLiteral) [concrete]
// CHECK:STDOUT: %Convert.type.792: type = fn_type @Convert.5, @impl.2f2(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.c02: %Convert.type.792 = struct_value () [symbolic]
// CHECK:STDOUT: %As.impl_witness.d2d: <witness> = impl_witness imports.%As.impl_witness_table.afe, @impl.2f2(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.70b: type = fn_type @Convert.5, @impl.2f2(%int_32) [concrete]
// CHECK:STDOUT: %Convert.92a: %Convert.type.70b = struct_value () [concrete]
// CHECK:STDOUT: %As.facet: %As.type.ce0 = facet_value Core.IntLiteral, (%As.impl_witness.d2d) [concrete]
// CHECK:STDOUT: %.68c: type = fn_type_with_self_type %Convert.type.b94, %As.facet [concrete]
// CHECK:STDOUT: %Convert.bound.7d9: <bound method> = bound_method %int_3.1ba, %Convert.92a [concrete]
// CHECK:STDOUT: %Convert.specific_fn.4cf: <specific function> = specific_function %Convert.92a, @Convert.5(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.94d: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn.4cf [concrete]
// CHECK:STDOUT: %int_3.d14: %u32 = int_value 3 [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness.a11: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.6ad, @impl.750(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.e06: type = fn_type @Convert.4, @impl.750(%int_32) [concrete]
// CHECK:STDOUT: %Convert.47f: %Convert.type.e06 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet.84e: %ImplicitAs.type.2fd = facet_value %u32, (%ImplicitAs.impl_witness.a11) [concrete]
// CHECK:STDOUT: %.268: type = fn_type_with_self_type %Convert.type.71e, %ImplicitAs.facet.84e [concrete]
// CHECK:STDOUT: %Convert.bound.258: <bound method> = bound_method %int_3.d14, %Convert.47f [concrete]
// CHECK:STDOUT: %Convert.specific_fn.2eb: <specific function> = specific_function %Convert.47f, @Convert.4(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.3a6: <bound method> = bound_method %int_3.d14, %Convert.specific_fn.2eb [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core.import_ref.823: @impl.750.%Convert.type (%Convert.type.002) = import_ref Core//prelude/types/uint, loc24_44, loaded [symbolic = @impl.750.%Convert (constants.%Convert.819)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.6ad = impl_witness_table (%Core.import_ref.823), @impl.750 [concrete]
// CHECK:STDOUT: %Core.import_ref.aef: @impl.2f2.%Convert.type (%Convert.type.792) = import_ref Core//prelude/types/uint, loc29_40, loaded [symbolic = @impl.2f2.%Convert (constants.%Convert.c02)]
// CHECK:STDOUT: %As.impl_witness_table.afe = impl_witness_table (%Core.import_ref.aef), @impl.2f2 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: %.loc6_24: type = splice_block %array_type.loc6 [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc6_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3.loc6: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %int_32.loc6_21: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(constants.%int_32) [concrete = constants.%u32]
// CHECK:STDOUT: %impl.elem0.loc6_18.1: %.68c = impl_witness_access constants.%As.impl_witness.d2d, element0 [concrete = constants.%Convert.92a]
// CHECK:STDOUT: %bound_method.loc6_18.1: <bound method> = bound_method %int_3.loc6, %impl.elem0.loc6_18.1 [concrete = constants.%Convert.bound.7d9]
// CHECK:STDOUT: %specific_fn.loc6_18.1: <specific function> = specific_function %impl.elem0.loc6_18.1, @Convert.5(constants.%int_32) [concrete = constants.%Convert.specific_fn.4cf]
// CHECK:STDOUT: %bound_method.loc6_18.2: <bound method> = bound_method %int_3.loc6, %specific_fn.loc6_18.1 [concrete = constants.%bound_method.94d]
// CHECK:STDOUT: %int.convert_checked.loc6_18.1: init %u32 = call %bound_method.loc6_18.2(%int_3.loc6) [concrete = constants.%int_3.d14]
// CHECK:STDOUT: %.loc6_18.1: %u32 = value_of_initializer %int.convert_checked.loc6_18.1 [concrete = constants.%int_3.d14]
// CHECK:STDOUT: %.loc6_18.2: %u32 = converted %int_3.loc6, %.loc6_18.1 [concrete = constants.%int_3.d14]
// CHECK:STDOUT: %impl.elem0.loc6_18.2: %.268 = impl_witness_access constants.%ImplicitAs.impl_witness.a11, element0 [concrete = constants.%Convert.47f]
// CHECK:STDOUT: %bound_method.loc6_18.3: <bound method> = bound_method %.loc6_18.2, %impl.elem0.loc6_18.2 [concrete = constants.%Convert.bound.258]
// CHECK:STDOUT: %specific_fn.loc6_18.2: <specific function> = specific_function %impl.elem0.loc6_18.2, @Convert.4(constants.%int_32) [concrete = constants.%Convert.specific_fn.2eb]
// CHECK:STDOUT: %bound_method.loc6_18.4: <bound method> = bound_method %.loc6_18.2, %specific_fn.loc6_18.2 [concrete = constants.%bound_method.3a6]
// CHECK:STDOUT: %int.convert_checked.loc6_18.2: init Core.IntLiteral = call %bound_method.loc6_18.4(%.loc6_18.2) [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc6_18.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc6_18.2 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc6_18.4: Core.IntLiteral = converted %.loc6_18.2, %.loc6_18.3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type.loc6: type = array_type %.loc6_18.4, %i32.loc6 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
-289
View File
@@ -1,289 +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/array/canonicalize_index.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/canonicalize_index.carbon
fn Add(a: i32, b: i32) -> i32 = "int.sadd";
fn ConvertToU32(a: i32) -> u32 = "int.convert_checked";
var a: array(i32, Add(1, 2)) = (1, 2, 3);
let b: array(i32, 3)* = &a;
let c: array(i32, ConvertToU32(3))* = &a;
// CHECK:STDOUT: --- canonicalize_index.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %Add.type.b1f: type = fn_type @Add.1 [concrete]
// CHECK:STDOUT: %Add: %Add.type.b1f = struct_value () [concrete]
// CHECK:STDOUT: %UInt.type: type = generic_class_type @UInt [concrete]
// CHECK:STDOUT: %UInt.generic: %UInt.type = struct_value () [concrete]
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete]
// CHECK:STDOUT: %pattern_type.4a9: type = pattern_type %u32 [concrete]
// CHECK:STDOUT: %ConvertToU32.type: type = fn_type @ConvertToU32 [concrete]
// CHECK:STDOUT: %ConvertToU32: %ConvertToU32.type = struct_value () [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [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.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.type.2fd: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
// CHECK:STDOUT: %From: Core.IntLiteral = bind_symbolic_name From, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.708: type = fn_type @Convert.3, @impl.971(%From) [symbolic]
// CHECK:STDOUT: %Convert.c68: %Convert.type.708 = struct_value () [symbolic]
// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet.921: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet.921 [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn.b6f: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn.b6f [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn.b6f [concrete]
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness.a11d: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.1d9, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet.f49: %ImplicitAs.type.2fd = facet_value %i32, (%ImplicitAs.impl_witness.a11d) [concrete]
// CHECK:STDOUT: %.0ea: type = fn_type_with_self_type %Convert.type.71e, %ImplicitAs.facet.f49 [concrete]
// CHECK:STDOUT: %Convert.bound.2d6: <bound method> = bound_method %int_3.822, %Convert.960 [concrete]
// CHECK:STDOUT: %Convert.specific_fn.8a8: <specific function> = specific_function %Convert.960, @Convert.3(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.c6f: <bound method> = bound_method %int_3.822, %Convert.specific_fn.8a8 [concrete]
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: %ptr.f01: type = ptr_type %array_type [concrete]
// CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn.b6f [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
// CHECK:STDOUT: %pattern_type.743: type = pattern_type %ptr.f01 [concrete]
// CHECK:STDOUT: %int_3.d14: %u32 = int_value 3 [concrete]
// CHECK:STDOUT: %Convert.type.002: type = fn_type @Convert.9, @impl.750(%From) [symbolic]
// CHECK:STDOUT: %Convert.819: %Convert.type.002 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.a110: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.6ad, @impl.750(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.e06: type = fn_type @Convert.9, @impl.750(%int_32) [concrete]
// CHECK:STDOUT: %Convert.47f: %Convert.type.e06 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet.84e: %ImplicitAs.type.2fd = facet_value %u32, (%ImplicitAs.impl_witness.a110) [concrete]
// CHECK:STDOUT: %.268: type = fn_type_with_self_type %Convert.type.71e, %ImplicitAs.facet.84e [concrete]
// CHECK:STDOUT: %Convert.bound.258: <bound method> = bound_method %int_3.d14, %Convert.47f [concrete]
// CHECK:STDOUT: %Convert.specific_fn.2eb: <specific function> = specific_function %Convert.47f, @Convert.9(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.3a6: <bound method> = bound_method %int_3.d14, %Convert.specific_fn.2eb [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = 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.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: %Core.import_ref.85c: @impl.971.%Convert.type (%Convert.type.708) = import_ref Core//prelude/types/int, loc23_44, loaded [symbolic = @impl.971.%Convert (constants.%Convert.c68)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.1d9 = impl_witness_table (%Core.import_ref.85c), @impl.971 [concrete]
// CHECK:STDOUT: %Core.import_ref.823: @impl.750.%Convert.type (%Convert.type.002) = import_ref Core//prelude/types/uint, loc24_44, loaded [symbolic = @impl.750.%Convert (constants.%Convert.819)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.6ad = impl_witness_table (%Core.import_ref.823), @impl.750 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .Add = %Add.decl
// CHECK:STDOUT: .ConvertToU32 = %ConvertToU32.decl
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: .c = %c
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Add.decl: %Add.type.b1f = fn_decl @Add.1 [concrete = constants.%Add] {
// CHECK:STDOUT: %a.patt: %pattern_type.7ce = binding_pattern a [concrete]
// CHECK:STDOUT: %a.param_patt: %pattern_type.7ce = value_param_pattern %a.patt, call_param0 [concrete]
// CHECK:STDOUT: %b.patt: %pattern_type.7ce = binding_pattern b [concrete]
// CHECK:STDOUT: %b.param_patt: %pattern_type.7ce = value_param_pattern %b.patt, call_param1 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32.loc11_27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_27: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %a.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc11_11: type = splice_block %i32.loc11_11 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc11_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_11: 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: %i32 = value_param call_param1
// CHECK:STDOUT: %.loc11_19: type = splice_block %i32.loc11_19 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %ConvertToU32.decl: %ConvertToU32.type = fn_decl @ConvertToU32 [concrete = constants.%ConvertToU32] {
// CHECK:STDOUT: %a.patt: %pattern_type.7ce = binding_pattern a [concrete]
// CHECK:STDOUT: %a.param_patt: %pattern_type.7ce = value_param_pattern %a.patt, call_param0 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.4a9 = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.4a9 = out_param_pattern %return.patt, call_param1 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32.loc12_28: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(constants.%int_32) [concrete = constants.%u32]
// CHECK:STDOUT: %a.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc12: type = splice_block %i32 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc12_20: 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: %return.param: ref %u32 = out_param call_param1
// CHECK:STDOUT: %return: ref %u32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.5d8 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.5d8 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc14_28: type = splice_block %array_type.loc14 [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %Add.ref: %Add.type.b1f = name_ref Add, %Add.decl [concrete = constants.%Add]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %impl.elem0.loc14_23: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_23.1: <bound method> = bound_method %int_1, %impl.elem0.loc14_23 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc14_23: <specific function> = specific_function %impl.elem0.loc14_23, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc14_23.2: <bound method> = bound_method %int_1, %specific_fn.loc14_23 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc14_23: init %i32 = call %bound_method.loc14_23.2(%int_1) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc14_23.1: %i32 = value_of_initializer %int.convert_checked.loc14_23 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc14_23.2: %i32 = converted %int_1, %.loc14_23.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc14_26: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_26.1: <bound method> = bound_method %int_2, %impl.elem0.loc14_26 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc14_26: <specific function> = specific_function %impl.elem0.loc14_26, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc14_26.2: <bound method> = bound_method %int_2, %specific_fn.loc14_26 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc14_26: init %i32 = call %bound_method.loc14_26.2(%int_2) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc14_26.1: %i32 = value_of_initializer %int.convert_checked.loc14_26 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc14_26.2: %i32 = converted %int_2, %.loc14_26.1 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int.sadd: init %i32 = call %Add.ref(%.loc14_23.2, %.loc14_26.2) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %impl.elem0.loc14_27: %.0ea = impl_witness_access constants.%ImplicitAs.impl_witness.a11d, element0 [concrete = constants.%Convert.960]
// CHECK:STDOUT: %bound_method.loc14_27.1: <bound method> = bound_method %int.sadd, %impl.elem0.loc14_27 [concrete = constants.%Convert.bound.2d6]
// CHECK:STDOUT: %specific_fn.loc14_27: <specific function> = specific_function %impl.elem0.loc14_27, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.8a8]
// CHECK:STDOUT: %bound_method.loc14_27.2: <bound method> = bound_method %int.sadd, %specific_fn.loc14_27 [concrete = constants.%bound_method.c6f]
// CHECK:STDOUT: %.loc14_27.1: %i32 = value_of_initializer %int.sadd [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc14_27.2: %i32 = converted %int.sadd, %.loc14_27.1 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int.convert_checked.loc14_27: init Core.IntLiteral = call %bound_method.loc14_27.2(%.loc14_27.2) [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc14_27.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc14_27 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc14_27.4: Core.IntLiteral = converted %int.sadd, %.loc14_27.3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type.loc14: type = array_type %.loc14_27.4, %i32.loc14 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.743 = binding_pattern b [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc15: type = splice_block %ptr.loc15 [concrete = constants.%ptr.f01] {
// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3.loc15: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type.loc15: type = array_type %int_3.loc15, %i32.loc15 [concrete = constants.%array_type]
// CHECK:STDOUT: %ptr.loc15: type = ptr_type %array_type.loc15 [concrete = constants.%ptr.f01]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: %ptr.f01 = bind_name b, @__global_init.%addr.loc15
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %c.patt: %pattern_type.743 = binding_pattern c [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc16_35: type = splice_block %ptr.loc16 [concrete = constants.%ptr.f01] {
// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %ConvertToU32.ref: %ConvertToU32.type = name_ref ConvertToU32, %ConvertToU32.decl [concrete = constants.%ConvertToU32]
// CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %impl.elem0.loc16_32: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc16_32.1: <bound method> = bound_method %int_3.loc16, %impl.elem0.loc16_32 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc16_32: <specific function> = specific_function %impl.elem0.loc16_32, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc16_32.2: <bound method> = bound_method %int_3.loc16, %specific_fn.loc16_32 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc16_32: init %i32 = call %bound_method.loc16_32.2(%int_3.loc16) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_32.1: %i32 = value_of_initializer %int.convert_checked.loc16_32 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_32.2: %i32 = converted %int_3.loc16, %.loc16_32.1 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int.convert_checked.loc16_33.1: init %u32 = call %ConvertToU32.ref(%.loc16_32.2) [concrete = constants.%int_3.d14]
// CHECK:STDOUT: %impl.elem0.loc16_33: %.268 = impl_witness_access constants.%ImplicitAs.impl_witness.a110, element0 [concrete = constants.%Convert.47f]
// CHECK:STDOUT: %bound_method.loc16_33.1: <bound method> = bound_method %int.convert_checked.loc16_33.1, %impl.elem0.loc16_33 [concrete = constants.%Convert.bound.258]
// CHECK:STDOUT: %specific_fn.loc16_33: <specific function> = specific_function %impl.elem0.loc16_33, @Convert.9(constants.%int_32) [concrete = constants.%Convert.specific_fn.2eb]
// CHECK:STDOUT: %bound_method.loc16_33.2: <bound method> = bound_method %int.convert_checked.loc16_33.1, %specific_fn.loc16_33 [concrete = constants.%bound_method.3a6]
// CHECK:STDOUT: %.loc16_33.1: %u32 = value_of_initializer %int.convert_checked.loc16_33.1 [concrete = constants.%int_3.d14]
// CHECK:STDOUT: %.loc16_33.2: %u32 = converted %int.convert_checked.loc16_33.1, %.loc16_33.1 [concrete = constants.%int_3.d14]
// CHECK:STDOUT: %int.convert_checked.loc16_33.2: init Core.IntLiteral = call %bound_method.loc16_33.2(%.loc16_33.2) [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc16_33.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc16_33.2 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc16_33.4: Core.IntLiteral = converted %int.convert_checked.loc16_33.1, %.loc16_33.3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type.loc16: type = array_type %.loc16_33.4, %i32.loc16 [concrete = constants.%array_type]
// CHECK:STDOUT: %ptr.loc16: type = ptr_type %array_type.loc16 [concrete = constants.%ptr.f01]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c: %ptr.f01 = bind_name c, @__global_init.%addr.loc16
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Add.1(%a.param: %i32, %b.param: %i32) -> %i32 = "int.sadd";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @ConvertToU32(%a.param: %i32) -> %u32 = "int.convert_checked";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1.loc14_33: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc14_36: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc14_40.1: %tuple.type = tuple_literal (%int_1.loc14_33, %int_2.loc14_36, %int_3)
// CHECK:STDOUT: %impl.elem0.loc14_40.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_40.1: <bound method> = bound_method %int_1.loc14_33, %impl.elem0.loc14_40.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc14_40.1: <specific function> = specific_function %impl.elem0.loc14_40.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc14_40.2: <bound method> = bound_method %int_1.loc14_33, %specific_fn.loc14_40.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc14_40.1: init %i32 = call %bound_method.loc14_40.2(%int_1.loc14_33) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc14_40.2: init %i32 = converted %int_1.loc14_33, %int.convert_checked.loc14_40.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc14_40.3: ref %i32 = array_index file.%a.var, %int_0
// CHECK:STDOUT: %.loc14_40.4: init %i32 = initialize_from %.loc14_40.2 to %.loc14_40.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc14_40.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_40.3: <bound method> = bound_method %int_2.loc14_36, %impl.elem0.loc14_40.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc14_40.2: <specific function> = specific_function %impl.elem0.loc14_40.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc14_40.4: <bound method> = bound_method %int_2.loc14_36, %specific_fn.loc14_40.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc14_40.2: init %i32 = call %bound_method.loc14_40.4(%int_2.loc14_36) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc14_40.5: init %i32 = converted %int_2.loc14_36, %int.convert_checked.loc14_40.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int_1.loc14_40: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc14_40.6: ref %i32 = array_index file.%a.var, %int_1.loc14_40
// CHECK:STDOUT: %.loc14_40.7: init %i32 = initialize_from %.loc14_40.5 to %.loc14_40.6 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc14_40.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc14_40.5: <bound method> = bound_method %int_3, %impl.elem0.loc14_40.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc14_40.3: <specific function> = specific_function %impl.elem0.loc14_40.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc14_40.6: <bound method> = bound_method %int_3, %specific_fn.loc14_40.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc14_40.3: init %i32 = call %bound_method.loc14_40.6(%int_3) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc14_40.8: init %i32 = converted %int_3, %int.convert_checked.loc14_40.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int_2.loc14_40: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc14_40.9: ref %i32 = array_index file.%a.var, %int_2.loc14_40
// CHECK:STDOUT: %.loc14_40.10: init %i32 = initialize_from %.loc14_40.8 to %.loc14_40.9 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc14_40.11: init %array_type = array_init (%.loc14_40.4, %.loc14_40.7, %.loc14_40.10) to file.%a.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc14_1: init %array_type = converted %.loc14_40.1, %.loc14_40.11 [concrete = constants.%array]
// CHECK:STDOUT: assign file.%a.var, %.loc14_1
// CHECK:STDOUT: %a.ref.loc15: ref %array_type = name_ref a, file.%a
// CHECK:STDOUT: %addr.loc15: %ptr.f01 = addr_of %a.ref.loc15
// CHECK:STDOUT: %a.ref.loc16: ref %array_type = name_ref a, file.%a
// CHECK:STDOUT: %addr.loc16: %ptr.f01 = addr_of %a.ref.loc16
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1,135 +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/array/fail_bound_negative.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_bound_negative.carbon
fn Negate(n: i32) -> i32 = "int.snegate";
// CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+4]]:19: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: var a: array(i32, Negate(1));
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
var a: array(i32, Negate(1));
// CHECK:STDOUT: --- fail_bound_negative.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %Negate.type.15b: type = fn_type @Negate.1 [concrete]
// CHECK:STDOUT: %Negate: %Negate.type.15b = struct_value () [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [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.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.type.2fd: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
// CHECK:STDOUT: %From: Core.IntLiteral = bind_symbolic_name From, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.708: type = fn_type @Convert.3, @impl.971(%From) [symbolic]
// CHECK:STDOUT: %Convert.c68: %Convert.type.708 = struct_value () [symbolic]
// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet.921: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet.921 [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn.b6f: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn.b6f [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %int_-1.251: %i32 = int_value -1 [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness.a11: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.1d9, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet.f49: %ImplicitAs.type.2fd = facet_value %i32, (%ImplicitAs.impl_witness.a11) [concrete]
// CHECK:STDOUT: %.0ea: type = fn_type_with_self_type %Convert.type.71e, %ImplicitAs.facet.f49 [concrete]
// CHECK:STDOUT: %Convert.bound.75d: <bound method> = bound_method %int_-1.251, %Convert.960 [concrete]
// CHECK:STDOUT: %Convert.specific_fn.8a8: <specific function> = specific_function %Convert.960, @Convert.3(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.245: <bound method> = bound_method %int_-1.251, %Convert.specific_fn.8a8 [concrete]
// CHECK:STDOUT: %int_-1.638: Core.IntLiteral = int_value -1 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: %Core.import_ref.85c: @impl.971.%Convert.type (%Convert.type.708) = import_ref Core//prelude/types/int, loc23_44, loaded [symbolic = @impl.971.%Convert (constants.%Convert.c68)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.1d9 = impl_witness_table (%Core.import_ref.85c), @impl.971 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .Negate = %Negate.decl
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Negate.decl: %Negate.type.15b = fn_decl @Negate.1 [concrete = constants.%Negate] {
// CHECK:STDOUT: %n.patt: %pattern_type.7ce = binding_pattern n [concrete]
// CHECK:STDOUT: %n.param_patt: %pattern_type.7ce = value_param_pattern %n.patt, call_param0 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32.loc11_22: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_22: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %n.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc11: type = splice_block %i32.loc11_14 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc11_14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %n: %i32 = bind_name n, %n.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: <error> = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref <error> = var %a.var_patt [concrete = <error>]
// CHECK:STDOUT: %.loc17_28: type = splice_block %array_type [concrete = <error>] {
// 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: %Negate.ref: %Negate.type.15b = name_ref Negate, %Negate.decl [concrete = constants.%Negate]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %impl.elem0.loc17_26: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc17_26.1: <bound method> = bound_method %int_1, %impl.elem0.loc17_26 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc17_26: <specific function> = specific_function %impl.elem0.loc17_26, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc17_26.2: <bound method> = bound_method %int_1, %specific_fn.loc17_26 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc17_26: init %i32 = call %bound_method.loc17_26.2(%int_1) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc17_26.1: %i32 = value_of_initializer %int.convert_checked.loc17_26 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc17_26.2: %i32 = converted %int_1, %.loc17_26.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %int.snegate: init %i32 = call %Negate.ref(%.loc17_26.2) [concrete = constants.%int_-1.251]
// CHECK:STDOUT: %impl.elem0.loc17_27: %.0ea = impl_witness_access constants.%ImplicitAs.impl_witness.a11, element0 [concrete = constants.%Convert.960]
// CHECK:STDOUT: %bound_method.loc17_27.1: <bound method> = bound_method %int.snegate, %impl.elem0.loc17_27 [concrete = constants.%Convert.bound.75d]
// CHECK:STDOUT: %specific_fn.loc17_27: <specific function> = specific_function %impl.elem0.loc17_27, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn.8a8]
// CHECK:STDOUT: %bound_method.loc17_27.2: <bound method> = bound_method %int.snegate, %specific_fn.loc17_27 [concrete = constants.%bound_method.245]
// CHECK:STDOUT: %.loc17_27.1: %i32 = value_of_initializer %int.snegate [concrete = constants.%int_-1.251]
// CHECK:STDOUT: %.loc17_27.2: %i32 = converted %int.snegate, %.loc17_27.1 [concrete = constants.%int_-1.251]
// CHECK:STDOUT: %int.convert_checked.loc17_27: init Core.IntLiteral = call %bound_method.loc17_27.2(%.loc17_27.2) [concrete = constants.%int_-1.638]
// CHECK:STDOUT: %.loc17_27.3: Core.IntLiteral = value_of_initializer %int.convert_checked.loc17_27 [concrete = constants.%int_-1.638]
// CHECK:STDOUT: %.loc17_27.4: Core.IntLiteral = converted %int.snegate, %.loc17_27.3 [concrete = constants.%int_-1.638]
// CHECK:STDOUT: %array_type: type = array_type %.loc17_27.4, %i32 [concrete = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: <error> = bind_name a, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Negate.1(%n.param: %i32) -> %i32 = "int.snegate";
// CHECK:STDOUT:
@@ -1,82 +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/array/fail_bound_overflow.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_bound_overflow.carbon
// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:19: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge]
// CHECK:STDERR: var a: array(i32, 39999999999999999993);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(i32, 39999999999999999993);
// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+7]]:14: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: var b: array(1, 39999999999999999993);
// CHECK:STDERR: ^
// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var b: array(1, 39999999999999999993);
// CHECK:STDERR: ^
// CHECK:STDERR:
var b: array(1, 39999999999999999993);
// CHECK:STDOUT: --- fail_bound_overflow.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_39999999999999999993: Core.IntLiteral = int_value 39999999999999999993 [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: <error> = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref <error> = var %a.var_patt [concrete = <error>]
// CHECK:STDOUT: %.loc15: type = splice_block %array_type.loc15 [concrete = <error>] {
// 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: %int_39999999999999999993.loc15: Core.IntLiteral = int_value 39999999999999999993 [concrete = constants.%int_39999999999999999993]
// CHECK:STDOUT: %array_type.loc15: type = array_type %int_39999999999999999993.loc15, %i32 [concrete = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: <error> = bind_name a, <error>
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: <error> = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: <error> = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref <error> = var %b.var_patt [concrete = <error>]
// CHECK:STDOUT: %.loc24_37: type = splice_block %array_type.loc24 [concrete = <error>] {
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %int_39999999999999999993.loc24: Core.IntLiteral = int_value 39999999999999999993 [concrete = constants.%int_39999999999999999993]
// CHECK:STDOUT: %.loc24_14: type = converted %int_1, <error> [concrete = <error>]
// CHECK:STDOUT: %array_type.loc24: type = array_type %int_39999999999999999993.loc24, <error> [concrete = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: <error> = bind_name b, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1,84 +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/array/fail_incomplete_element.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_incomplete_element.carbon
class Incomplete;
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+7]]:8: error: binding pattern has incomplete type `array(Incomplete, 1)` in name binding declaration [IncompleteTypeInBindingDecl]
// CHECK:STDERR: var a: array(Incomplete, 1);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class Incomplete;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(Incomplete, 1);
var p: Incomplete* = &a[0];
// CHECK:STDOUT: --- fail_incomplete_element.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Incomplete: type = class_type @Incomplete [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %Incomplete [concrete]
// CHECK:STDOUT: %ptr: type = ptr_type %Incomplete [concrete]
// CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = 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> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .Incomplete = %Incomplete.decl
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .p = %p
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %Incomplete.decl: type = class_decl @Incomplete [concrete = constants.%Incomplete] {} {}
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: <error> = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref <error> = var %a.var_patt [concrete = <error>]
// CHECK:STDOUT: %.loc20: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %Incomplete.ref.loc20: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %Incomplete.ref.loc20 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: <error> = bind_name a, <error>
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %p.patt: %pattern_type = binding_pattern p [concrete]
// CHECK:STDOUT: %p.var_patt: %pattern_type = var_pattern %p.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %p.var: ref %ptr = var %p.var_patt [concrete]
// CHECK:STDOUT: %.loc22: type = splice_block %ptr [concrete = constants.%ptr] {
// CHECK:STDOUT: %Incomplete.ref.loc22: type = name_ref Incomplete, %Incomplete.decl [concrete = constants.%Incomplete]
// CHECK:STDOUT: %ptr: type = ptr_type %Incomplete.ref.loc22 [concrete = constants.%ptr]
// CHECK:STDOUT: }
// CHECK:STDOUT: %p: ref %ptr = bind_name p, %p.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @Incomplete;
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a.ref: <error> = name_ref a, file.%a [concrete = <error>]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %addr: <error> = addr_of <error> [concrete = <error>]
// CHECK:STDOUT: assign file.%p.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
-56
View File
@@ -1,56 +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/array/fail_invalid_type.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_invalid_type.carbon
// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+7]]:14: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: var a: array(1, 1);
// CHECK:STDERR: ^
// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+4]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var a: array(1, 1);
// CHECK:STDERR: ^
// CHECK:STDERR:
var a: array(1, 1);
// CHECK:STDOUT: --- fail_invalid_type.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
// CHECK:STDOUT: import Core//prelude
// CHECK:STDOUT: import Core//prelude/...
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: <error> = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: <error> = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref <error> = var %a.var_patt [concrete = <error>]
// CHECK:STDOUT: %.loc18_18: type = splice_block %array_type [concrete = <error>] {
// CHECK:STDOUT: %int_1.loc18_14: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %int_1.loc18_17: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %.loc18_14: type = converted %int_1.loc18_14, <error> [concrete = <error>]
// CHECK:STDOUT: %array_type: type = array_type %int_1.loc18_17, <error> [concrete = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: <error> = bind_name a, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT:
-70
View File
@@ -1,70 +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/array/fail_out_of_bound.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_out_of_bound.carbon
// CHECK:STDERR: fail_out_of_bound.carbon:[[@LINE+4]]:24: error: cannot initialize array of 1 element from 3 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: var a: array(i32, 1) = (1, 2, 3);
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
var a: array(i32, 1) = (1, 2, 3);
// CHECK:STDOUT: --- fail_out_of_bound.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.a98: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.a98 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.a98 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc15: type = splice_block %array_type [concrete = constants.%array_type] {
// 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: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %i32 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc15: %tuple.type = tuple_literal (%int_1, %int_2, %int_3)
// CHECK:STDOUT: assign file.%a.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1,160 +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/array/fail_out_of_bound_non_literal.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_out_of_bound_non_literal.carbon
var a: array(i32, 3) = (1, 2, 3);
// CHECK:STDERR: fail_out_of_bound_non_literal.carbon:[[@LINE+4]]:16: error: array index `3` is past the end of type `array(i32, 3)` [ArrayIndexOutOfBounds]
// CHECK:STDERR: var b: i32 = a[{.index = 3}.index];
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var b: i32 = a[{.index = 3}.index];
// CHECK:STDOUT: --- fail_out_of_bound_non_literal.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
// CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
// CHECK:STDOUT: %struct_type.index: type = struct_type {.index: Core.IntLiteral} [concrete]
// CHECK:STDOUT: %struct: %struct_type.index = struct_value (%int_3.1ba) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.5d8 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.5d8 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc11: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32.loc11 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.7ce = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.7ce = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %i32 = var %b.var_patt [concrete]
// CHECK:STDOUT: %.loc16: type = splice_block %i32.loc16 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1.loc11_25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc11_28: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3.loc11: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc11_32.1: %tuple.type = tuple_literal (%int_1.loc11_25, %int_2.loc11_28, %int_3.loc11)
// CHECK:STDOUT: %impl.elem0.loc11_32.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_32.1: <bound method> = bound_method %int_1.loc11_25, %impl.elem0.loc11_32.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc11_32.1: <specific function> = specific_function %impl.elem0.loc11_32.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_32.2: <bound method> = bound_method %int_1.loc11_25, %specific_fn.loc11_32.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc11_32.1: init %i32 = call %bound_method.loc11_32.2(%int_1.loc11_25) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc11_32.2: init %i32 = converted %int_1.loc11_25, %int.convert_checked.loc11_32.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc11_32.3: ref %i32 = array_index file.%a.var, %int_0
// CHECK:STDOUT: %.loc11_32.4: init %i32 = initialize_from %.loc11_32.2 to %.loc11_32.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc11_32.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_32.3: <bound method> = bound_method %int_2.loc11_28, %impl.elem0.loc11_32.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc11_32.2: <specific function> = specific_function %impl.elem0.loc11_32.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_32.4: <bound method> = bound_method %int_2.loc11_28, %specific_fn.loc11_32.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc11_32.2: init %i32 = call %bound_method.loc11_32.4(%int_2.loc11_28) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc11_32.5: init %i32 = converted %int_2.loc11_28, %int.convert_checked.loc11_32.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int_1.loc11_32: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc11_32.6: ref %i32 = array_index file.%a.var, %int_1.loc11_32
// CHECK:STDOUT: %.loc11_32.7: init %i32 = initialize_from %.loc11_32.5 to %.loc11_32.6 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc11_32.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_32.5: <bound method> = bound_method %int_3.loc11, %impl.elem0.loc11_32.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc11_32.3: <specific function> = specific_function %impl.elem0.loc11_32.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_32.6: <bound method> = bound_method %int_3.loc11, %specific_fn.loc11_32.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc11_32.3: init %i32 = call %bound_method.loc11_32.6(%int_3.loc11) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc11_32.8: init %i32 = converted %int_3.loc11, %int.convert_checked.loc11_32.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int_2.loc11_32: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc11_32.9: ref %i32 = array_index file.%a.var, %int_2.loc11_32
// CHECK:STDOUT: %.loc11_32.10: init %i32 = initialize_from %.loc11_32.8 to %.loc11_32.9 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc11_32.11: init %array_type = array_init (%.loc11_32.4, %.loc11_32.7, %.loc11_32.10) to file.%a.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_32.1, %.loc11_32.11 [concrete = constants.%array]
// CHECK:STDOUT: assign file.%a.var, %.loc11_1
// CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a
// CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc16_27.1: %struct_type.index = struct_literal (%int_3.loc16)
// CHECK:STDOUT: %struct: %struct_type.index = struct_value (%int_3.loc16) [concrete = constants.%struct]
// CHECK:STDOUT: %.loc16_27.2: %struct_type.index = converted %.loc16_27.1, %struct [concrete = constants.%struct]
// CHECK:STDOUT: %.loc16_28.1: Core.IntLiteral = struct_access %.loc16_27.2, element0 [concrete = constants.%int_3.1ba]
// 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: %impl.elem0.loc16: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc16_28.1: <bound method> = bound_method %.loc16_28.1, %impl.elem0.loc16 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc16: <specific function> = specific_function %impl.elem0.loc16, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc16_28.2: <bound method> = bound_method %.loc16_28.1, %specific_fn.loc16 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %bound_method.loc16_28.2(%.loc16_28.1) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_28.2: %i32 = value_of_initializer %int.convert_checked.loc16 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_28.3: %i32 = converted %.loc16_28.1, %.loc16_28.2 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_34.1: ref %i32 = array_index %a.ref, %.loc16_28.3 [concrete = <error>]
// CHECK:STDOUT: %.loc16_34.2: %i32 = bind_value %.loc16_34.1 [concrete = <error>]
// CHECK:STDOUT: assign file.%b.var, %.loc16_34.2
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
-218
View File
@@ -1,218 +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/array/fail_type_mismatch.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_type_mismatch.carbon
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+7]]:24: error: cannot implicitly convert expression of type `String` to `i32` [ConversionFailure]
// CHECK:STDERR: var a: array(i32, 3) = (1, "Hello", "World");
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: note: type `String` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var a: array(i32, 3) = (1, "Hello", "World");
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(i32, 3) = (1, "Hello", "World");
var t1: (i32, String, String);
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+7]]:24: error: cannot implicitly convert expression of type `String` to `i32` [ConversionFailure]
// CHECK:STDERR: var b: array(i32, 3) = t1;
// CHECK:STDERR: ^~
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: note: type `String` does not implement interface `Core.ImplicitAs(i32)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var b: array(i32, 3) = t1;
// CHECK:STDERR: ^~
// CHECK:STDERR:
var b: array(i32, 3) = t1;
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: error: cannot initialize array of 3 elements from 2 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: var c: array(i32, 3) = (1, 2);
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR:
var c: array(i32, 3) = (1, 2);
var t2: (i32, i32);
// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+4]]:24: error: cannot initialize array of 3 elements from tuple with 2 elements [ArrayInitFromExprArgCountMismatch]
// CHECK:STDERR: var d: array(i32, 3) = t2;
// CHECK:STDERR: ^~
// CHECK:STDERR:
var d: array(i32, 3) = t2;
// CHECK:STDOUT: --- fail_type_mismatch.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %str.ef1: String = string_literal "Hello" [concrete]
// CHECK:STDOUT: %str.abb: String = string_literal "World" [concrete]
// CHECK:STDOUT: %tuple.type.b0f: type = tuple_type (Core.IntLiteral, String, String) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
// CHECK:STDOUT: %tuple.type.9e7: type = tuple_type (%i32, String, String) [concrete]
// CHECK:STDOUT: %pattern_type.99d: type = pattern_type %tuple.type.9e7 [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
// CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete]
// CHECK:STDOUT: %pattern_type.511: type = pattern_type %tuple.type.d07 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .t1 = %t1
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: .c = %c
// CHECK:STDOUT: .t2 = %t2
// CHECK:STDOUT: .d = %d
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.5d8 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.5d8 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc18: type = splice_block %array_type.loc18 [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3.loc18: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %array_type.loc18: type = array_type %int_3.loc18, %i32.loc18 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %t1.patt: %pattern_type.99d = binding_pattern t1 [concrete]
// CHECK:STDOUT: %t1.var_patt: %pattern_type.99d = var_pattern %t1.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t1.var: ref %tuple.type.9e7 = var %t1.var_patt [concrete]
// CHECK:STDOUT: %.loc20_29.1: type = splice_block %.loc20_29.3 [concrete = constants.%tuple.type.9e7] {
// CHECK:STDOUT: %int_32.loc20: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc20: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc20_29.2: %tuple.type.ff9 = tuple_literal (%i32.loc20, String, String)
// CHECK:STDOUT: %.loc20_29.3: type = converted %.loc20_29.2, constants.%tuple.type.9e7 [concrete = constants.%tuple.type.9e7]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t1: ref %tuple.type.9e7 = bind_name t1, %t1.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.5d8 = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.5d8 = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %array_type = var %b.var_patt [concrete]
// CHECK:STDOUT: %.loc28: type = splice_block %array_type.loc28 [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc28: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc28: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3.loc28: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %array_type.loc28: type = array_type %int_3.loc28, %i32.loc28 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %array_type = bind_name b, %b.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %c.patt: %pattern_type.5d8 = binding_pattern c [concrete]
// CHECK:STDOUT: %c.var_patt: %pattern_type.5d8 = var_pattern %c.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c.var: ref %array_type = var %c.var_patt [concrete]
// CHECK:STDOUT: %.loc34: type = splice_block %array_type.loc34 [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc34: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc34: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3.loc34: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %array_type.loc34: type = array_type %int_3.loc34, %i32.loc34 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %c: ref %array_type = bind_name c, %c.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %t2.patt: %pattern_type.511 = binding_pattern t2 [concrete]
// CHECK:STDOUT: %t2.var_patt: %pattern_type.511 = var_pattern %t2.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t2.var: ref %tuple.type.d07 = var %t2.var_patt [concrete]
// CHECK:STDOUT: %.loc36_18.1: type = splice_block %.loc36_18.3 [concrete = constants.%tuple.type.d07] {
// CHECK:STDOUT: %int_32.loc36_10: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc36_10: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_32.loc36_15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc36_15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc36_18.2: %tuple.type.24b = tuple_literal (%i32.loc36_10, %i32.loc36_15)
// CHECK:STDOUT: %.loc36_18.3: type = converted %.loc36_18.2, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t2: ref %tuple.type.d07 = bind_name t2, %t2.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %d.patt: %pattern_type.5d8 = binding_pattern d [concrete]
// CHECK:STDOUT: %d.var_patt: %pattern_type.5d8 = var_pattern %d.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %d.var: ref %array_type = var %d.var_patt [concrete]
// CHECK:STDOUT: %.loc41: type = splice_block %array_type.loc41 [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc41: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc41: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3.loc41: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %array_type.loc41: type = array_type %int_3.loc41, %i32.loc41 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %d: ref %array_type = bind_name d, %d.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1.loc18: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %str.loc18_28: String = string_literal "Hello" [concrete = constants.%str.ef1]
// CHECK:STDOUT: %str.loc18_37: String = string_literal "World" [concrete = constants.%str.abb]
// CHECK:STDOUT: %.loc18_44.1: %tuple.type.b0f = tuple_literal (%int_1.loc18, %str.loc18_28, %str.loc18_37)
// CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc18_44.1: <bound method> = bound_method %int_1.loc18, %impl.elem0 [concrete = constants.%Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc18_44.2: <bound method> = bound_method %int_1.loc18, %specific_fn [concrete = constants.%bound_method]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc18_44.2(%int_1.loc18) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc18_44.2: init %i32 = converted %int_1.loc18, %int.convert_checked [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %int_0.loc18: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc18_44.3: ref %i32 = array_index file.%a.var, %int_0.loc18
// CHECK:STDOUT: %.loc18_44.4: init %i32 = initialize_from %.loc18_44.2 to %.loc18_44.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc18_44.5: %i32 = converted %str.loc18_28, <error> [concrete = <error>]
// CHECK:STDOUT: assign file.%a.var, <error>
// CHECK:STDOUT: %t1.ref: ref %tuple.type.9e7 = name_ref t1, file.%t1
// CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %t1.ref, element0
// CHECK:STDOUT: %.loc28_24.1: %i32 = bind_value %tuple.elem0
// CHECK:STDOUT: %int_0.loc28: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc28_24.2: ref %i32 = array_index file.%b.var, %int_0.loc28
// CHECK:STDOUT: %.loc28_24.3: init %i32 = initialize_from %.loc28_24.1 to %.loc28_24.2
// CHECK:STDOUT: %tuple.elem1: ref String = tuple_access %t1.ref, element1
// CHECK:STDOUT: %.loc28_24.4: %i32 = converted %tuple.elem1, <error> [concrete = <error>]
// CHECK:STDOUT: assign file.%b.var, <error>
// CHECK:STDOUT: %int_1.loc34: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc34: %tuple.type.f94 = tuple_literal (%int_1.loc34, %int_2)
// CHECK:STDOUT: assign file.%c.var, <error>
// CHECK:STDOUT: %t2.ref: ref %tuple.type.d07 = name_ref t2, file.%t2
// CHECK:STDOUT: assign file.%d.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
-185
View File
@@ -1,185 +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/array/function_param.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/function_param.carbon
fn F(arr: array(i32, 3), i: i32) -> i32 {
return arr[i];
}
fn G() -> i32 {
return F((1, 2, 3), 1);
}
// CHECK:STDOUT: --- function_param.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
// CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %arr.patt: %pattern_type.5d8 = binding_pattern arr [concrete]
// CHECK:STDOUT: %arr.param_patt: %pattern_type.5d8 = value_param_pattern %arr.patt, call_param0 [concrete]
// CHECK:STDOUT: %i.patt: %pattern_type.7ce = binding_pattern i [concrete]
// CHECK:STDOUT: %i.param_patt: %pattern_type.7ce = value_param_pattern %i.patt, call_param1 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param2 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32.loc11_37: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_37: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %arr.param: %array_type = value_param call_param0
// CHECK:STDOUT: %.loc11_23: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc11_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32.loc11_17 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %arr: %array_type = bind_name arr, %arr.param
// CHECK:STDOUT: %i.param: %i32 = value_param call_param1
// CHECK:STDOUT: %.loc11_29: type = splice_block %i32.loc11_29 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc11_29: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11_29: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %i: %i32 = bind_name i, %i.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
// CHECK:STDOUT: } {
// 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: %return.param: ref %i32 = out_param call_param0
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%arr.param: %array_type, %i.param: %i32) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %arr.ref: %array_type = name_ref arr, %arr
// CHECK:STDOUT: %i.ref: %i32 = name_ref i, %i
// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc12_15.1: ref %array_type = value_as_ref %arr.ref
// CHECK:STDOUT: %.loc12_15.2: ref %i32 = array_index %.loc12_15.1, %i.ref
// CHECK:STDOUT: %.loc12_15.3: %i32 = bind_value %.loc12_15.2
// CHECK:STDOUT: return %.loc12_15.3
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %int_1.loc16_13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc16_16: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc16_20.1: %tuple.type = tuple_literal (%int_1.loc16_13, %int_2.loc16_16, %int_3)
// CHECK:STDOUT: %int_1.loc16_23: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %impl.elem0.loc16_20.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc16_20.1: <bound method> = bound_method %int_1.loc16_13, %impl.elem0.loc16_20.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc16_20.1: <specific function> = specific_function %impl.elem0.loc16_20.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc16_20.2: <bound method> = bound_method %int_1.loc16_13, %specific_fn.loc16_20.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc16_20.1: init %i32 = call %bound_method.loc16_20.2(%int_1.loc16_13) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc16_20.2: init %i32 = converted %int_1.loc16_13, %int.convert_checked.loc16_20.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc16_20.3: ref %array_type = temporary_storage
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc16_20.4: ref %i32 = array_index %.loc16_20.3, %int_0
// CHECK:STDOUT: %.loc16_20.5: init %i32 = initialize_from %.loc16_20.2 to %.loc16_20.4 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc16_20.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc16_20.3: <bound method> = bound_method %int_2.loc16_16, %impl.elem0.loc16_20.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc16_20.2: <specific function> = specific_function %impl.elem0.loc16_20.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc16_20.4: <bound method> = bound_method %int_2.loc16_16, %specific_fn.loc16_20.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc16_20.2: init %i32 = call %bound_method.loc16_20.4(%int_2.loc16_16) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc16_20.6: init %i32 = converted %int_2.loc16_16, %int.convert_checked.loc16_20.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int_1.loc16_20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc16_20.7: ref %i32 = array_index %.loc16_20.3, %int_1.loc16_20
// CHECK:STDOUT: %.loc16_20.8: init %i32 = initialize_from %.loc16_20.6 to %.loc16_20.7 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc16_20.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc16_20.5: <bound method> = bound_method %int_3, %impl.elem0.loc16_20.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc16_20.3: <specific function> = specific_function %impl.elem0.loc16_20.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc16_20.6: <bound method> = bound_method %int_3, %specific_fn.loc16_20.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc16_20.3: init %i32 = call %bound_method.loc16_20.6(%int_3) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_20.9: init %i32 = converted %int_3, %int.convert_checked.loc16_20.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int_2.loc16_20: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc16_20.10: ref %i32 = array_index %.loc16_20.3, %int_2.loc16_20
// CHECK:STDOUT: %.loc16_20.11: init %i32 = initialize_from %.loc16_20.9 to %.loc16_20.10 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc16_20.12: init %array_type = array_init (%.loc16_20.5, %.loc16_20.8, %.loc16_20.11) to %.loc16_20.3 [concrete = constants.%array]
// CHECK:STDOUT: %.loc16_20.13: init %array_type = converted %.loc16_20.1, %.loc16_20.12 [concrete = constants.%array]
// CHECK:STDOUT: %.loc16_20.14: ref %array_type = temporary %.loc16_20.3, %.loc16_20.13
// CHECK:STDOUT: %.loc16_20.15: %array_type = bind_value %.loc16_20.14
// CHECK:STDOUT: %impl.elem0.loc16_23: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc16_23.1: <bound method> = bound_method %int_1.loc16_23, %impl.elem0.loc16_23 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc16_23: <specific function> = specific_function %impl.elem0.loc16_23, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc16_23.2: <bound method> = bound_method %int_1.loc16_23, %specific_fn.loc16_23 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc16_23: init %i32 = call %bound_method.loc16_23.2(%int_1.loc16_23) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc16_23.1: %i32 = value_of_initializer %int.convert_checked.loc16_23 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc16_23.2: %i32 = converted %int_1.loc16_23, %.loc16_23.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %F.call: init %i32 = call %F.ref(%.loc16_20.15, %.loc16_23.2)
// CHECK:STDOUT: %.loc16_25.1: %i32 = value_of_initializer %F.call
// CHECK:STDOUT: %.loc16_25.2: %i32 = converted %F.call, %.loc16_25.1
// CHECK:STDOUT: return %.loc16_25.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
-123
View File
@@ -1,123 +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/array/generic_empty.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/generic_empty.carbon
fn G(T:! type) {
// We can initialize this without knowing T.
var arr: array(T, 0) = ();
}
fn H() {
G(i32);
}
// CHECK:STDOUT: --- generic_empty.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: %G.type: type = fn_type @G [concrete]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %array_type.281: type = array_type %int_0, %T [symbolic]
// CHECK:STDOUT: %require_complete.b7f: <witness> = require_complete_type %array_type.281 [symbolic]
// CHECK:STDOUT: %pattern_type.d48: type = pattern_type %array_type.281 [symbolic]
// CHECK:STDOUT: %array.2ed: %array_type.281 = tuple_value () [symbolic]
// CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
// CHECK:STDOUT: %H: %H.type = struct_value () [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: %G.specific_fn: <specific function> = specific_function %G, @G(%i32) [concrete]
// CHECK:STDOUT: %array_type.f5c: type = array_type %int_0, %i32 [concrete]
// CHECK:STDOUT: %complete_type.cff: <witness> = complete_type_witness %array_type.f5c [concrete]
// CHECK:STDOUT: %pattern_type.772: type = pattern_type %array_type.f5c [concrete]
// CHECK:STDOUT: %array.812: %array_type.f5c = tuple_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: .H = %H.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
// CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %T.loc11_6.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_6.2 (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @G(%T.loc11_6.1: type) {
// CHECK:STDOUT: %T.loc11_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_6.2 (constants.%T)]
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %array_type.loc13_22.2: type = array_type constants.%int_0, %T.loc11_6.2 [symbolic = %array_type.loc13_22.2 (constants.%array_type.281)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %array_type.loc13_22.2 [symbolic = %require_complete (constants.%require_complete.b7f)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %array_type.loc13_22.2 [symbolic = %pattern_type (constants.%pattern_type.d48)]
// CHECK:STDOUT: %array: @G.%array_type.loc13_22.2 (%array_type.281) = tuple_value () [symbolic = %array (constants.%array.2ed)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %arr.patt: @G.%pattern_type (%pattern_type.d48) = binding_pattern arr [concrete]
// CHECK:STDOUT: %arr.var_patt: @G.%pattern_type (%pattern_type.d48) = var_pattern %arr.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc13_22.2 (%array_type.281) = var %arr.var_patt
// CHECK:STDOUT: %.loc13_27.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc13_27.2: init @G.%array_type.loc13_22.2 (%array_type.281) = array_init () to %arr.var [symbolic = %array (constants.%array.2ed)]
// CHECK:STDOUT: %.loc13_3: init @G.%array_type.loc13_22.2 (%array_type.281) = converted %.loc13_27.1, %.loc13_27.2 [symbolic = %array (constants.%array.2ed)]
// CHECK:STDOUT: assign %arr.var, %.loc13_3
// CHECK:STDOUT: %.loc13_22: type = splice_block %array_type.loc13_22.1 [symbolic = %array_type.loc13_22.2 (constants.%array_type.281)] {
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %array_type.loc13_22.1: type = array_type %int_0, %T.ref [symbolic = %array_type.loc13_22.2 (constants.%array_type.281)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %arr: ref @G.%array_type.loc13_22.2 (%array_type.281) = bind_name arr, %arr.var
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @H() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
// 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: %G.specific_fn: <specific function> = specific_function %G.ref, @G(constants.%i32) [concrete = constants.%G.specific_fn]
// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.specific_fn()
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @G(constants.%T) {
// CHECK:STDOUT: %T.loc11_6.2 => constants.%T
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @G(constants.%i32) {
// CHECK:STDOUT: %T.loc11_6.2 => constants.%i32
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %array_type.loc13_22.2 => constants.%array_type.f5c
// CHECK:STDOUT: %require_complete => constants.%complete_type.cff
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.772
// CHECK:STDOUT: %array => constants.%array.812
// CHECK:STDOUT: }
// CHECK:STDOUT:
+12 -92
View File
@@ -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/array/import.carbon
@@ -19,63 +21,16 @@ fn F() -> array(i32, 42);
import library "library";
fn G(n: i32) -> i32 {
//@dump-sem-ir-begin
return F()[n];
//@dump-sem-ir-end
}
// CHECK:STDOUT: --- library.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_42: Core.IntLiteral = int_value 42 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_42, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.b6e: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %return.patt: %pattern_type.b6e = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.b6e = out_param_pattern %return.patt, call_param0 [concrete]
// CHECK:STDOUT: } {
// 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: %int_42: Core.IntLiteral = int_value 42 [concrete = constants.%int_42]
// CHECK:STDOUT: %array_type: type = array_type %int_42, %i32 [concrete = constants.%array_type]
// CHECK:STDOUT: %return.param: ref %array_type = out_param call_param0
// CHECK:STDOUT: %return: ref %array_type = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F() -> %array_type;
// CHECK:STDOUT:
// CHECK:STDOUT: --- user.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [concrete]
@@ -84,54 +39,19 @@ fn G(n: i32) -> i32 {
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Main.F: %F.type = import_ref Main//library, F, loaded [concrete = constants.%F]
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .F = imports.%Main.F
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %default.import = import <none>
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
// CHECK:STDOUT: %n.patt: %pattern_type.7ce = binding_pattern n [concrete]
// CHECK:STDOUT: %n.param_patt: %pattern_type.7ce = value_param_pattern %n.patt, call_param0 [concrete]
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %int_32.loc4_17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc4_17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %n.param: %i32 = value_param call_param0
// CHECK:STDOUT: %.loc4: type = splice_block %i32.loc4_9 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc4_9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc4_9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %n: %i32 = bind_name n, %n.param
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G(%n.param: %i32) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.F [concrete = constants.%F]
// CHECK:STDOUT: %.loc5_12.1: ref %array_type = temporary_storage
// CHECK:STDOUT: %F.call: init %array_type = call %F.ref() to %.loc5_12.1
// CHECK:STDOUT: %.loc6_12.1: ref %array_type = temporary_storage
// CHECK:STDOUT: %F.call: init %array_type = call %F.ref() to %.loc6_12.1
// CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
// CHECK:STDOUT: %.loc5_12.2: ref %array_type = temporary %.loc5_12.1, %F.call
// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc5_15.1: ref %i32 = array_index %.loc5_12.2, %n.ref
// CHECK:STDOUT: %.loc5_15.2: %i32 = bind_value %.loc5_15.1
// CHECK:STDOUT: return %.loc5_15.2
// CHECK:STDOUT: %.loc6_12.2: ref %array_type = temporary %.loc6_12.1, %F.call
// CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc6_15.1: ref %i32 = array_index %.loc6_12.2, %n.ref
// CHECK:STDOUT: %.loc6_15.2: %i32 = bind_value %.loc6_15.1
// CHECK:STDOUT: return %.loc6_15.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F [from "library.carbon"];
// CHECK:STDOUT:
+153 -98
View File
@@ -2,31 +2,63 @@
// 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/array/index_not_literal.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/index_not_literal.carbon
var a: array(i32, 3) = (1, 2, 3);
var b: i32 = a[{.index = 2}.index];
// --- function_param.carbon
// CHECK:STDOUT: --- index_not_literal.carbon
fn F(arr: array(i32, 3), i: i32) -> i32 {
//@dump-sem-ir-begin
return arr[i];
//@dump-sem-ir-end
}
fn G() -> i32 {
//@dump-sem-ir-begin
return F((1, 2, 3), 1);
//@dump-sem-ir-end
}
// --- index_non_literal.carbon
library "[[@TEST_NAME]]";
fn F(a: array({}, 3)) -> {} {
//@dump-sem-ir-begin
return a[{.index = 2}.index];
//@dump-sem-ir-end
}
// --- fail_out_of_bound_non_literal.carbon
library "[[@TEST_NAME]]";
fn F(a: array({}, 3)) -> {} {
// CHECK:STDERR: fail_out_of_bound_non_literal.carbon:[[@LINE+4]]:12: error: array index `3` is past the end of type `array({}, 3)` [ArrayIndexOutOfBounds]
// CHECK:STDERR: return a[{.index = 3}.index];
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
return a[{.index = 3}.index];
}
// CHECK:STDOUT: --- function_param.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
@@ -38,7 +70,6 @@ var b: i32 = a[{.index = 2}.index];
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
@@ -49,108 +80,132 @@ var b: i32 = a[{.index = 2}.index];
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
// CHECK:STDOUT: %struct_type.index: type = struct_type {.index: Core.IntLiteral} [concrete]
// CHECK:STDOUT: %struct: %struct_type.index = struct_value (%int_2.ecc) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: .b = %b
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.5d8 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.5d8 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc11: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %i32.loc11 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.7ce = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.7ce = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %i32 = var %b.var_patt [concrete]
// CHECK:STDOUT: %.loc12: type = splice_block %i32.loc12 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
// CHECK:STDOUT: fn @F(%arr.param: %array_type, %i.param: %i32) -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %arr.ref: %array_type = name_ref arr, %arr
// CHECK:STDOUT: %i.ref: %i32 = name_ref i, %i
// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %.loc4_15.1: ref %array_type = value_as_ref %arr.ref
// CHECK:STDOUT: %.loc4_15.2: ref %i32 = array_index %.loc4_15.1, %i.ref
// CHECK:STDOUT: %.loc4_15.3: %i32 = bind_value %.loc4_15.2
// CHECK:STDOUT: return %.loc4_15.3
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: fn @G() -> %i32 {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1.loc11_25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc11_28: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %int_1.loc10_13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc10_16: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc11_32.1: %tuple.type = tuple_literal (%int_1.loc11_25, %int_2.loc11_28, %int_3)
// CHECK:STDOUT: %impl.elem0.loc11_32.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_32.1: <bound method> = bound_method %int_1.loc11_25, %impl.elem0.loc11_32.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc11_32.1: <specific function> = specific_function %impl.elem0.loc11_32.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_32.2: <bound method> = bound_method %int_1.loc11_25, %specific_fn.loc11_32.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc11_32.1: init %i32 = call %bound_method.loc11_32.2(%int_1.loc11_25) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc11_32.2: init %i32 = converted %int_1.loc11_25, %int.convert_checked.loc11_32.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc10_20.1: %tuple.type = tuple_literal (%int_1.loc10_13, %int_2.loc10_16, %int_3)
// CHECK:STDOUT: %int_1.loc10_23: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %impl.elem0.loc10_20.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc10_20.1: <bound method> = bound_method %int_1.loc10_13, %impl.elem0.loc10_20.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc10_20.1: <specific function> = specific_function %impl.elem0.loc10_20.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc10_20.2: <bound method> = bound_method %int_1.loc10_13, %specific_fn.loc10_20.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc10_20.1: init %i32 = call %bound_method.loc10_20.2(%int_1.loc10_13) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc10_20.2: init %i32 = converted %int_1.loc10_13, %int.convert_checked.loc10_20.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc10_20.3: ref %array_type = temporary_storage
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc11_32.3: ref %i32 = array_index file.%a.var, %int_0
// CHECK:STDOUT: %.loc11_32.4: init %i32 = initialize_from %.loc11_32.2 to %.loc11_32.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc11_32.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_32.3: <bound method> = bound_method %int_2.loc11_28, %impl.elem0.loc11_32.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc11_32.2: <specific function> = specific_function %impl.elem0.loc11_32.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_32.4: <bound method> = bound_method %int_2.loc11_28, %specific_fn.loc11_32.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc11_32.2: init %i32 = call %bound_method.loc11_32.4(%int_2.loc11_28) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc11_32.5: init %i32 = converted %int_2.loc11_28, %int.convert_checked.loc11_32.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int_1.loc11_32: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc11_32.6: ref %i32 = array_index file.%a.var, %int_1.loc11_32
// CHECK:STDOUT: %.loc11_32.7: init %i32 = initialize_from %.loc11_32.5 to %.loc11_32.6 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc11_32.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_32.5: <bound method> = bound_method %int_3, %impl.elem0.loc11_32.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc11_32.3: <specific function> = specific_function %impl.elem0.loc11_32.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_32.6: <bound method> = bound_method %int_3, %specific_fn.loc11_32.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc11_32.3: init %i32 = call %bound_method.loc11_32.6(%int_3) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc11_32.8: init %i32 = converted %int_3, %int.convert_checked.loc11_32.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int_2.loc11_32: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc11_32.9: ref %i32 = array_index file.%a.var, %int_2.loc11_32
// CHECK:STDOUT: %.loc11_32.10: init %i32 = initialize_from %.loc11_32.8 to %.loc11_32.9 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc11_32.11: init %array_type = array_init (%.loc11_32.4, %.loc11_32.7, %.loc11_32.10) to file.%a.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_32.1, %.loc11_32.11 [concrete = constants.%array]
// CHECK:STDOUT: assign file.%a.var, %.loc11_1
// CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, file.%a
// CHECK:STDOUT: %int_2.loc12: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc12_27.1: %struct_type.index = struct_literal (%int_2.loc12)
// CHECK:STDOUT: %struct: %struct_type.index = struct_value (%int_2.loc12) [concrete = constants.%struct]
// CHECK:STDOUT: %.loc12_27.2: %struct_type.index = converted %.loc12_27.1, %struct [concrete = constants.%struct]
// CHECK:STDOUT: %.loc12_28.1: Core.IntLiteral = struct_access %.loc12_27.2, element0 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc10_20.4: ref %i32 = array_index %.loc10_20.3, %int_0
// CHECK:STDOUT: %.loc10_20.5: init %i32 = initialize_from %.loc10_20.2 to %.loc10_20.4 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc10_20.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc10_20.3: <bound method> = bound_method %int_2.loc10_16, %impl.elem0.loc10_20.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc10_20.2: <specific function> = specific_function %impl.elem0.loc10_20.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc10_20.4: <bound method> = bound_method %int_2.loc10_16, %specific_fn.loc10_20.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc10_20.2: init %i32 = call %bound_method.loc10_20.4(%int_2.loc10_16) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc10_20.6: init %i32 = converted %int_2.loc10_16, %int.convert_checked.loc10_20.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int_1.loc10_20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc10_20.7: ref %i32 = array_index %.loc10_20.3, %int_1.loc10_20
// CHECK:STDOUT: %.loc10_20.8: init %i32 = initialize_from %.loc10_20.6 to %.loc10_20.7 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc10_20.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc10_20.5: <bound method> = bound_method %int_3, %impl.elem0.loc10_20.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc10_20.3: <specific function> = specific_function %impl.elem0.loc10_20.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc10_20.6: <bound method> = bound_method %int_3, %specific_fn.loc10_20.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc10_20.3: init %i32 = call %bound_method.loc10_20.6(%int_3) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc10_20.9: init %i32 = converted %int_3, %int.convert_checked.loc10_20.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int_2.loc10_20: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc10_20.10: ref %i32 = array_index %.loc10_20.3, %int_2.loc10_20
// CHECK:STDOUT: %.loc10_20.11: init %i32 = initialize_from %.loc10_20.9 to %.loc10_20.10 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc10_20.12: init %array_type = array_init (%.loc10_20.5, %.loc10_20.8, %.loc10_20.11) to %.loc10_20.3 [concrete = constants.%array]
// CHECK:STDOUT: %.loc10_20.13: init %array_type = converted %.loc10_20.1, %.loc10_20.12 [concrete = constants.%array]
// CHECK:STDOUT: %.loc10_20.14: ref %array_type = temporary %.loc10_20.3, %.loc10_20.13
// CHECK:STDOUT: %.loc10_20.15: %array_type = bind_value %.loc10_20.14
// CHECK:STDOUT: %impl.elem0.loc10_23: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc10_23.1: <bound method> = bound_method %int_1.loc10_23, %impl.elem0.loc10_23 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc10_23: <specific function> = specific_function %impl.elem0.loc10_23, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc10_23.2: <bound method> = bound_method %int_1.loc10_23, %specific_fn.loc10_23 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc10_23: init %i32 = call %bound_method.loc10_23.2(%int_1.loc10_23) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc10_23.1: %i32 = value_of_initializer %int.convert_checked.loc10_23 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc10_23.2: %i32 = converted %int_1.loc10_23, %.loc10_23.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %F.call: init %i32 = call %F.ref(%.loc10_20.15, %.loc10_23.2)
// CHECK:STDOUT: %.loc10_25.1: %i32 = value_of_initializer %F.call
// CHECK:STDOUT: %.loc10_25.2: %i32 = converted %F.call, %.loc10_25.1
// CHECK:STDOUT: return %.loc10_25.2
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- index_non_literal.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %empty_struct_type [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %struct_type.index: type = struct_type {.index: Core.IntLiteral} [concrete]
// CHECK:STDOUT: %struct: %struct_type.index = struct_value (%int_2.ecc) [concrete]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F(%a.param: %array_type) -> %empty_struct_type {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a.ref: %array_type = name_ref a, %a
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc6_23.1: %struct_type.index = struct_literal (%int_2)
// CHECK:STDOUT: %struct: %struct_type.index = struct_value (%int_2) [concrete = constants.%struct]
// CHECK:STDOUT: %.loc6_23.2: %struct_type.index = converted %.loc6_23.1, %struct [concrete = constants.%struct]
// CHECK:STDOUT: %.loc6_24.1: Core.IntLiteral = struct_access %.loc6_23.2, element0 [concrete = constants.%int_2.ecc]
// 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: %impl.elem0.loc12: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc12_28.1: <bound method> = bound_method %.loc12_28.1, %impl.elem0.loc12 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc12: <specific function> = specific_function %impl.elem0.loc12, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc12_28.2: <bound method> = bound_method %.loc12_28.1, %specific_fn.loc12 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %bound_method.loc12_28.2(%.loc12_28.1) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc12_28.2: %i32 = value_of_initializer %int.convert_checked.loc12 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc12_28.3: %i32 = converted %.loc12_28.1, %.loc12_28.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc12_34.1: ref %i32 = array_index %a.ref, %.loc12_28.3
// CHECK:STDOUT: %.loc12_34.2: %i32 = bind_value %.loc12_34.1
// CHECK:STDOUT: assign file.%b.var, %.loc12_34.2
// CHECK:STDOUT: return
// CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc6_24.1: <bound method> = bound_method %.loc6_24.1, %impl.elem0 [concrete = constants.%Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc6_24.2: <bound method> = bound_method %.loc6_24.1, %specific_fn [concrete = constants.%bound_method]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc6_24.2(%.loc6_24.1) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc6_24.2: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc6_24.3: %i32 = converted %.loc6_24.1, %.loc6_24.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc6_30.1: ref %array_type = value_as_ref %a.ref
// CHECK:STDOUT: %.loc6_30.2: ref %empty_struct_type = array_index %.loc6_30.1, %.loc6_24.3
// CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
// CHECK:STDOUT: %.loc6_30.3: %empty_struct_type = converted %.loc6_30.2, %empty_struct [concrete = constants.%empty_struct]
// CHECK:STDOUT: return %.loc6_30.3
// CHECK:STDOUT: }
// CHECK:STDOUT:
+71 -172
View File
@@ -2,12 +2,31 @@
// 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/array/init_dependent_bound.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/init_dependent_bound.carbon
// --- generic_empty.carbon
library "[[@TEST_NAME]]";
fn G(T:! type) {
// We can initialize this without knowing T.
//@dump-sem-ir-begin
var arr: array(T, 0) = ();
//@dump-sem-ir-end
}
class C {}
fn H() {
G(C);
}
// --- fail_init_dependent_bound.carbon
library "[[@TEST_NAME]]";
@@ -26,166 +45,97 @@ library "[[@TEST_NAME]]";
// TODO: This should be valid.
fn G(template N:! i32) {
//@dump-sem-ir-begin
// CHECK:STDERR: fail_todo_init_template_dependent_bound.carbon:[[@LINE+4]]:12: error: cannot evaluate type expression [TypeExprEvaluationFailure]
// CHECK:STDERR: var arr: array(i32, N) = (1, 2, 3);
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR:
var arr: array(i32, N) = (1, 2, 3);
//@dump-sem-ir-end
}
fn H() { G(3); }
// CHECK:STDOUT: --- fail_init_dependent_bound.carbon
// CHECK:STDOUT: --- generic_empty.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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: %N.51e: %i32 = bind_symbolic_name N, 0 [symbolic]
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [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.2fd: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [concrete]
// CHECK:STDOUT: %From: Core.IntLiteral = bind_symbolic_name From, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.708: type = fn_type @Convert.3, @impl.971(%From) [symbolic]
// CHECK:STDOUT: %Convert.c68: %Convert.type.708 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.a11: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.1d9, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.2fd = facet_value %i32, (%ImplicitAs.impl_witness.a11) [concrete]
// CHECK:STDOUT: %.0ea: type = fn_type_with_self_type %Convert.type.71e, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.51e, %Convert.960 [symbolic]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.960, @Convert.3(%int_32) [concrete]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %N.51e, %Convert.specific_fn [symbolic]
// CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %bound_method(%N.51e) [symbolic]
// CHECK:STDOUT: %array_type: type = array_type %int.convert_checked, %i32 [symbolic]
// CHECK:STDOUT: %require_complete.7cb: <witness> = require_complete_type %array_type [symbolic]
// CHECK:STDOUT: %pattern_type.ccc: type = pattern_type %array_type [symbolic]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %array_type.281: type = array_type %int_0, %T [symbolic]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %array_type.281 [symbolic]
// CHECK:STDOUT: %pattern_type.d48: type = pattern_type %array_type.281 [symbolic]
// CHECK:STDOUT: %array.2ed: %array_type.281 = tuple_value () [symbolic]
// CHECK:STDOUT: %C: type = class_type @C [concrete]
// CHECK:STDOUT: %array_type.6f1: type = array_type %int_0, %C [concrete]
// CHECK:STDOUT: %complete_type.ed6: <witness> = complete_type_witness %array_type.6f1 [concrete]
// CHECK:STDOUT: %pattern_type.9c8: type = pattern_type %array_type.6f1 [concrete]
// CHECK:STDOUT: %array.2e5: %array_type.6f1 = tuple_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.85c: @impl.971.%Convert.type (%Convert.type.708) = import_ref Core//prelude/types/int, loc23_44, loaded [symbolic = @impl.971.%Convert (constants.%Convert.c68)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.1d9 = impl_witness_table (%Core.import_ref.85c), @impl.971 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .F = %F.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
// CHECK:STDOUT: %N.patt: %pattern_type.7ce = symbolic_binding_pattern N, 0 [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc4: type = splice_block %i32.loc4 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc4: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc4: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %N.loc4_6.1: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc4_6.2 (constants.%N.51e)]
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @F(%N.loc4_6.1: %i32) {
// CHECK:STDOUT: %N.loc4_6.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc4_6.2 (constants.%N.51e)]
// CHECK:STDOUT: generic fn @G(%T.loc4_6.1: type) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.loc4_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)]
// CHECK:STDOUT: %bound_method.loc9_23.3: <bound method> = bound_method %N.loc4_6.2, constants.%Convert.specific_fn [symbolic = %bound_method.loc9_23.3 (constants.%bound_method)]
// CHECK:STDOUT: %int.convert_checked.loc9_23.2: init Core.IntLiteral = call %bound_method.loc9_23.3(%N.loc4_6.2) [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)]
// CHECK:STDOUT: %array_type.loc9_24.2: type = array_type %int.convert_checked.loc9_23.2, constants.%i32 [symbolic = %array_type.loc9_24.2 (constants.%array_type)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %array_type.loc9_24.2 [symbolic = %require_complete (constants.%require_complete.7cb)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %array_type.loc9_24.2 [symbolic = %pattern_type (constants.%pattern_type.ccc)]
// CHECK:STDOUT: %array_type.loc7_22.2: type = array_type constants.%int_0, %T.loc4_6.2 [symbolic = %array_type.loc7_22.2 (constants.%array_type.281)]
// CHECK:STDOUT: %require_complete: <witness> = require_complete_type %array_type.loc7_22.2 [symbolic = %require_complete (constants.%require_complete)]
// CHECK:STDOUT: %pattern_type: type = pattern_type %array_type.loc7_22.2 [symbolic = %pattern_type (constants.%pattern_type.d48)]
// CHECK:STDOUT: %array: @G.%array_type.loc7_22.2 (%array_type.281) = tuple_value () [symbolic = %array (constants.%array.2ed)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %arr.patt: @F.%pattern_type (%pattern_type.ccc) = binding_pattern arr [concrete]
// CHECK:STDOUT: %arr.var_patt: @F.%pattern_type (%pattern_type.ccc) = var_pattern %arr.patt [concrete]
// CHECK:STDOUT: %arr.patt: @G.%pattern_type (%pattern_type.d48) = binding_pattern arr [concrete]
// CHECK:STDOUT: %arr.var_patt: @G.%pattern_type (%pattern_type.d48) = var_pattern %arr.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %arr.var: ref @F.%array_type.loc9_24.2 (%array_type) = var %arr.var_patt
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc9_36: %tuple.type = tuple_literal (%int_1, %int_2, %int_3)
// CHECK:STDOUT: assign %arr.var, <error>
// CHECK:STDOUT: %.loc9_24: type = splice_block %array_type.loc9_24.1 [symbolic = %array_type.loc9_24.2 (constants.%array_type)] {
// CHECK:STDOUT: %int_32.loc9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc4_6.1 [symbolic = %N.loc4_6.2 (constants.%N.51e)]
// CHECK:STDOUT: %impl.elem0: %.0ea = impl_witness_access constants.%ImplicitAs.impl_witness.a11, element0 [concrete = constants.%Convert.960]
// CHECK:STDOUT: %bound_method.loc9_23.1: <bound method> = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound)]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc9_23.2: <bound method> = bound_method %N.ref, %specific_fn [symbolic = %bound_method.loc9_23.3 (constants.%bound_method)]
// CHECK:STDOUT: %int.convert_checked.loc9_23.1: init Core.IntLiteral = call %bound_method.loc9_23.2(%N.ref) [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)]
// CHECK:STDOUT: %.loc9_23.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc9_23.1 [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)]
// CHECK:STDOUT: %.loc9_23.2: Core.IntLiteral = converted %N.ref, %.loc9_23.1 [symbolic = %int.convert_checked.loc9_23.2 (constants.%int.convert_checked)]
// CHECK:STDOUT: %array_type.loc9_24.1: type = array_type %.loc9_23.2, %i32.loc9 [symbolic = %array_type.loc9_24.2 (constants.%array_type)]
// CHECK:STDOUT: %arr.var: ref @G.%array_type.loc7_22.2 (%array_type.281) = var %arr.var_patt
// CHECK:STDOUT: %.loc7_27.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc7_27.2: init @G.%array_type.loc7_22.2 (%array_type.281) = array_init () to %arr.var [symbolic = %array (constants.%array.2ed)]
// CHECK:STDOUT: %.loc7_3: init @G.%array_type.loc7_22.2 (%array_type.281) = converted %.loc7_27.1, %.loc7_27.2 [symbolic = %array (constants.%array.2ed)]
// CHECK:STDOUT: assign %arr.var, %.loc7_3
// CHECK:STDOUT: %.loc7_22: type = splice_block %array_type.loc7_22.1 [symbolic = %array_type.loc7_22.2 (constants.%array_type.281)] {
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_6.1 [symbolic = %T.loc4_6.2 (constants.%T)]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %array_type.loc7_22.1: type = array_type %int_0, %T.ref [symbolic = %array_type.loc7_22.2 (constants.%array_type.281)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %arr: ref @F.%array_type.loc9_24.2 (%array_type) = bind_name arr, %arr.var
// CHECK:STDOUT: return
// CHECK:STDOUT: %arr: ref @G.%array_type.loc7_22.2 (%array_type.281) = bind_name arr, %arr.var
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%N.51e) {
// CHECK:STDOUT: %N.loc4_6.2 => constants.%N.51e
// CHECK:STDOUT: specific @G(constants.%T) {
// CHECK:STDOUT: %T.loc4_6.2 => constants.%T
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @G(constants.%C) {
// CHECK:STDOUT: %T.loc4_6.2 => constants.%C
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %array_type.loc7_22.2 => constants.%array_type.6f1
// CHECK:STDOUT: %require_complete => constants.%complete_type.ed6
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.9c8
// CHECK:STDOUT: %array => constants.%array.2e5
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- fail_todo_init_template_dependent_bound.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %N.51e: %i32 = bind_symbolic_name N, 0, template [template]
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
// CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
// CHECK:STDOUT: %H: %H.type = struct_value () [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.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.type.2fd: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
// CHECK:STDOUT: %From: Core.IntLiteral = bind_symbolic_name From, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.708: type = fn_type @Convert.3, @impl.971(%From) [symbolic]
// CHECK:STDOUT: %Convert.c68: %Convert.type.708 = struct_value () [symbolic]
// CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet.921: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet.921 [concrete]
// CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn.b6f: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn.b6f [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G, @G(%int_3.822) [concrete]
// CHECK:STDOUT: %ImplicitAs.impl_witness.a11: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.1d9, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.971(%int_32) [concrete]
// CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [concrete]
@@ -208,44 +158,15 @@ fn H() { G(3); }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: %Core.import_ref.85c: @impl.971.%Convert.type (%Convert.type.708) = import_ref Core//prelude/types/int, loc23_44, loaded [symbolic = @impl.971.%Convert (constants.%Convert.c68)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.1d9 = impl_witness_table (%Core.import_ref.85c), @impl.971 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .G = %G.decl
// CHECK:STDOUT: .H = %H.decl
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
// CHECK:STDOUT: %N.patt: %pattern_type.7ce = symbolic_binding_pattern N, 0, template [concrete]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5 [concrete = constants.%i32] {
// CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: }
// CHECK:STDOUT: %N.loc5_15.1: %i32 = bind_symbolic_name N, 0, template [template = %N.loc5_15.2 (constants.%N.51e)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {} {}
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @G(%N.loc5_15.1: %i32) {
// CHECK:STDOUT: %N.loc5_15.2: %i32 = bind_symbolic_name N, 0, template [template = %N.loc5_15.2 (constants.%N.51e)]
// CHECK:STDOUT: <elided>
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %.loc10_23.2: <instruction> = convert_to_value_action %N.ref, Core.IntLiteral [template]
// CHECK:STDOUT: %.loc11_23.2: <instruction> = convert_to_value_action %N.ref, Core.IntLiteral [template]
// CHECK:STDOUT:
// CHECK:STDOUT: fn() {
// CHECK:STDOUT: !entry:
@@ -257,36 +178,14 @@ fn H() { G(3); }
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc10_36: %tuple.type = tuple_literal (%int_1, %int_2, %int_3)
// CHECK:STDOUT: %.loc11_36: %tuple.type = tuple_literal (%int_1, %int_2, %int_3)
// CHECK:STDOUT: assign %arr.var, <error>
// CHECK:STDOUT: %.1: <error> = splice_block <error> [concrete = <error>] {
// CHECK:STDOUT: %int_32.loc10: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
// CHECK:STDOUT: %i32.loc10: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
// CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc5_15.1 [template = %N.loc5_15.2 (constants.%N.51e)]
// CHECK:STDOUT: %.loc10_23.1: Core.IntLiteral = splice_inst %.loc10_23.2
// CHECK:STDOUT: %array_type: type = array_type %.loc10_23.1, %i32.loc10
// CHECK:STDOUT: }
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %arr: <error> = bind_name arr, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @H() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc13_13.1: <bound method> = bound_method %int_3, %impl.elem0 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn.b6f]
// CHECK:STDOUT: %bound_method.loc13_13.2: <bound method> = bound_method %int_3, %specific_fn [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc13_13.2(%int_3) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc13_13.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc13_13.2: %i32 = converted %int_3, %.loc13_13.1 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G.ref, @G(constants.%int_3.822) [concrete = constants.%G.specific_fn]
// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.specific_fn()
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @G(constants.%N.51e) {
// CHECK:STDOUT: %N.loc5_15.2 => constants.%N.51e
// CHECK:STDOUT: }
@@ -295,6 +194,6 @@ fn H() { G(3); }
// CHECK:STDOUT: %N.loc5_15.2 => constants.%int_3.822
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %.loc10_23.2 => constants.%inst.splice_block
// CHECK:STDOUT: %.loc11_23.2 => constants.%inst.splice_block
// CHECK:STDOUT: }
// CHECK:STDOUT:
-207
View File
@@ -1,207 +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/array/nine_elements.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/nine_elements.carbon
var a: array(i32, 9) = (1, 2, 3, 4, 5, 6, 7, 8, 9);
// CHECK:STDOUT: --- nine_elements.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// 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_9.988: Core.IntLiteral = int_value 9 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_9.988, %i32 [concrete]
// CHECK:STDOUT: %pattern_type.b3e: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
// CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [concrete]
// CHECK:STDOUT: %int_6.462: Core.IntLiteral = int_value 6 [concrete]
// CHECK:STDOUT: %int_7.29f: Core.IntLiteral = int_value 7 [concrete]
// CHECK:STDOUT: %int_8.b85: Core.IntLiteral = int_value 8 [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral, Core.IntLiteral, Core.IntLiteral, Core.IntLiteral, Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
// CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
// CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
// CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
// CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
// CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
// CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
// CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
// CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
// CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
// CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
// CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.1da: <bound method> = bound_method %int_4.0c1, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
// CHECK:STDOUT: %Convert.bound.4e6: <bound method> = bound_method %int_5.64b, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.a25: <bound method> = bound_method %int_5.64b, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [concrete]
// CHECK:STDOUT: %Convert.bound.ce9: <bound method> = bound_method %int_6.462, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.efa: <bound method> = bound_method %int_6.462, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_6.e56: %i32 = int_value 6 [concrete]
// CHECK:STDOUT: %Convert.bound.208: <bound method> = bound_method %int_7.29f, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.3bd: <bound method> = bound_method %int_7.29f, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_7.0b1: %i32 = int_value 7 [concrete]
// CHECK:STDOUT: %Convert.bound.e09: <bound method> = bound_method %int_8.b85, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.02d: <bound method> = bound_method %int_8.b85, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_8.98c: %i32 = int_value 8 [concrete]
// CHECK:STDOUT: %Convert.bound.9e2: <bound method> = bound_method %int_9.988, %Convert.956 [concrete]
// CHECK:STDOUT: %bound_method.cd3: <bound method> = bound_method %int_9.988, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_9.f88: %i32 = int_value 9 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822, %int_4.940, %int_5.0f6, %int_6.e56, %int_7.0b1, %int_8.98c, %int_9.f88) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
// CHECK:STDOUT: .Int = %Core.Int
// 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.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
// CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
// CHECK:STDOUT: .Core = imports.%Core
// CHECK:STDOUT: .a = %a
// CHECK:STDOUT: }
// CHECK:STDOUT: %Core.import = import Core
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.b3e = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.b3e = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt [concrete]
// CHECK:STDOUT: %.loc11: type = splice_block %array_type [concrete = constants.%array_type] {
// 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: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9.988]
// CHECK:STDOUT: %array_type: type = array_type %int_9, %i32 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %int_1.loc11_25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %int_2.loc11_28: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %int_3.loc11_31: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %int_4.loc11_34: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
// CHECK:STDOUT: %int_5.loc11_37: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
// CHECK:STDOUT: %int_6.loc11_40: Core.IntLiteral = int_value 6 [concrete = constants.%int_6.462]
// CHECK:STDOUT: %int_7.loc11_43: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f]
// CHECK:STDOUT: %int_8.loc11_46: Core.IntLiteral = int_value 8 [concrete = constants.%int_8.b85]
// CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9.988]
// CHECK:STDOUT: %.loc11_50.1: %tuple.type = tuple_literal (%int_1.loc11_25, %int_2.loc11_28, %int_3.loc11_31, %int_4.loc11_34, %int_5.loc11_37, %int_6.loc11_40, %int_7.loc11_43, %int_8.loc11_46, %int_9)
// CHECK:STDOUT: %impl.elem0.loc11_50.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.1: <bound method> = bound_method %int_1.loc11_25, %impl.elem0.loc11_50.1 [concrete = constants.%Convert.bound.ab5]
// CHECK:STDOUT: %specific_fn.loc11_50.1: <specific function> = specific_function %impl.elem0.loc11_50.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.2: <bound method> = bound_method %int_1.loc11_25, %specific_fn.loc11_50.1 [concrete = constants.%bound_method.9a1]
// CHECK:STDOUT: %int.convert_checked.loc11_50.1: init %i32 = call %bound_method.loc11_50.2(%int_1.loc11_25) [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %.loc11_50.2: init %i32 = converted %int_1.loc11_25, %int.convert_checked.loc11_50.1 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc11_50.3: ref %i32 = array_index file.%a.var, %int_0
// CHECK:STDOUT: %.loc11_50.4: init %i32 = initialize_from %.loc11_50.2 to %.loc11_50.3 [concrete = constants.%int_1.5d2]
// CHECK:STDOUT: %impl.elem0.loc11_50.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.3: <bound method> = bound_method %int_2.loc11_28, %impl.elem0.loc11_50.2 [concrete = constants.%Convert.bound.ef9]
// CHECK:STDOUT: %specific_fn.loc11_50.2: <specific function> = specific_function %impl.elem0.loc11_50.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.4: <bound method> = bound_method %int_2.loc11_28, %specific_fn.loc11_50.2 [concrete = constants.%bound_method.b92]
// CHECK:STDOUT: %int.convert_checked.loc11_50.2: init %i32 = call %bound_method.loc11_50.4(%int_2.loc11_28) [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %.loc11_50.5: init %i32 = converted %int_2.loc11_28, %int.convert_checked.loc11_50.2 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %int_1.loc11_50: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
// CHECK:STDOUT: %.loc11_50.6: ref %i32 = array_index file.%a.var, %int_1.loc11_50
// CHECK:STDOUT: %.loc11_50.7: init %i32 = initialize_from %.loc11_50.5 to %.loc11_50.6 [concrete = constants.%int_2.ef8]
// CHECK:STDOUT: %impl.elem0.loc11_50.3: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.5: <bound method> = bound_method %int_3.loc11_31, %impl.elem0.loc11_50.3 [concrete = constants.%Convert.bound.b30]
// CHECK:STDOUT: %specific_fn.loc11_50.3: <specific function> = specific_function %impl.elem0.loc11_50.3, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.6: <bound method> = bound_method %int_3.loc11_31, %specific_fn.loc11_50.3 [concrete = constants.%bound_method.047]
// CHECK:STDOUT: %int.convert_checked.loc11_50.3: init %i32 = call %bound_method.loc11_50.6(%int_3.loc11_31) [concrete = constants.%int_3.822]
// CHECK:STDOUT: %.loc11_50.8: init %i32 = converted %int_3.loc11_31, %int.convert_checked.loc11_50.3 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %int_2.loc11_50: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
// CHECK:STDOUT: %.loc11_50.9: ref %i32 = array_index file.%a.var, %int_2.loc11_50
// CHECK:STDOUT: %.loc11_50.10: init %i32 = initialize_from %.loc11_50.8 to %.loc11_50.9 [concrete = constants.%int_3.822]
// CHECK:STDOUT: %impl.elem0.loc11_50.4: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.7: <bound method> = bound_method %int_4.loc11_34, %impl.elem0.loc11_50.4 [concrete = constants.%Convert.bound.ac3]
// CHECK:STDOUT: %specific_fn.loc11_50.4: <specific function> = specific_function %impl.elem0.loc11_50.4, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.8: <bound method> = bound_method %int_4.loc11_34, %specific_fn.loc11_50.4 [concrete = constants.%bound_method.1da]
// CHECK:STDOUT: %int.convert_checked.loc11_50.4: init %i32 = call %bound_method.loc11_50.8(%int_4.loc11_34) [concrete = constants.%int_4.940]
// CHECK:STDOUT: %.loc11_50.11: init %i32 = converted %int_4.loc11_34, %int.convert_checked.loc11_50.4 [concrete = constants.%int_4.940]
// CHECK:STDOUT: %int_3.loc11_50: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
// CHECK:STDOUT: %.loc11_50.12: ref %i32 = array_index file.%a.var, %int_3.loc11_50
// CHECK:STDOUT: %.loc11_50.13: init %i32 = initialize_from %.loc11_50.11 to %.loc11_50.12 [concrete = constants.%int_4.940]
// CHECK:STDOUT: %impl.elem0.loc11_50.5: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.9: <bound method> = bound_method %int_5.loc11_37, %impl.elem0.loc11_50.5 [concrete = constants.%Convert.bound.4e6]
// CHECK:STDOUT: %specific_fn.loc11_50.5: <specific function> = specific_function %impl.elem0.loc11_50.5, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.10: <bound method> = bound_method %int_5.loc11_37, %specific_fn.loc11_50.5 [concrete = constants.%bound_method.a25]
// CHECK:STDOUT: %int.convert_checked.loc11_50.5: init %i32 = call %bound_method.loc11_50.10(%int_5.loc11_37) [concrete = constants.%int_5.0f6]
// CHECK:STDOUT: %.loc11_50.14: init %i32 = converted %int_5.loc11_37, %int.convert_checked.loc11_50.5 [concrete = constants.%int_5.0f6]
// CHECK:STDOUT: %int_4.loc11_50: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
// CHECK:STDOUT: %.loc11_50.15: ref %i32 = array_index file.%a.var, %int_4.loc11_50
// CHECK:STDOUT: %.loc11_50.16: init %i32 = initialize_from %.loc11_50.14 to %.loc11_50.15 [concrete = constants.%int_5.0f6]
// CHECK:STDOUT: %impl.elem0.loc11_50.6: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.11: <bound method> = bound_method %int_6.loc11_40, %impl.elem0.loc11_50.6 [concrete = constants.%Convert.bound.ce9]
// CHECK:STDOUT: %specific_fn.loc11_50.6: <specific function> = specific_function %impl.elem0.loc11_50.6, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.12: <bound method> = bound_method %int_6.loc11_40, %specific_fn.loc11_50.6 [concrete = constants.%bound_method.efa]
// CHECK:STDOUT: %int.convert_checked.loc11_50.6: init %i32 = call %bound_method.loc11_50.12(%int_6.loc11_40) [concrete = constants.%int_6.e56]
// CHECK:STDOUT: %.loc11_50.17: init %i32 = converted %int_6.loc11_40, %int.convert_checked.loc11_50.6 [concrete = constants.%int_6.e56]
// CHECK:STDOUT: %int_5.loc11_50: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
// CHECK:STDOUT: %.loc11_50.18: ref %i32 = array_index file.%a.var, %int_5.loc11_50
// CHECK:STDOUT: %.loc11_50.19: init %i32 = initialize_from %.loc11_50.17 to %.loc11_50.18 [concrete = constants.%int_6.e56]
// CHECK:STDOUT: %impl.elem0.loc11_50.7: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.13: <bound method> = bound_method %int_7.loc11_43, %impl.elem0.loc11_50.7 [concrete = constants.%Convert.bound.208]
// CHECK:STDOUT: %specific_fn.loc11_50.7: <specific function> = specific_function %impl.elem0.loc11_50.7, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.14: <bound method> = bound_method %int_7.loc11_43, %specific_fn.loc11_50.7 [concrete = constants.%bound_method.3bd]
// CHECK:STDOUT: %int.convert_checked.loc11_50.7: init %i32 = call %bound_method.loc11_50.14(%int_7.loc11_43) [concrete = constants.%int_7.0b1]
// CHECK:STDOUT: %.loc11_50.20: init %i32 = converted %int_7.loc11_43, %int.convert_checked.loc11_50.7 [concrete = constants.%int_7.0b1]
// CHECK:STDOUT: %int_6.loc11_50: Core.IntLiteral = int_value 6 [concrete = constants.%int_6.462]
// CHECK:STDOUT: %.loc11_50.21: ref %i32 = array_index file.%a.var, %int_6.loc11_50
// CHECK:STDOUT: %.loc11_50.22: init %i32 = initialize_from %.loc11_50.20 to %.loc11_50.21 [concrete = constants.%int_7.0b1]
// CHECK:STDOUT: %impl.elem0.loc11_50.8: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.15: <bound method> = bound_method %int_8.loc11_46, %impl.elem0.loc11_50.8 [concrete = constants.%Convert.bound.e09]
// CHECK:STDOUT: %specific_fn.loc11_50.8: <specific function> = specific_function %impl.elem0.loc11_50.8, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.16: <bound method> = bound_method %int_8.loc11_46, %specific_fn.loc11_50.8 [concrete = constants.%bound_method.02d]
// CHECK:STDOUT: %int.convert_checked.loc11_50.8: init %i32 = call %bound_method.loc11_50.16(%int_8.loc11_46) [concrete = constants.%int_8.98c]
// CHECK:STDOUT: %.loc11_50.23: init %i32 = converted %int_8.loc11_46, %int.convert_checked.loc11_50.8 [concrete = constants.%int_8.98c]
// CHECK:STDOUT: %int_7.loc11_50: Core.IntLiteral = int_value 7 [concrete = constants.%int_7.29f]
// CHECK:STDOUT: %.loc11_50.24: ref %i32 = array_index file.%a.var, %int_7.loc11_50
// CHECK:STDOUT: %.loc11_50.25: init %i32 = initialize_from %.loc11_50.23 to %.loc11_50.24 [concrete = constants.%int_8.98c]
// CHECK:STDOUT: %impl.elem0.loc11_50.9: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method.loc11_50.17: <bound method> = bound_method %int_9, %impl.elem0.loc11_50.9 [concrete = constants.%Convert.bound.9e2]
// CHECK:STDOUT: %specific_fn.loc11_50.9: <specific function> = specific_function %impl.elem0.loc11_50.9, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc11_50.18: <bound method> = bound_method %int_9, %specific_fn.loc11_50.9 [concrete = constants.%bound_method.cd3]
// CHECK:STDOUT: %int.convert_checked.loc11_50.9: init %i32 = call %bound_method.loc11_50.18(%int_9) [concrete = constants.%int_9.f88]
// CHECK:STDOUT: %.loc11_50.26: init %i32 = converted %int_9, %int.convert_checked.loc11_50.9 [concrete = constants.%int_9.f88]
// CHECK:STDOUT: %int_8.loc11_50: Core.IntLiteral = int_value 8 [concrete = constants.%int_8.b85]
// CHECK:STDOUT: %.loc11_50.27: ref %i32 = array_index file.%a.var, %int_8.loc11_50
// CHECK:STDOUT: %.loc11_50.28: init %i32 = initialize_from %.loc11_50.26 to %.loc11_50.27 [concrete = constants.%int_9.f88]
// CHECK:STDOUT: %.loc11_50.29: init %array_type = array_init (%.loc11_50.4, %.loc11_50.7, %.loc11_50.10, %.loc11_50.13, %.loc11_50.16, %.loc11_50.19, %.loc11_50.22, %.loc11_50.25, %.loc11_50.28) to file.%a.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc11_1: init %array_type = converted %.loc11_50.1, %.loc11_50.29 [concrete = constants.%array]
// CHECK:STDOUT: assign file.%a.var, %.loc11_1
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
+389
View File
@@ -0,0 +1,389 @@
// 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/array/no_prelude/basics.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/no_prelude/basics.carbon
// --- assign_var.carbon
library "[[@TEST_NAME]]";
var a: ((), (), ());
//@dump-sem-ir-begin
var b: array((), 3) = a;
//@dump-sem-ir-end
// --- assign_arity.carbon
var a0: array((), 0) = ();
var a1: array((), 1) = ((),);
var a2: array((), 2) = ((), ());
// --- array_in_place.carbon
library "[[@TEST_NAME]]";
class C {}
fn F() -> (C, C, C);
fn G() {
//@dump-sem-ir-begin
var v: array((C, C, C), 2) = (F(), F());
//@dump-sem-ir-end
}
// --- array_vs_tuple.carbon
library "[[@TEST_NAME]]";
fn G() {
// These should have two different constant values.
//@dump-sem-ir-begin
var a: array((), 3);
var b: ((), (), ());
//@dump-sem-ir-end
}
// --- assign_return_value.carbon
library "[[@TEST_NAME]]";
fn F() -> ((),) { return ((),); }
fn Run() {
//@dump-sem-ir-begin
var t: array((), 1) = F();
//@dump-sem-ir-end
}
// --- nine_elements.carbon
library "[[@TEST_NAME]]";
var a: ((), (), (), (), (), (), (), (), ()) =
((), (), (), (), (), (), (), (), ());
// Regression test for APInt handling.
//@dump-sem-ir-begin
var b: array((), 9) = a;
//@dump-sem-ir-end
// --- fail_incomplete_element.carbon
library "[[@TEST_NAME]]";
class Incomplete;
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+7]]:8: error: binding pattern has incomplete type `array(Incomplete, 1)` in name binding declaration [IncompleteTypeInBindingDecl]
// CHECK:STDERR: var a: array(Incomplete, 1);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class Incomplete;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(Incomplete, 1);
var p: Incomplete* = &a[0];
// --- fail_invalid_element.carbon
library "[[@TEST_NAME]]";
// CHECK:STDERR: fail_invalid_element.carbon:[[@LINE+4]]:14: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
// CHECK:STDERR: var a: array(1, 1);
// CHECK:STDERR: ^
// CHECK:STDERR:
var a: array(1, 1);
// CHECK:STDOUT: --- assign_var.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %empty_tuple.type [concrete]
// CHECK:STDOUT: %pattern_type.035: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%empty_tuple, %empty_tuple, %empty_tuple) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.035 = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.035 = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %array_type = var %b.var_patt [concrete]
// CHECK:STDOUT: %.loc6_19: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %.loc6_15.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc6_15.2: type = converted %.loc6_15.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %.loc6_15.2 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %array_type = bind_name b, %b.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a.ref: ref %tuple.type = name_ref a, file.%a
// CHECK:STDOUT: %tuple.elem0: ref %empty_tuple.type = tuple_access %a.ref, element0
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc6_23.1: ref %empty_tuple.type = array_index file.%b.var, %int_0
// CHECK:STDOUT: %.loc6_23.2: init %empty_tuple.type = tuple_init () to %.loc6_23.1 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc6_23.3: init %empty_tuple.type = converted %tuple.elem0, %.loc6_23.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem1: ref %empty_tuple.type = tuple_access %a.ref, element1
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %.loc6_23.4: ref %empty_tuple.type = array_index file.%b.var, %int_1
// CHECK:STDOUT: %.loc6_23.5: init %empty_tuple.type = tuple_init () to %.loc6_23.4 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc6_23.6: init %empty_tuple.type = converted %tuple.elem1, %.loc6_23.5 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem2: ref %empty_tuple.type = tuple_access %a.ref, element2
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc6_23.7: ref %empty_tuple.type = array_index file.%b.var, %int_2
// CHECK:STDOUT: %.loc6_23.8: init %empty_tuple.type = tuple_init () to %.loc6_23.7 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc6_23.9: init %empty_tuple.type = converted %tuple.elem2, %.loc6_23.8 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc6_23.10: init %array_type = array_init (%.loc6_23.3, %.loc6_23.6, %.loc6_23.9) to file.%b.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc6_1: init %array_type = converted %a.ref, %.loc6_23.10 [concrete = constants.%array]
// CHECK:STDOUT: assign file.%b.var, %.loc6_1
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- array_in_place.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %C: type = class_type @C [concrete]
// CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
// CHECK:STDOUT: %tuple.type.734: type = tuple_type (%C, %C, %C) [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_2, %tuple.type.734 [concrete]
// CHECK:STDOUT: %pattern_type.e0b: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %tuple.type.14a: type = tuple_type (%tuple.type.734, %tuple.type.734) [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %v.patt: %pattern_type.e0b = binding_pattern v [concrete]
// CHECK:STDOUT: %v.var_patt: %pattern_type.e0b = var_pattern %v.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %v.var: ref %array_type = var %v.var_patt
// CHECK:STDOUT: %F.ref.loc10_33: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %.loc10_41.1: ref %tuple.type.734 = splice_block %.loc10_41.2 {
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc10_41.2: ref %tuple.type.734 = array_index %v.var, %int_0
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.call.loc10_35: init %tuple.type.734 = call %F.ref.loc10_33() to %.loc10_41.1
// CHECK:STDOUT: %F.ref.loc10_38: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %.loc10_41.3: ref %tuple.type.734 = splice_block %.loc10_41.4 {
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %.loc10_41.4: ref %tuple.type.734 = array_index %v.var, %int_1
// CHECK:STDOUT: }
// CHECK:STDOUT: %F.call.loc10_40: init %tuple.type.734 = call %F.ref.loc10_38() to %.loc10_41.3
// CHECK:STDOUT: %.loc10_41.5: %tuple.type.14a = tuple_literal (%F.call.loc10_35, %F.call.loc10_40)
// CHECK:STDOUT: %.loc10_41.6: init %array_type = array_init (%F.call.loc10_35, %F.call.loc10_40) to %v.var
// CHECK:STDOUT: %.loc10_3: init %array_type = converted %.loc10_41.5, %.loc10_41.6
// CHECK:STDOUT: assign %v.var, %.loc10_3
// CHECK:STDOUT: %.loc10_28: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %C.ref.loc10_17: type = name_ref C, file.%C.decl [concrete = constants.%C]
// CHECK:STDOUT: %C.ref.loc10_20: type = name_ref C, file.%C.decl [concrete = constants.%C]
// CHECK:STDOUT: %C.ref.loc10_23: type = name_ref C, file.%C.decl [concrete = constants.%C]
// CHECK:STDOUT: %.loc10_24.1: %tuple.type.ff9 = tuple_literal (%C.ref.loc10_17, %C.ref.loc10_20, %C.ref.loc10_23)
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc10_24.2: type = converted %.loc10_24.1, constants.%tuple.type.734 [concrete = constants.%tuple.type.734]
// CHECK:STDOUT: %array_type: type = array_type %int_2, %.loc10_24.2 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %v: ref %array_type = bind_name v, %v.var
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- array_vs_tuple.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %empty_tuple.type [concrete]
// CHECK:STDOUT: %pattern_type.035: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
// CHECK:STDOUT: %pattern_type.8c1: type = pattern_type %tuple.type [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %a.patt: %pattern_type.035 = binding_pattern a [concrete]
// CHECK:STDOUT: %a.var_patt: %pattern_type.035 = var_pattern %a.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt
// CHECK:STDOUT: %.loc7_21: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %.loc7_17.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc7_17.2: type = converted %.loc7_17.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %array_type: type = array_type %int_3, %.loc7_17.2 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.8c1 = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.8c1 = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %tuple.type = var %b.var_patt
// CHECK:STDOUT: %.loc8_21.1: type = splice_block %.loc8_21.6 [concrete = constants.%tuple.type] {
// CHECK:STDOUT: %.loc8_12: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc8_16: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc8_20: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %.loc8_21.2: %tuple.type = tuple_literal (%.loc8_12, %.loc8_16, %.loc8_20)
// CHECK:STDOUT: %.loc8_21.3: type = converted %.loc8_12, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc8_21.4: type = converted %.loc8_16, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc8_21.5: type = converted %.loc8_20, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %.loc8_21.6: type = converted %.loc8_21.2, constants.%tuple.type [concrete = constants.%tuple.type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %tuple.type = bind_name b, %b.var
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- assign_return_value.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type) [concrete]
// CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
// CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %empty_tuple.type [concrete]
// CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%empty_tuple) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Run() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %t.patt: %pattern_type.fe8 = binding_pattern t [concrete]
// CHECK:STDOUT: %t.var_patt: %pattern_type.fe8 = var_pattern %t.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t.var: ref %array_type = var %t.var_patt
// CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
// CHECK:STDOUT: %F.call: init %tuple.type = call %F.ref()
// CHECK:STDOUT: %.loc8_27.1: ref %tuple.type = temporary_storage
// CHECK:STDOUT: %.loc8_27.2: ref %tuple.type = temporary %.loc8_27.1, %F.call
// CHECK:STDOUT: %tuple.elem0: ref %empty_tuple.type = tuple_access %.loc8_27.2, element0
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc8_27.3: ref %empty_tuple.type = array_index %t.var, %int_0
// CHECK:STDOUT: %.loc8_27.4: init %empty_tuple.type = tuple_init () to %.loc8_27.3 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc8_27.5: init %empty_tuple.type = converted %tuple.elem0, %.loc8_27.4 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc8_27.6: init %array_type = array_init (%.loc8_27.5) to %t.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc8_3: init %array_type = converted %F.call, %.loc8_27.6 [concrete = constants.%array]
// CHECK:STDOUT: assign %t.var, %.loc8_3
// CHECK:STDOUT: %.loc8_21: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %.loc8_17.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %.loc8_17.2: type = converted %.loc8_17.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %array_type: type = array_type %int_1, %.loc8_17.2 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %t: ref %array_type = bind_name t, %t.var
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: --- nine_elements.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
// CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete]
// CHECK:STDOUT: %array_type: type = array_type %int_9, %empty_tuple.type [concrete]
// CHECK:STDOUT: %pattern_type.3db: type = pattern_type %array_type [concrete]
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete]
// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete]
// CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [concrete]
// CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete]
// CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple) [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: name_binding_decl {
// CHECK:STDOUT: %b.patt: %pattern_type.3db = binding_pattern b [concrete]
// CHECK:STDOUT: %b.var_patt: %pattern_type.3db = var_pattern %b.patt [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b.var: ref %array_type = var %b.var_patt [concrete]
// CHECK:STDOUT: %.loc9_19: type = splice_block %array_type [concrete = constants.%array_type] {
// CHECK:STDOUT: %.loc9_15.1: %empty_tuple.type = tuple_literal ()
// CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9]
// CHECK:STDOUT: %.loc9_15.2: type = converted %.loc9_15.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
// CHECK:STDOUT: %array_type: type = array_type %int_9, %.loc9_15.2 [concrete = constants.%array_type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %b: ref %array_type = bind_name b, %b.var
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %a.ref: ref %tuple.type = name_ref a, file.%a
// CHECK:STDOUT: %tuple.elem0.loc9: ref %empty_tuple.type = tuple_access %a.ref, element0
// CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
// CHECK:STDOUT: %.loc9_23.1: ref %empty_tuple.type = array_index file.%b.var, %int_0
// CHECK:STDOUT: %.loc9_23.2: init %empty_tuple.type = tuple_init () to %.loc9_23.1 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.3: init %empty_tuple.type = converted %tuple.elem0.loc9, %.loc9_23.2 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem1.loc9: ref %empty_tuple.type = tuple_access %a.ref, element1
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
// CHECK:STDOUT: %.loc9_23.4: ref %empty_tuple.type = array_index file.%b.var, %int_1
// CHECK:STDOUT: %.loc9_23.5: init %empty_tuple.type = tuple_init () to %.loc9_23.4 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.6: init %empty_tuple.type = converted %tuple.elem1.loc9, %.loc9_23.5 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem2.loc9: ref %empty_tuple.type = tuple_access %a.ref, element2
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
// CHECK:STDOUT: %.loc9_23.7: ref %empty_tuple.type = array_index file.%b.var, %int_2
// CHECK:STDOUT: %.loc9_23.8: init %empty_tuple.type = tuple_init () to %.loc9_23.7 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.9: init %empty_tuple.type = converted %tuple.elem2.loc9, %.loc9_23.8 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem3.loc9: ref %empty_tuple.type = tuple_access %a.ref, element3
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
// CHECK:STDOUT: %.loc9_23.10: ref %empty_tuple.type = array_index file.%b.var, %int_3
// CHECK:STDOUT: %.loc9_23.11: init %empty_tuple.type = tuple_init () to %.loc9_23.10 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.12: init %empty_tuple.type = converted %tuple.elem3.loc9, %.loc9_23.11 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem4.loc9: ref %empty_tuple.type = tuple_access %a.ref, element4
// CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4]
// CHECK:STDOUT: %.loc9_23.13: ref %empty_tuple.type = array_index file.%b.var, %int_4
// CHECK:STDOUT: %.loc9_23.14: init %empty_tuple.type = tuple_init () to %.loc9_23.13 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.15: init %empty_tuple.type = converted %tuple.elem4.loc9, %.loc9_23.14 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem5.loc9: ref %empty_tuple.type = tuple_access %a.ref, element5
// CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5]
// CHECK:STDOUT: %.loc9_23.16: ref %empty_tuple.type = array_index file.%b.var, %int_5
// CHECK:STDOUT: %.loc9_23.17: init %empty_tuple.type = tuple_init () to %.loc9_23.16 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.18: init %empty_tuple.type = converted %tuple.elem5.loc9, %.loc9_23.17 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem6.loc9: ref %empty_tuple.type = tuple_access %a.ref, element6
// CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [concrete = constants.%int_6]
// CHECK:STDOUT: %.loc9_23.19: ref %empty_tuple.type = array_index file.%b.var, %int_6
// CHECK:STDOUT: %.loc9_23.20: init %empty_tuple.type = tuple_init () to %.loc9_23.19 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.21: init %empty_tuple.type = converted %tuple.elem6.loc9, %.loc9_23.20 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem7.loc9: ref %empty_tuple.type = tuple_access %a.ref, element7
// CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete = constants.%int_7]
// CHECK:STDOUT: %.loc9_23.22: ref %empty_tuple.type = array_index file.%b.var, %int_7
// CHECK:STDOUT: %.loc9_23.23: init %empty_tuple.type = tuple_init () to %.loc9_23.22 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.24: init %empty_tuple.type = converted %tuple.elem7.loc9, %.loc9_23.23 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %tuple.elem8.loc9: ref %empty_tuple.type = tuple_access %a.ref, element8
// CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete = constants.%int_8]
// CHECK:STDOUT: %.loc9_23.25: ref %empty_tuple.type = array_index file.%b.var, %int_8
// CHECK:STDOUT: %.loc9_23.26: init %empty_tuple.type = tuple_init () to %.loc9_23.25 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.27: init %empty_tuple.type = converted %tuple.elem8.loc9, %.loc9_23.26 [concrete = constants.%empty_tuple]
// CHECK:STDOUT: %.loc9_23.28: init %array_type = array_init (%.loc9_23.3, %.loc9_23.6, %.loc9_23.9, %.loc9_23.12, %.loc9_23.15, %.loc9_23.18, %.loc9_23.21, %.loc9_23.24, %.loc9_23.27) to file.%b.var [concrete = constants.%array]
// CHECK:STDOUT: %.loc9_1: init %array_type = converted %a.ref, %.loc9_23.28 [concrete = constants.%array]
// CHECK:STDOUT: assign file.%b.var, %.loc9_1
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -0,0 +1,70 @@
// 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/array/no_prelude/element_mismatches.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/no_prelude/element_mismatches.carbon
// --- fail_arg_wrong_type.carbon
library "[[@TEST_NAME]]";
class C {}
// CHECK:STDERR: fail_arg_wrong_type.carbon:[[@LINE+4]]:22: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
// CHECK:STDERR: var a: array(C, 3) = ({}, "Hello", "World");
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: array(C, 3) = ({}, "Hello", "World");
// --- fail_var_wrong_type.carbon
library "[[@TEST_NAME]]";
class C {}
class D {}
var a: (C, D, D);
// CHECK:STDERR: fail_var_wrong_type.carbon:[[@LINE+4]]:22: error: cannot copy value of type `C` [CopyOfUncopyableType]
// CHECK:STDERR: var b: array(C, 3) = a;
// CHECK:STDERR: ^
// CHECK:STDERR:
var b: array(C, 3) = a;
// --- fail_arg_too_short.carbon
library "[[@TEST_NAME]]";
class C {}
// CHECK:STDERR: fail_arg_too_short.carbon:[[@LINE+4]]:22: error: cannot initialize array of 3 elements from 2 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: var a: array(C, 3) = ({}, {});
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
var a: array(C, 3) = ({}, {});
// --- fail_var_too_short.carbon
library "[[@TEST_NAME]]";
class C {}
var a: (C, C);
// CHECK:STDERR: fail_var_too_short.carbon:[[@LINE+4]]:22: error: cannot initialize array of 3 elements from tuple with 2 elements [ArrayInitFromExprArgCountMismatch]
// CHECK:STDERR: var b: array(C, 3) = a;
// CHECK:STDERR: ^
// CHECK:STDERR:
var b: array(C, 3) = a;
// --- fail_arg_too_long.carbon
// CHECK:STDERR: fail_arg_too_long.carbon:[[@LINE+4]]:23: error: cannot initialize array of 1 element from 3 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: var a: array((), 1) = ((), (), ());
// CHECK:STDERR: ^~~~~~~~~~~~
// CHECK:STDERR:
var a: array((), 1) = ((), (), ());