| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857 |
- // 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/deduce/array.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/deduce/array.carbon
- // --- type_only.carbon
- library "[[@TEST_NAME]]";
- class C {}
- fn F[T:! type](a: [T; 3]) -> T { return a[0]; }
- fn G() -> C {
- var a: [C; 3] = ({}, {}, {});
- return F(a);
- }
- // --- fail_todo_bound_only.carbon
- library "[[@TEST_NAME]]";
- class C {}
- // CHECK:STDERR: fail_todo_bound_only.carbon:[[@LINE+4]]:22: error: semantics TODO: `symbolic array bound`
- // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; }
- // CHECK:STDERR: ^
- // CHECK:STDERR:
- fn F[N:! i32](a: [C; N]) -> i32 { return N; }
- fn G() -> C {
- var a: [C; 3] = ({}, {}, {});
- return F(a);
- }
- // --- fail_todo_type_and_bound.carbon
- library "[[@TEST_NAME]]";
- class C {}
- // CHECK:STDERR: fail_todo_type_and_bound.carbon:[[@LINE+4]]:32: error: semantics TODO: `symbolic array bound`
- // CHECK:STDERR: fn F[T:! type, N:! i32](a: [T; N]) -> T;
- // CHECK:STDERR: ^
- // CHECK:STDERR:
- fn F[T:! type, N:! i32](a: [T; N]) -> T;
- fn G() -> C {
- var a: [C; 3] = ({}, {}, {});
- return F(a);
- }
- // --- fail_bound_mismatch.carbon
- library "[[@TEST_NAME]]";
- class C {}
- fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
- fn G() -> C {
- // TODO: We succeed at deducing T here but fail to convert. Is this the right behavior?
- var a: [C; 3] = ({}, {}, {});
- // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+10]]:10: error: cannot implicitly convert from `[C; 3]` to `[C; 2]`
- // CHECK:STDERR: return F(a);
- // CHECK:STDERR: ^~
- // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+7]]:10: note: type `[C; 3]` does not implement interface `ImplicitAs`
- // CHECK:STDERR: return F(a);
- // CHECK:STDERR: ^~
- // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE-11]]:1: note: initializing parameter 1 of function declared here
- // CHECK:STDERR: fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
- // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // CHECK:STDERR:
- return F(a);
- }
- // --- fail_type_mismatch.carbon
- library "[[@TEST_NAME]]";
- class C {}
- class D {}
- // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:22: error: semantics TODO: `symbolic array bound`
- // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; }
- // CHECK:STDERR: ^
- fn F[N:! i32](a: [C; N]) -> i32 { return N; }
- fn G() -> C {
- var a: [D; 3] = ({}, {}, {});
- return F(a);
- }
- // CHECK:STDOUT: --- type_only.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
- // CHECK:STDOUT: %.3: i32 = int_literal 3 [template]
- // CHECK:STDOUT: %.4: type = array_type %.3, %T [symbolic]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %.5: type = tuple_type () [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %.6: type = ptr_type %.4 [symbolic]
- // CHECK:STDOUT: %.7: i32 = int_literal 0 [template]
- // CHECK:STDOUT: %G.type: type = fn_type @G [template]
- // CHECK:STDOUT: %G: %G.type = struct_value () [template]
- // CHECK:STDOUT: %.8: type = ptr_type %.1 [template]
- // CHECK:STDOUT: %.9: type = array_type %.3, %C [template]
- // CHECK:STDOUT: %.10: type = ptr_type %.9 [template]
- // CHECK:STDOUT: %.11: type = tuple_type (%.1, %.1, %.1) [template]
- // CHECK:STDOUT: %struct: %C = struct_value () [template]
- // CHECK:STDOUT: %.12: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %.13: i32 = int_literal 2 [template]
- // CHECK:STDOUT: %array: %.9 = tuple_value (%struct, %struct, %struct) [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .C = %C.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: .G = %G.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
- // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
- // CHECK:STDOUT: %a.patt: @F.%.loc6_24.2 (%.4) = binding_pattern a
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
- // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %.loc6_23: i32 = int_literal 3 [template = constants.%.3]
- // CHECK:STDOUT: %.loc6_24.1: type = array_type %.loc6_23, %T [symbolic = %.loc6_24.2 (constants.%.4)]
- // CHECK:STDOUT: %a.param: @F.%.loc6_24.2 (%.4) = param a, runtime_param0
- // CHECK:STDOUT: %a: @F.%.loc6_24.2 (%.4) = bind_name a, %a.param
- // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {
- // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %return: ref %C = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
- // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %.loc6_24.2: type = array_type constants.%.3, @F.%T.loc6_6.2 (%T) [symbolic = %.loc6_24.2 (constants.%.4)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%T.loc6_6.1: type](%a: @F.%.loc6_24.2 (%.4)) -> @F.%T.loc6_6.2 (%T) {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %a.ref: @F.%.loc6_24.2 (%.4) = name_ref a, %a
- // CHECK:STDOUT: %.loc6_43: i32 = int_literal 0 [template = constants.%.7]
- // CHECK:STDOUT: %.loc6_44.1: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref
- // CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43
- // CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2
- // CHECK:STDOUT: return %.loc6_44.3
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @G() -> %return: %C {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %C.ref.loc9: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %.loc9_14: i32 = int_literal 3 [template = constants.%.3]
- // CHECK:STDOUT: %.loc9_15: type = array_type %.loc9_14, %C [template = constants.%.9]
- // CHECK:STDOUT: %a.var: ref %.9 = var a
- // CHECK:STDOUT: %a: ref %.9 = bind_name a, %a.var
- // CHECK:STDOUT: %.loc9_21.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc9_25.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc9_29.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc9_30.1: %.11 = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1)
- // CHECK:STDOUT: %.loc9_30.2: i32 = int_literal 0 [template = constants.%.7]
- // CHECK:STDOUT: %.loc9_30.3: ref %C = array_index %a.var, %.loc9_30.2
- // CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.3 [template = constants.%struct]
- // CHECK:STDOUT: %.loc9_30.4: init %C = converted %.loc9_21.1, %.loc9_21.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc9_30.5: i32 = int_literal 1 [template = constants.%.12]
- // CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %.loc9_30.5
- // CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.6 [template = constants.%struct]
- // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc9_30.8: i32 = int_literal 2 [template = constants.%.13]
- // CHECK:STDOUT: %.loc9_30.9: ref %C = array_index %a.var, %.loc9_30.8
- // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.9 [template = constants.%struct]
- // CHECK:STDOUT: %.loc9_30.10: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc9_30.11: init %.9 = array_init (%.loc9_30.4, %.loc9_30.7, %.loc9_30.10) to %a.var [template = constants.%array]
- // CHECK:STDOUT: %.loc9_31: init %.9 = converted %.loc9_30.1, %.loc9_30.11 [template = constants.%array]
- // CHECK:STDOUT: assign %a.var, %.loc9_31
- // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
- // CHECK:STDOUT: %a.ref: ref %.9 = name_ref a, %a
- // CHECK:STDOUT: %.loc8: ref %C = splice_block %return {}
- // CHECK:STDOUT: %.loc10: %.9 = bind_value %a.ref
- // CHECK:STDOUT: %F.call: init %C = call %F.ref(%.loc10) to %.loc8
- // CHECK:STDOUT: return %F.call to %return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%T) {
- // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
- // CHECK:STDOUT: %.loc6_24.2 => constants.%.4
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%C) {
- // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
- // CHECK:STDOUT: %.loc6_24.2 => constants.%.9
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_todo_bound_only.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
- // CHECK:STDOUT: %.3: type = tuple_type () [template]
- // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
- // CHECK:STDOUT: %N: i32 = bind_symbolic_name N, 0 [symbolic]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %G.type: type = fn_type @G [template]
- // CHECK:STDOUT: %G: %G.type = struct_value () [template]
- // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
- // CHECK:STDOUT: %.5: i32 = int_literal 3 [template]
- // CHECK:STDOUT: %.6: type = array_type %.5, %C [template]
- // CHECK:STDOUT: %.7: type = ptr_type %.6 [template]
- // CHECK:STDOUT: %.8: type = tuple_type (%.1, %.1, %.1) [template]
- // CHECK:STDOUT: %.9: i32 = int_literal 0 [template]
- // CHECK:STDOUT: %struct: %C = struct_value () [template]
- // CHECK:STDOUT: %.10: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %.11: i32 = int_literal 2 [template]
- // CHECK:STDOUT: %array: %.6 = tuple_value (%struct, %struct, %struct) [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int32 = %import_ref
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .C = %C.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: .G = %G.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
- // CHECK:STDOUT: %N.patt: i32 = symbolic_binding_pattern N, 0
- // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %int.make_type_32.loc10_10: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc10_10.1: type = value_of_initializer %int.make_type_32.loc10_10 [template = i32]
- // CHECK:STDOUT: %.loc10_10.2: type = converted %int.make_type_32.loc10_10, %.loc10_10.1 [template = i32]
- // CHECK:STDOUT: %N.param: i32 = param N, runtime_param<invalid>
- // CHECK:STDOUT: %N.loc10_6.1: i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %N.ref.loc10_22: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT: %.loc10_23: type = array_type %N.ref.loc10_22, %C [template = <error>]
- // CHECK:STDOUT: %a.param: <error> = param a, runtime_param0
- // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
- // CHECK:STDOUT: %int.make_type_32.loc10_29: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc10_29.1: type = value_of_initializer %int.make_type_32.loc10_29 [template = i32]
- // CHECK:STDOUT: %.loc10_29.2: type = converted %int.make_type_32.loc10_29, %.loc10_29.1 [template = i32]
- // CHECK:STDOUT: %return: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {
- // CHECK:STDOUT: %C.ref.loc12: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %return: ref %C = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @F(%N.loc10_6.1: i32) {
- // CHECK:STDOUT: %N.loc10_6.2: i32 = bind_symbolic_name N, 0 [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%N.loc10_6.1: i32](%a: <error>) -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %N.ref.loc10_42: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT: return %N.ref.loc10_42
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @G() -> %return: %C {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %.loc13_14: i32 = int_literal 3 [template = constants.%.5]
- // CHECK:STDOUT: %.loc13_15: type = array_type %.loc13_14, %C [template = constants.%.6]
- // CHECK:STDOUT: %a.var: ref %.6 = var a
- // CHECK:STDOUT: %a: ref %.6 = bind_name a, %a.var
- // CHECK:STDOUT: %.loc13_21.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_25.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_29.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_30.1: %.8 = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
- // CHECK:STDOUT: %.loc13_30.2: i32 = int_literal 0 [template = constants.%.9]
- // CHECK:STDOUT: %.loc13_30.3: ref %C = array_index %a.var, %.loc13_30.2
- // CHECK:STDOUT: %.loc13_21.2: init %C = class_init (), %.loc13_30.3 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.4: init %C = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.5: i32 = int_literal 1 [template = constants.%.10]
- // CHECK:STDOUT: %.loc13_30.6: ref %C = array_index %a.var, %.loc13_30.5
- // CHECK:STDOUT: %.loc13_25.2: init %C = class_init (), %.loc13_30.6 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.7: init %C = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.8: i32 = int_literal 2 [template = constants.%.11]
- // CHECK:STDOUT: %.loc13_30.9: ref %C = array_index %a.var, %.loc13_30.8
- // CHECK:STDOUT: %.loc13_29.2: init %C = class_init (), %.loc13_30.9 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.10: init %C = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.11: init %.6 = array_init (%.loc13_30.4, %.loc13_30.7, %.loc13_30.10) to %a.var [template = constants.%array]
- // CHECK:STDOUT: %.loc13_31: init %.6 = converted %.loc13_30.1, %.loc13_30.11 [template = constants.%array]
- // CHECK:STDOUT: assign %a.var, %.loc13_31
- // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
- // CHECK:STDOUT: %a.ref: ref %.6 = name_ref a, %a
- // CHECK:STDOUT: return <error> to %return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%N) {
- // CHECK:STDOUT: %N.loc10_6.2 => constants.%N
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_todo_type_and_bound.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
- // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
- // CHECK:STDOUT: %.3: type = tuple_type () [template]
- // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
- // CHECK:STDOUT: %N: i32 = bind_symbolic_name N, 1 [symbolic]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %G.type: type = fn_type @G [template]
- // CHECK:STDOUT: %G: %G.type = struct_value () [template]
- // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
- // CHECK:STDOUT: %.5: i32 = int_literal 3 [template]
- // CHECK:STDOUT: %.6: type = array_type %.5, %C [template]
- // CHECK:STDOUT: %.7: type = ptr_type %.6 [template]
- // CHECK:STDOUT: %.8: type = tuple_type (%.1, %.1, %.1) [template]
- // CHECK:STDOUT: %.9: i32 = int_literal 0 [template]
- // CHECK:STDOUT: %struct: %C = struct_value () [template]
- // CHECK:STDOUT: %.10: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %.11: i32 = int_literal 2 [template]
- // CHECK:STDOUT: %array: %.6 = tuple_value (%struct, %struct, %struct) [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int32 = %import_ref
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .C = %C.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: .G = %G.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
- // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
- // CHECK:STDOUT: %N.patt: i32 = symbolic_binding_pattern N, 1
- // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
- // CHECK:STDOUT: %T.loc10_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc10_6.2 (constants.%T)]
- // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc10_20.1: type = value_of_initializer %int.make_type_32 [template = i32]
- // CHECK:STDOUT: %.loc10_20.2: type = converted %int.make_type_32, %.loc10_20.1 [template = i32]
- // CHECK:STDOUT: %N.param: i32 = param N, runtime_param<invalid>
- // CHECK:STDOUT: %N.loc10_16.1: i32 = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc10_16.2 (constants.%N)]
- // CHECK:STDOUT: %T.ref.loc10_29: type = name_ref T, %T.loc10_6.1 [symbolic = %T.loc10_6.2 (constants.%T)]
- // CHECK:STDOUT: %N.ref: i32 = name_ref N, %N.loc10_16.1 [symbolic = %N.loc10_16.2 (constants.%N)]
- // CHECK:STDOUT: %.loc10_33: type = array_type %N.ref, %T [template = <error>]
- // CHECK:STDOUT: %a.param: <error> = param a, runtime_param0
- // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
- // CHECK:STDOUT: %T.ref.loc10_39: type = name_ref T, %T.loc10_6.1 [symbolic = %T.loc10_6.2 (constants.%T)]
- // CHECK:STDOUT: %return: ref @F.%T.loc10_6.2 (%T) = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {
- // CHECK:STDOUT: %C.ref.loc12: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %return: ref %C = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @F(%T.loc10_6.1: type, %N.loc10_16.1: i32) {
- // CHECK:STDOUT: %T.loc10_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc10_6.2 (constants.%T)]
- // CHECK:STDOUT: %N.loc10_16.2: i32 = bind_symbolic_name N, 1 [symbolic = %N.loc10_16.2 (constants.%N)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%T.loc10_6.1: type, %N.loc10_16.1: i32](%a: <error>) -> @F.%T.loc10_6.2 (%T);
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @G() -> %return: %C {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %.loc13_14: i32 = int_literal 3 [template = constants.%.5]
- // CHECK:STDOUT: %.loc13_15: type = array_type %.loc13_14, %C [template = constants.%.6]
- // CHECK:STDOUT: %a.var: ref %.6 = var a
- // CHECK:STDOUT: %a: ref %.6 = bind_name a, %a.var
- // CHECK:STDOUT: %.loc13_21.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_25.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_29.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_30.1: %.8 = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
- // CHECK:STDOUT: %.loc13_30.2: i32 = int_literal 0 [template = constants.%.9]
- // CHECK:STDOUT: %.loc13_30.3: ref %C = array_index %a.var, %.loc13_30.2
- // CHECK:STDOUT: %.loc13_21.2: init %C = class_init (), %.loc13_30.3 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.4: init %C = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.5: i32 = int_literal 1 [template = constants.%.10]
- // CHECK:STDOUT: %.loc13_30.6: ref %C = array_index %a.var, %.loc13_30.5
- // CHECK:STDOUT: %.loc13_25.2: init %C = class_init (), %.loc13_30.6 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.7: init %C = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.8: i32 = int_literal 2 [template = constants.%.11]
- // CHECK:STDOUT: %.loc13_30.9: ref %C = array_index %a.var, %.loc13_30.8
- // CHECK:STDOUT: %.loc13_29.2: init %C = class_init (), %.loc13_30.9 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.10: init %C = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.11: init %.6 = array_init (%.loc13_30.4, %.loc13_30.7, %.loc13_30.10) to %a.var [template = constants.%array]
- // CHECK:STDOUT: %.loc13_31: init %.6 = converted %.loc13_30.1, %.loc13_30.11 [template = constants.%array]
- // CHECK:STDOUT: assign %a.var, %.loc13_31
- // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
- // CHECK:STDOUT: %a.ref: ref %.6 = name_ref a, %a
- // CHECK:STDOUT: return <error> to %return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%T, constants.%N) {
- // CHECK:STDOUT: %T.loc10_6.2 => constants.%T
- // CHECK:STDOUT: %N.loc10_16.2 => constants.%N
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_bound_mismatch.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
- // CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
- // CHECK:STDOUT: %.4: type = array_type %.3, %T [symbolic]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %.5: type = tuple_type () [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %.6: type = ptr_type %.4 [symbolic]
- // CHECK:STDOUT: %.7: i32 = int_literal 0 [template]
- // CHECK:STDOUT: %G.type: type = fn_type @G [template]
- // CHECK:STDOUT: %G: %G.type = struct_value () [template]
- // CHECK:STDOUT: %.8: type = ptr_type %.1 [template]
- // CHECK:STDOUT: %.9: i32 = int_literal 3 [template]
- // CHECK:STDOUT: %.10: type = array_type %.9, %C [template]
- // CHECK:STDOUT: %.11: type = ptr_type %.10 [template]
- // CHECK:STDOUT: %.12: type = tuple_type (%.1, %.1, %.1) [template]
- // CHECK:STDOUT: %struct: %C = struct_value () [template]
- // CHECK:STDOUT: %.13: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %array: %.10 = tuple_value (%struct, %struct, %struct) [template]
- // CHECK:STDOUT: %.14: type = array_type %.3, %C [template]
- // CHECK:STDOUT: %.15: type = ptr_type %.14 [template]
- // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
- // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
- // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
- // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
- // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
- // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
- // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
- // CHECK:STDOUT: %.16: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
- // CHECK:STDOUT: %.17: %.16 = assoc_entity element0, imports.%import_ref.5 [symbolic]
- // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%.14) [template]
- // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%.14) [template]
- // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
- // CHECK:STDOUT: %.18: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
- // CHECK:STDOUT: %.19: %.18 = assoc_entity element0, imports.%import_ref.5 [template]
- // CHECK:STDOUT: %.20: %.16 = assoc_entity element0, imports.%import_ref.6 [symbolic]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .ImplicitAs = %import_ref.1
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+40, loaded [template = constants.%ImplicitAs]
- // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+45, unloaded
- // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.16) = import_ref Core//prelude/operators/as, inst+63, loaded [symbolic = @ImplicitAs.%.2 (constants.%.20)]
- // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+56, unloaded
- // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+56, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+56, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .C = %C.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: .G = %G.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
- // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
- // CHECK:STDOUT: %a.patt: @F.%.loc6_24.2 (%.4) = binding_pattern a
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
- // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %.loc6_23: i32 = int_literal 2 [template = constants.%.3]
- // CHECK:STDOUT: %.loc6_24.1: type = array_type %.loc6_23, %T [symbolic = %.loc6_24.2 (constants.%.4)]
- // CHECK:STDOUT: %a.param: @F.%.loc6_24.2 (%.4) = param a, runtime_param0
- // CHECK:STDOUT: %a: @F.%.loc6_24.2 (%.4) = bind_name a, %a.param
- // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {
- // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %return: ref %C = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
- // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
- // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
- // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
- // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.16)]
- // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.16) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.17)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: interface {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = imports.%import_ref.2
- // CHECK:STDOUT: .Convert = imports.%import_ref.3
- // CHECK:STDOUT: witness = (imports.%import_ref.4)
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
- // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
- // CHECK:STDOUT: %.loc6_24.2: type = array_type constants.%.3, @F.%T.loc6_6.2 (%T) [symbolic = %.loc6_24.2 (constants.%.4)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%T.loc6_6.1: type](%a: @F.%.loc6_24.2 (%.4)) -> @F.%T.loc6_6.2 (%T) {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %a.ref: @F.%.loc6_24.2 (%.4) = name_ref a, %a
- // CHECK:STDOUT: %.loc6_43: i32 = int_literal 0 [template = constants.%.7]
- // CHECK:STDOUT: %.loc6_44.1: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref
- // CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43
- // CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2
- // CHECK:STDOUT: return %.loc6_44.3
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @G() -> %return: %C {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %C.ref.loc10: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %.loc10_14: i32 = int_literal 3 [template = constants.%.9]
- // CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, %C [template = constants.%.10]
- // CHECK:STDOUT: %a.var: ref %.10 = var a
- // CHECK:STDOUT: %a: ref %.10 = bind_name a, %a.var
- // CHECK:STDOUT: %.loc10_21.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc10_25.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc10_29.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc10_30.1: %.12 = tuple_literal (%.loc10_21.1, %.loc10_25.1, %.loc10_29.1)
- // CHECK:STDOUT: %.loc10_30.2: i32 = int_literal 0 [template = constants.%.7]
- // CHECK:STDOUT: %.loc10_30.3: ref %C = array_index %a.var, %.loc10_30.2
- // CHECK:STDOUT: %.loc10_21.2: init %C = class_init (), %.loc10_30.3 [template = constants.%struct]
- // CHECK:STDOUT: %.loc10_30.4: init %C = converted %.loc10_21.1, %.loc10_21.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc10_30.5: i32 = int_literal 1 [template = constants.%.13]
- // CHECK:STDOUT: %.loc10_30.6: ref %C = array_index %a.var, %.loc10_30.5
- // CHECK:STDOUT: %.loc10_25.2: init %C = class_init (), %.loc10_30.6 [template = constants.%struct]
- // CHECK:STDOUT: %.loc10_30.7: init %C = converted %.loc10_25.1, %.loc10_25.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc10_30.8: i32 = int_literal 2 [template = constants.%.3]
- // CHECK:STDOUT: %.loc10_30.9: ref %C = array_index %a.var, %.loc10_30.8
- // CHECK:STDOUT: %.loc10_29.2: init %C = class_init (), %.loc10_30.9 [template = constants.%struct]
- // CHECK:STDOUT: %.loc10_30.10: init %C = converted %.loc10_29.1, %.loc10_29.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc10_30.11: init %.10 = array_init (%.loc10_30.4, %.loc10_30.7, %.loc10_30.10) to %a.var [template = constants.%array]
- // CHECK:STDOUT: %.loc10_31: init %.10 = converted %.loc10_30.1, %.loc10_30.11 [template = constants.%array]
- // CHECK:STDOUT: assign %a.var, %.loc10_31
- // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
- // CHECK:STDOUT: %a.ref: ref %.10 = name_ref a, %a
- // CHECK:STDOUT: %.loc21_11.1: ref %C = temporary_storage
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%.14) [template = constants.%ImplicitAs.type.3]
- // CHECK:STDOUT: %.loc21_11.2: %.18 = specific_constant imports.%import_ref.3, @ImplicitAs(constants.%.14) [template = constants.%.19]
- // CHECK:STDOUT: %Convert.ref: %.18 = name_ref Convert, %.loc21_11.2 [template = constants.%.19]
- // CHECK:STDOUT: %.loc21_11.3: %.14 = converted %a.ref, <error> [template = <error>]
- // CHECK:STDOUT: %F.call: init %C = call %F.ref(<invalid>) [template = <error>]
- // CHECK:STDOUT: return %F.call to %return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
- // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
- // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%self: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%T) {
- // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
- // CHECK:STDOUT: %.loc6_24.2 => constants.%.4
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%C) {
- // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
- // CHECK:STDOUT: %.loc6_24.2 => constants.%.14
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
- // CHECK:STDOUT: %Self => constants.%Self.1
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(constants.%.14) {
- // CHECK:STDOUT: %Dest => constants.%.14
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
- // CHECK:STDOUT: %Self => constants.%Self.2
- // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
- // CHECK:STDOUT: %Convert => constants.%Convert.2
- // CHECK:STDOUT: %.1 => constants.%.18
- // CHECK:STDOUT: %.2 => constants.%.19
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_type_mismatch.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %C: type = class_type @C [template]
- // CHECK:STDOUT: %.1: type = struct_type {} [template]
- // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
- // CHECK:STDOUT: %D: type = class_type @D [template]
- // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
- // CHECK:STDOUT: %.3: type = tuple_type () [template]
- // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
- // CHECK:STDOUT: %N: i32 = bind_symbolic_name N, 0 [symbolic]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %G.type: type = fn_type @G [template]
- // CHECK:STDOUT: %G: %G.type = struct_value () [template]
- // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
- // CHECK:STDOUT: %.5: i32 = int_literal 3 [template]
- // CHECK:STDOUT: %.6: type = array_type %.5, %D [template]
- // CHECK:STDOUT: %.7: type = ptr_type %.6 [template]
- // CHECK:STDOUT: %.8: type = tuple_type (%.1, %.1, %.1) [template]
- // CHECK:STDOUT: %.9: i32 = int_literal 0 [template]
- // CHECK:STDOUT: %struct: %D = struct_value () [template]
- // CHECK:STDOUT: %.10: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %.11: i32 = int_literal 2 [template]
- // CHECK:STDOUT: %array: %.6 = tuple_value (%struct, %struct, %struct) [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int32 = %import_ref
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = imports.%Core
- // CHECK:STDOUT: .C = %C.decl
- // CHECK:STDOUT: .D = %D.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: .G = %G.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
- // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
- // CHECK:STDOUT: %N.patt: i32 = symbolic_binding_pattern N, 0
- // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %int.make_type_32.loc10_10: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc10_10.1: type = value_of_initializer %int.make_type_32.loc10_10 [template = i32]
- // CHECK:STDOUT: %.loc10_10.2: type = converted %int.make_type_32.loc10_10, %.loc10_10.1 [template = i32]
- // CHECK:STDOUT: %N.param: i32 = param N, runtime_param<invalid>
- // CHECK:STDOUT: %N.loc10_6.1: i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %N.ref.loc10_22: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT: %.loc10_23: type = array_type %N.ref.loc10_22, %C [template = <error>]
- // CHECK:STDOUT: %a.param: <error> = param a, runtime_param0
- // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
- // CHECK:STDOUT: %int.make_type_32.loc10_29: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc10_29.1: type = value_of_initializer %int.make_type_32.loc10_29 [template = i32]
- // CHECK:STDOUT: %.loc10_29.2: type = converted %int.make_type_32.loc10_29, %.loc10_29.1 [template = i32]
- // CHECK:STDOUT: %return: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {
- // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
- // CHECK:STDOUT: %return: ref %C = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @C {
- // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%C
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @D {
- // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%D
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic fn @F(%N.loc10_6.1: i32) {
- // CHECK:STDOUT: %N.loc10_6.2: i32 = bind_symbolic_name N, 0 [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%N.loc10_6.1: i32](%a: <error>) -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %N.ref.loc10_42: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
- // CHECK:STDOUT: return %N.ref.loc10_42
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @G() -> %return: %C {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
- // CHECK:STDOUT: %.loc13_14: i32 = int_literal 3 [template = constants.%.5]
- // CHECK:STDOUT: %.loc13_15: type = array_type %.loc13_14, %D [template = constants.%.6]
- // CHECK:STDOUT: %a.var: ref %.6 = var a
- // CHECK:STDOUT: %a: ref %.6 = bind_name a, %a.var
- // CHECK:STDOUT: %.loc13_21.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_25.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_29.1: %.1 = struct_literal ()
- // CHECK:STDOUT: %.loc13_30.1: %.8 = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
- // CHECK:STDOUT: %.loc13_30.2: i32 = int_literal 0 [template = constants.%.9]
- // CHECK:STDOUT: %.loc13_30.3: ref %D = array_index %a.var, %.loc13_30.2
- // CHECK:STDOUT: %.loc13_21.2: init %D = class_init (), %.loc13_30.3 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.4: init %D = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.5: i32 = int_literal 1 [template = constants.%.10]
- // CHECK:STDOUT: %.loc13_30.6: ref %D = array_index %a.var, %.loc13_30.5
- // CHECK:STDOUT: %.loc13_25.2: init %D = class_init (), %.loc13_30.6 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.7: init %D = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.8: i32 = int_literal 2 [template = constants.%.11]
- // CHECK:STDOUT: %.loc13_30.9: ref %D = array_index %a.var, %.loc13_30.8
- // CHECK:STDOUT: %.loc13_29.2: init %D = class_init (), %.loc13_30.9 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.10: init %D = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%struct]
- // CHECK:STDOUT: %.loc13_30.11: init %.6 = array_init (%.loc13_30.4, %.loc13_30.7, %.loc13_30.10) to %a.var [template = constants.%array]
- // CHECK:STDOUT: %.loc13_31: init %.6 = converted %.loc13_30.1, %.loc13_30.11 [template = constants.%array]
- // CHECK:STDOUT: assign %a.var, %.loc13_31
- // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
- // CHECK:STDOUT: %a.ref: ref %.6 = name_ref a, %a
- // CHECK:STDOUT: return <error> to %return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F(constants.%N) {
- // CHECK:STDOUT: %N.loc10_6.2 => constants.%N
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|