array.carbon 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/deduce/array.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/deduce/array.carbon
  10. // --- type_only.carbon
  11. library "[[@TEST_NAME]]";
  12. class C {}
  13. fn F[T:! type](a: [T; 3]) -> T { return a[0]; }
  14. fn G() -> C {
  15. var a: [C; 3] = ({}, {}, {});
  16. return F(a);
  17. }
  18. // --- fail_todo_bound_only.carbon
  19. library "[[@TEST_NAME]]";
  20. class C {}
  21. // CHECK:STDERR: fail_todo_bound_only.carbon:[[@LINE+4]]:22: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
  22. // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  23. // CHECK:STDERR: ^
  24. // CHECK:STDERR:
  25. fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  26. fn G() -> C {
  27. var a: [C; 3] = ({}, {}, {});
  28. return F(a);
  29. }
  30. // --- fail_todo_type_and_bound.carbon
  31. library "[[@TEST_NAME]]";
  32. class C {}
  33. // CHECK:STDERR: fail_todo_type_and_bound.carbon:[[@LINE+4]]:32: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
  34. // CHECK:STDERR: fn F[T:! type, N:! i32](a: [T; N]) -> T;
  35. // CHECK:STDERR: ^
  36. // CHECK:STDERR:
  37. fn F[T:! type, N:! i32](a: [T; N]) -> T;
  38. fn G() -> C {
  39. var a: [C; 3] = ({}, {}, {});
  40. return F(a);
  41. }
  42. // --- fail_bound_mismatch.carbon
  43. library "[[@TEST_NAME]]";
  44. class C {}
  45. fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
  46. fn G() -> C {
  47. // TODO: We succeed at deducing T here but fail to convert. Is this the right behavior?
  48. var a: [C; 3] = ({}, {}, {});
  49. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+10]]:12: error: cannot implicitly convert from `[C; 3]` to `[C; 2]` [ImplicitAsConversionFailure]
  50. // CHECK:STDERR: return F(a);
  51. // CHECK:STDERR: ^
  52. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+7]]:12: note: type `[C; 3]` does not implement interface `ImplicitAs([C; 2])` [MissingImplInMemberAccessNote]
  53. // CHECK:STDERR: return F(a);
  54. // CHECK:STDERR: ^
  55. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE-11]]:16: note: initializing function parameter [InCallToFunctionParam]
  56. // CHECK:STDERR: fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
  57. // CHECK:STDERR: ^~~~~~~~~
  58. // CHECK:STDERR:
  59. return F(a);
  60. }
  61. // --- fail_type_mismatch.carbon
  62. library "[[@TEST_NAME]]";
  63. class C {}
  64. class D {}
  65. // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:22: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
  66. // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  67. // CHECK:STDERR: ^
  68. fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  69. fn G() -> C {
  70. var a: [D; 3] = ({}, {}, {});
  71. return F(a);
  72. }
  73. // CHECK:STDOUT: --- type_only.carbon
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: constants {
  76. // CHECK:STDOUT: %C: type = class_type @C [template]
  77. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  78. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  79. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  80. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  81. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  82. // CHECK:STDOUT: %array_type.1: type = array_type %int_3, %T [symbolic]
  83. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  84. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  85. // CHECK:STDOUT: %int_0.1: Core.IntLiteral = int_value 0 [template]
  86. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  87. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  88. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  89. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  90. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  91. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  92. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  93. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  94. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.1, %Convert.14 [template]
  95. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  96. // CHECK:STDOUT: %int_0.2: %i32 = int_value 0 [template]
  97. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  98. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  99. // CHECK:STDOUT: %array_type.2: type = array_type %int_3, %C [template]
  100. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  101. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  102. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  103. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  104. // CHECK:STDOUT: %array: %array_type.2 = tuple_value (%C.val, %C.val, %C.val) [template]
  105. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%C) [template]
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: imports {
  109. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  110. // CHECK:STDOUT: .Int = %import_ref.1
  111. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  112. // CHECK:STDOUT: import Core//prelude
  113. // CHECK:STDOUT: import Core//prelude/...
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: file {
  118. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  119. // CHECK:STDOUT: .Core = imports.%Core
  120. // CHECK:STDOUT: .C = %C.decl
  121. // CHECK:STDOUT: .F = %F.decl
  122. // CHECK:STDOUT: .G = %G.decl
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %Core.import = import Core
  125. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  126. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  127. // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  128. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param<invalid> [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  129. // CHECK:STDOUT: %a.patt: @F.%array_type.loc6_24.2 (%array_type.1) = binding_pattern a
  130. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_24.2 (%array_type.1) = value_param_pattern %a.patt, runtime_param0
  131. // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern
  132. // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  133. // CHECK:STDOUT: } {
  134. // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  135. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  136. // CHECK:STDOUT: %array_type.loc6_24.1: type = array_type %int_3, %T [symbolic = %array_type.loc6_24.2 (constants.%array_type.1)]
  137. // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  138. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  139. // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
  140. // CHECK:STDOUT: %a.param: @F.%array_type.loc6_24.2 (%array_type.1) = value_param runtime_param0
  141. // CHECK:STDOUT: %a: @F.%array_type.loc6_24.2 (%array_type.1) = bind_name a, %a.param
  142. // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1
  143. // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  146. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  147. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  148. // CHECK:STDOUT: } {
  149. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
  150. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  151. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: class @C {
  156. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !members:
  159. // CHECK:STDOUT: .Self = constants.%C
  160. // CHECK:STDOUT: complete_type_witness = %complete_type
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
  164. // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
  165. // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  166. // CHECK:STDOUT: %array_type.loc6_24.2: type = array_type constants.%int_3, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_24.2 (constants.%array_type.1)]
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: !definition:
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_24.2 (%array_type.1)) -> @F.%T.loc6_6.2 (%T) {
  171. // CHECK:STDOUT: !entry:
  172. // CHECK:STDOUT: %a.ref: @F.%array_type.loc6_24.2 (%array_type.1) = name_ref a, %a
  173. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  174. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  175. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32]
  176. // CHECK:STDOUT: %.loc6_44.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  177. // CHECK:STDOUT: %.loc6_44.2: type = converted %int.make_type_signed, %.loc6_44.1 [template = constants.%i32]
  178. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  179. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  180. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  181. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.2]
  182. // CHECK:STDOUT: %.loc6_43.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.2]
  183. // CHECK:STDOUT: %.loc6_43.2: %i32 = converted %int_0, %.loc6_43.1 [template = constants.%int_0.2]
  184. // CHECK:STDOUT: %.loc6_44.3: ref @F.%array_type.loc6_24.2 (%array_type.1) = value_as_ref %a.ref
  185. // CHECK:STDOUT: %.loc6_44.4: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.3, %.loc6_43.2
  186. // CHECK:STDOUT: %.loc6_44.5: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.4
  187. // CHECK:STDOUT: return %.loc6_44.5
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: fn @G() -> %return.param_patt: %C {
  192. // CHECK:STDOUT: !entry:
  193. // CHECK:STDOUT: %C.ref.loc9: type = name_ref C, file.%C.decl [template = constants.%C]
  194. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  195. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.2]
  196. // CHECK:STDOUT: %a.var: ref %array_type.2 = var a
  197. // CHECK:STDOUT: %a: ref %array_type.2 = bind_name a, %a.var
  198. // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal ()
  199. // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal ()
  200. // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal ()
  201. // CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1)
  202. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  203. // CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0
  204. // CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [template = constants.%C.val]
  205. // CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [template = constants.%C.val]
  206. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  207. // CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1
  208. // CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [template = constants.%C.val]
  209. // CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%C.val]
  210. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  211. // CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2
  212. // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val]
  213. // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val]
  214. // CHECK:STDOUT: %.loc9_30.8: init %array_type.2 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array]
  215. // CHECK:STDOUT: %.loc9_31: init %array_type.2 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array]
  216. // CHECK:STDOUT: assign %a.var, %.loc9_31
  217. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  218. // CHECK:STDOUT: %a.ref: ref %array_type.2 = name_ref a, %a
  219. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [template = constants.%F.specific_fn]
  220. // CHECK:STDOUT: %.loc8: ref %C = splice_block %return {}
  221. // CHECK:STDOUT: %.loc10: %array_type.2 = bind_value %a.ref
  222. // CHECK:STDOUT: %F.call: init %C = call %F.specific_fn(%.loc10) to %.loc8
  223. // CHECK:STDOUT: return %F.call to %return
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: specific @F(constants.%T) {
  227. // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
  228. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T
  229. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.1
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: specific @F(constants.%C) {
  233. // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
  234. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C
  235. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.2
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: !definition:
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: --- fail_todo_bound_only.carbon
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: constants {
  243. // CHECK:STDOUT: %C: type = class_type @C [template]
  244. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  245. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  246. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  247. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  248. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  249. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  250. // CHECK:STDOUT: %N.1: %i32 = bind_symbolic_name N, 0 [symbolic]
  251. // CHECK:STDOUT: %N.patt.1: %i32 = symbolic_binding_pattern N, 0 [symbolic]
  252. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
  253. // CHECK:STDOUT: %Convert.type.13: type = fn_type @Convert.4, @impl.3(%int_32) [template]
  254. // CHECK:STDOUT: %Convert.13: %Convert.type.13 = struct_value () [template]
  255. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.13) [template]
  256. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.1, %Convert.13 [symbolic]
  257. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.4(%int_32) [symbolic]
  258. // CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.1) [symbolic]
  259. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  260. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  261. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  262. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  263. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  264. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template]
  265. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  266. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  267. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  268. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  269. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  270. // CHECK:STDOUT: %array: %array_type = tuple_value (%C.val, %C.val, %C.val) [template]
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: imports {
  274. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  275. // CHECK:STDOUT: .Int = %import_ref.1
  276. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  277. // CHECK:STDOUT: import Core//prelude
  278. // CHECK:STDOUT: import Core//prelude/...
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: file {
  283. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  284. // CHECK:STDOUT: .Core = imports.%Core
  285. // CHECK:STDOUT: .C = %C.decl
  286. // CHECK:STDOUT: .F = %F.decl
  287. // CHECK:STDOUT: .G = %G.decl
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT: %Core.import = import Core
  290. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  291. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  292. // CHECK:STDOUT: %N.patt.loc10_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt.1)]
  293. // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc10_6.1, runtime_param<invalid> [symbolic = %N.patt.loc10_6.2 (constants.%N.patt.1)]
  294. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  295. // CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
  296. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  297. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  298. // CHECK:STDOUT: } {
  299. // CHECK:STDOUT: %int_32.loc10_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  300. // CHECK:STDOUT: %int.make_type_signed.loc10_10: init type = call constants.%Int(%int_32.loc10_10) [template = constants.%i32]
  301. // CHECK:STDOUT: %.loc10_10.1: type = value_of_initializer %int.make_type_signed.loc10_10 [template = constants.%i32]
  302. // CHECK:STDOUT: %.loc10_10.2: type = converted %int.make_type_signed.loc10_10, %.loc10_10.1 [template = constants.%i32]
  303. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  304. // CHECK:STDOUT: %N.ref.loc10_22: %i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N.1)]
  305. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.13]
  306. // CHECK:STDOUT: %Convert.bound.loc10_22.1: <bound method> = bound_method %N.ref.loc10_22, %impl.elem0 [symbolic = %Convert.bound.loc10_22.2 (constants.%Convert.bound)]
  307. // CHECK:STDOUT: %Convert.specific_fn.loc10_22.1: <specific function> = specific_function %Convert.bound.loc10_22.1, @Convert.4(constants.%int_32) [symbolic = %Convert.specific_fn.loc10_22.2 (constants.%Convert.specific_fn)]
  308. // CHECK:STDOUT: %int.convert_checked.loc10_22.1: init Core.IntLiteral = call %Convert.specific_fn.loc10_22.1(%N.ref.loc10_22) [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  309. // CHECK:STDOUT: %.loc10_22.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc10_22.1 [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  310. // CHECK:STDOUT: %.loc10_22.2: Core.IntLiteral = converted %N.ref.loc10_22, %.loc10_22.1 [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  311. // CHECK:STDOUT: %array_type: type = array_type %.loc10_22.2, %C [template = <error>]
  312. // CHECK:STDOUT: %int_32.loc10_29: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  313. // CHECK:STDOUT: %int.make_type_signed.loc10_29: init type = call constants.%Int(%int_32.loc10_29) [template = constants.%i32]
  314. // CHECK:STDOUT: %.loc10_29.1: type = value_of_initializer %int.make_type_signed.loc10_29 [template = constants.%i32]
  315. // CHECK:STDOUT: %.loc10_29.2: type = converted %int.make_type_signed.loc10_29, %.loc10_29.1 [template = constants.%i32]
  316. // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<invalid>
  317. // CHECK:STDOUT: %N.loc10_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc10_6.2 (constants.%N.1)]
  318. // CHECK:STDOUT: %a.param: <error> = value_param runtime_param0
  319. // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
  320. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  321. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  324. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  325. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  326. // CHECK:STDOUT: } {
  327. // CHECK:STDOUT: %C.ref.loc12: type = name_ref C, file.%C.decl [template = constants.%C]
  328. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  329. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: class @C {
  334. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: !members:
  337. // CHECK:STDOUT: .Self = constants.%C
  338. // CHECK:STDOUT: complete_type_witness = %complete_type
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: generic fn @F(%N.loc10_6.1: %i32) {
  342. // CHECK:STDOUT: %N.loc10_6.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc10_6.2 (constants.%N.1)]
  343. // CHECK:STDOUT: %N.patt.loc10_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt.1)]
  344. // CHECK:STDOUT: %Convert.bound.loc10_22.2: <bound method> = bound_method %N.loc10_6.2, constants.%Convert.13 [symbolic = %Convert.bound.loc10_22.2 (constants.%Convert.bound)]
  345. // CHECK:STDOUT: %Convert.specific_fn.loc10_22.2: <specific function> = specific_function %Convert.bound.loc10_22.2, @Convert.4(constants.%int_32) [symbolic = %Convert.specific_fn.loc10_22.2 (constants.%Convert.specific_fn)]
  346. // CHECK:STDOUT: %int.convert_checked.loc10_22.2: init Core.IntLiteral = call %Convert.specific_fn.loc10_22.2(%N.loc10_6.2) [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: !definition:
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: fn[%N.param_patt: %i32](%a.param_patt: <error>) -> %i32 {
  351. // CHECK:STDOUT: !entry:
  352. // CHECK:STDOUT: %N.ref.loc10_42: %i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N.1)]
  353. // CHECK:STDOUT: return %N.ref.loc10_42
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: fn @G() -> %return.param_patt: %C {
  358. // CHECK:STDOUT: !entry:
  359. // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, file.%C.decl [template = constants.%C]
  360. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  361. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type]
  362. // CHECK:STDOUT: %a.var: ref %array_type = var a
  363. // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
  364. // CHECK:STDOUT: %.loc13_21.1: %empty_struct_type = struct_literal ()
  365. // CHECK:STDOUT: %.loc13_25.1: %empty_struct_type = struct_literal ()
  366. // CHECK:STDOUT: %.loc13_29.1: %empty_struct_type = struct_literal ()
  367. // CHECK:STDOUT: %.loc13_30.1: %tuple.type = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
  368. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  369. // CHECK:STDOUT: %.loc13_30.2: ref %C = array_index %a.var, %int_0
  370. // CHECK:STDOUT: %.loc13_21.2: init %C = class_init (), %.loc13_30.2 [template = constants.%C.val]
  371. // CHECK:STDOUT: %.loc13_30.3: init %C = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%C.val]
  372. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  373. // CHECK:STDOUT: %.loc13_30.4: ref %C = array_index %a.var, %int_1
  374. // CHECK:STDOUT: %.loc13_25.2: init %C = class_init (), %.loc13_30.4 [template = constants.%C.val]
  375. // CHECK:STDOUT: %.loc13_30.5: init %C = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%C.val]
  376. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  377. // CHECK:STDOUT: %.loc13_30.6: ref %C = array_index %a.var, %int_2
  378. // CHECK:STDOUT: %.loc13_29.2: init %C = class_init (), %.loc13_30.6 [template = constants.%C.val]
  379. // CHECK:STDOUT: %.loc13_30.7: init %C = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%C.val]
  380. // CHECK:STDOUT: %.loc13_30.8: init %array_type = array_init (%.loc13_30.3, %.loc13_30.5, %.loc13_30.7) to %a.var [template = constants.%array]
  381. // CHECK:STDOUT: %.loc13_31: init %array_type = converted %.loc13_30.1, %.loc13_30.8 [template = constants.%array]
  382. // CHECK:STDOUT: assign %a.var, %.loc13_31
  383. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  384. // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, %a
  385. // CHECK:STDOUT: return <error> to %return
  386. // CHECK:STDOUT: }
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: specific @F(constants.%N.1) {
  389. // CHECK:STDOUT: %N.loc10_6.2 => constants.%N.1
  390. // CHECK:STDOUT: %N.patt.loc10_6.2 => constants.%N.1
  391. // CHECK:STDOUT: %Convert.bound.loc10_22.2 => constants.%Convert.bound
  392. // CHECK:STDOUT: %Convert.specific_fn.loc10_22.2 => constants.%Convert.specific_fn
  393. // CHECK:STDOUT: %int.convert_checked.loc10_22.2 => constants.%int.convert_checked
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: --- fail_todo_type_and_bound.carbon
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: constants {
  399. // CHECK:STDOUT: %C: type = class_type @C [template]
  400. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  401. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  402. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  403. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  404. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  405. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  406. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  407. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  408. // CHECK:STDOUT: %N.1: %i32 = bind_symbolic_name N, 1 [symbolic]
  409. // CHECK:STDOUT: %N.patt.1: %i32 = symbolic_binding_pattern N, 1 [symbolic]
  410. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
  411. // CHECK:STDOUT: %Convert.type.13: type = fn_type @Convert.4, @impl.3(%int_32) [template]
  412. // CHECK:STDOUT: %Convert.13: %Convert.type.13 = struct_value () [template]
  413. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.13) [template]
  414. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.1, %Convert.13 [symbolic]
  415. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.4(%int_32) [symbolic]
  416. // CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.1) [symbolic]
  417. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  418. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  419. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  420. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  421. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  422. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template]
  423. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  424. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  425. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  426. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  427. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  428. // CHECK:STDOUT: %array: %array_type = tuple_value (%C.val, %C.val, %C.val) [template]
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: imports {
  432. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  433. // CHECK:STDOUT: .Int = %import_ref.1
  434. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  435. // CHECK:STDOUT: import Core//prelude
  436. // CHECK:STDOUT: import Core//prelude/...
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: file {
  441. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  442. // CHECK:STDOUT: .Core = imports.%Core
  443. // CHECK:STDOUT: .C = %C.decl
  444. // CHECK:STDOUT: .F = %F.decl
  445. // CHECK:STDOUT: .G = %G.decl
  446. // CHECK:STDOUT: }
  447. // CHECK:STDOUT: %Core.import = import Core
  448. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  449. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  450. // CHECK:STDOUT: %T.patt.loc10_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc10_6.2 (constants.%T.patt)]
  451. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc10_6.1, runtime_param<invalid> [symbolic = %T.patt.loc10_6.2 (constants.%T.patt)]
  452. // CHECK:STDOUT: %N.patt.loc10_16.1: %i32 = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc10_16.2 (constants.%N.patt.1)]
  453. // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc10_16.1, runtime_param<invalid> [symbolic = %N.patt.loc10_16.2 (constants.%N.patt.1)]
  454. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  455. // CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
  456. // CHECK:STDOUT: %return.patt: @F.%T.loc10_6.2 (%T) = return_slot_pattern
  457. // CHECK:STDOUT: %return.param_patt: @F.%T.loc10_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  458. // CHECK:STDOUT: } {
  459. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  460. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32]
  461. // CHECK:STDOUT: %.loc10_20.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  462. // CHECK:STDOUT: %.loc10_20.2: type = converted %int.make_type_signed, %.loc10_20.1 [template = constants.%i32]
  463. // CHECK:STDOUT: %T.ref.loc10_29: type = name_ref T, %T.loc10_6.1 [symbolic = %T.loc10_6.2 (constants.%T)]
  464. // CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc10_16.1 [symbolic = %N.loc10_16.2 (constants.%N.1)]
  465. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.13]
  466. // CHECK:STDOUT: %Convert.bound.loc10_32.1: <bound method> = bound_method %N.ref, %impl.elem0 [symbolic = %Convert.bound.loc10_32.2 (constants.%Convert.bound)]
  467. // CHECK:STDOUT: %Convert.specific_fn.loc10_32.1: <specific function> = specific_function %Convert.bound.loc10_32.1, @Convert.4(constants.%int_32) [symbolic = %Convert.specific_fn.loc10_32.2 (constants.%Convert.specific_fn)]
  468. // CHECK:STDOUT: %int.convert_checked.loc10_32.1: init Core.IntLiteral = call %Convert.specific_fn.loc10_32.1(%N.ref) [symbolic = %int.convert_checked.loc10_32.2 (constants.%int.convert_checked)]
  469. // CHECK:STDOUT: %.loc10_32.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc10_32.1 [symbolic = %int.convert_checked.loc10_32.2 (constants.%int.convert_checked)]
  470. // CHECK:STDOUT: %.loc10_32.2: Core.IntLiteral = converted %N.ref, %.loc10_32.1 [symbolic = %int.convert_checked.loc10_32.2 (constants.%int.convert_checked)]
  471. // CHECK:STDOUT: %array_type: type = array_type %.loc10_32.2, %T [template = <error>]
  472. // CHECK:STDOUT: %T.ref.loc10_39: type = name_ref T, %T.loc10_6.1 [symbolic = %T.loc10_6.2 (constants.%T)]
  473. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  474. // CHECK:STDOUT: %T.loc10_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc10_6.2 (constants.%T)]
  475. // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<invalid>
  476. // CHECK:STDOUT: %N.loc10_16.1: %i32 = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc10_16.2 (constants.%N.1)]
  477. // CHECK:STDOUT: %a.param: <error> = value_param runtime_param0
  478. // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
  479. // CHECK:STDOUT: %return.param: ref @F.%T.loc10_6.2 (%T) = out_param runtime_param1
  480. // CHECK:STDOUT: %return: ref @F.%T.loc10_6.2 (%T) = return_slot %return.param
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  483. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  484. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  485. // CHECK:STDOUT: } {
  486. // CHECK:STDOUT: %C.ref.loc12: type = name_ref C, file.%C.decl [template = constants.%C]
  487. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  488. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT: }
  491. // CHECK:STDOUT:
  492. // CHECK:STDOUT: class @C {
  493. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: !members:
  496. // CHECK:STDOUT: .Self = constants.%C
  497. // CHECK:STDOUT: complete_type_witness = %complete_type
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: generic fn @F(%T.loc10_6.1: type, %N.loc10_16.1: %i32) {
  501. // CHECK:STDOUT: %T.loc10_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc10_6.2 (constants.%T)]
  502. // CHECK:STDOUT: %T.patt.loc10_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc10_6.2 (constants.%T.patt)]
  503. // CHECK:STDOUT: %N.loc10_16.2: %i32 = bind_symbolic_name N, 1 [symbolic = %N.loc10_16.2 (constants.%N.1)]
  504. // CHECK:STDOUT: %N.patt.loc10_16.2: %i32 = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc10_16.2 (constants.%N.patt.1)]
  505. // CHECK:STDOUT: %Convert.bound.loc10_32.2: <bound method> = bound_method %N.loc10_16.2, constants.%Convert.13 [symbolic = %Convert.bound.loc10_32.2 (constants.%Convert.bound)]
  506. // CHECK:STDOUT: %Convert.specific_fn.loc10_32.2: <specific function> = specific_function %Convert.bound.loc10_32.2, @Convert.4(constants.%int_32) [symbolic = %Convert.specific_fn.loc10_32.2 (constants.%Convert.specific_fn)]
  507. // CHECK:STDOUT: %int.convert_checked.loc10_32.2: init Core.IntLiteral = call %Convert.specific_fn.loc10_32.2(%N.loc10_16.2) [symbolic = %int.convert_checked.loc10_32.2 (constants.%int.convert_checked)]
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: fn[%T.param_patt: type, %N.param_patt: %i32](%a.param_patt: <error>) -> @F.%T.loc10_6.2 (%T);
  510. // CHECK:STDOUT: }
  511. // CHECK:STDOUT:
  512. // CHECK:STDOUT: fn @G() -> %return.param_patt: %C {
  513. // CHECK:STDOUT: !entry:
  514. // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, file.%C.decl [template = constants.%C]
  515. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  516. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type]
  517. // CHECK:STDOUT: %a.var: ref %array_type = var a
  518. // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
  519. // CHECK:STDOUT: %.loc13_21.1: %empty_struct_type = struct_literal ()
  520. // CHECK:STDOUT: %.loc13_25.1: %empty_struct_type = struct_literal ()
  521. // CHECK:STDOUT: %.loc13_29.1: %empty_struct_type = struct_literal ()
  522. // CHECK:STDOUT: %.loc13_30.1: %tuple.type = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
  523. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  524. // CHECK:STDOUT: %.loc13_30.2: ref %C = array_index %a.var, %int_0
  525. // CHECK:STDOUT: %.loc13_21.2: init %C = class_init (), %.loc13_30.2 [template = constants.%C.val]
  526. // CHECK:STDOUT: %.loc13_30.3: init %C = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%C.val]
  527. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  528. // CHECK:STDOUT: %.loc13_30.4: ref %C = array_index %a.var, %int_1
  529. // CHECK:STDOUT: %.loc13_25.2: init %C = class_init (), %.loc13_30.4 [template = constants.%C.val]
  530. // CHECK:STDOUT: %.loc13_30.5: init %C = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%C.val]
  531. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  532. // CHECK:STDOUT: %.loc13_30.6: ref %C = array_index %a.var, %int_2
  533. // CHECK:STDOUT: %.loc13_29.2: init %C = class_init (), %.loc13_30.6 [template = constants.%C.val]
  534. // CHECK:STDOUT: %.loc13_30.7: init %C = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%C.val]
  535. // CHECK:STDOUT: %.loc13_30.8: init %array_type = array_init (%.loc13_30.3, %.loc13_30.5, %.loc13_30.7) to %a.var [template = constants.%array]
  536. // CHECK:STDOUT: %.loc13_31: init %array_type = converted %.loc13_30.1, %.loc13_30.8 [template = constants.%array]
  537. // CHECK:STDOUT: assign %a.var, %.loc13_31
  538. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  539. // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, %a
  540. // CHECK:STDOUT: return <error> to %return
  541. // CHECK:STDOUT: }
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: specific @F(constants.%T, constants.%N.1) {
  544. // CHECK:STDOUT: %T.loc10_6.2 => constants.%T
  545. // CHECK:STDOUT: %T.patt.loc10_6.2 => constants.%T
  546. // CHECK:STDOUT: %N.loc10_16.2 => constants.%N.1
  547. // CHECK:STDOUT: %N.patt.loc10_16.2 => constants.%N.1
  548. // CHECK:STDOUT: %Convert.bound.loc10_32.2 => constants.%Convert.bound
  549. // CHECK:STDOUT: %Convert.specific_fn.loc10_32.2 => constants.%Convert.specific_fn
  550. // CHECK:STDOUT: %int.convert_checked.loc10_32.2 => constants.%int.convert_checked
  551. // CHECK:STDOUT: }
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: --- fail_bound_mismatch.carbon
  554. // CHECK:STDOUT:
  555. // CHECK:STDOUT: constants {
  556. // CHECK:STDOUT: %C: type = class_type @C [template]
  557. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  558. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  559. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  560. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  561. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  562. // CHECK:STDOUT: %array_type.1: type = array_type %int_2, %T [symbolic]
  563. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  564. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  565. // CHECK:STDOUT: %int_0.1: Core.IntLiteral = int_value 0 [template]
  566. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  567. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  568. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  569. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  570. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  571. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  572. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  573. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  574. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.1, %Convert.14 [template]
  575. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  576. // CHECK:STDOUT: %int_0.2: %i32 = int_value 0 [template]
  577. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  578. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  579. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  580. // CHECK:STDOUT: %array_type.2: type = array_type %int_3, %C [template]
  581. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  582. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  583. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  584. // CHECK:STDOUT: %array: %array_type.2 = tuple_value (%C.val, %C.val, %C.val) [template]
  585. // CHECK:STDOUT: %array_type.3: type = array_type %int_2, %C [template]
  586. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%C) [template]
  587. // CHECK:STDOUT: }
  588. // CHECK:STDOUT:
  589. // CHECK:STDOUT: imports {
  590. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  591. // CHECK:STDOUT: .Int = %import_ref.1
  592. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  593. // CHECK:STDOUT: import Core//prelude
  594. // CHECK:STDOUT: import Core//prelude/...
  595. // CHECK:STDOUT: }
  596. // CHECK:STDOUT: }
  597. // CHECK:STDOUT:
  598. // CHECK:STDOUT: file {
  599. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  600. // CHECK:STDOUT: .Core = imports.%Core
  601. // CHECK:STDOUT: .C = %C.decl
  602. // CHECK:STDOUT: .F = %F.decl
  603. // CHECK:STDOUT: .G = %G.decl
  604. // CHECK:STDOUT: }
  605. // CHECK:STDOUT: %Core.import = import Core
  606. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  607. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  608. // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  609. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param<invalid> [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  610. // CHECK:STDOUT: %a.patt: @F.%array_type.loc6_24.2 (%array_type.1) = binding_pattern a
  611. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_24.2 (%array_type.1) = value_param_pattern %a.patt, runtime_param0
  612. // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern
  613. // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  614. // CHECK:STDOUT: } {
  615. // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  616. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  617. // CHECK:STDOUT: %array_type.loc6_24.1: type = array_type %int_2, %T [symbolic = %array_type.loc6_24.2 (constants.%array_type.1)]
  618. // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  619. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  620. // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
  621. // CHECK:STDOUT: %a.param: @F.%array_type.loc6_24.2 (%array_type.1) = value_param runtime_param0
  622. // CHECK:STDOUT: %a: @F.%array_type.loc6_24.2 (%array_type.1) = bind_name a, %a.param
  623. // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1
  624. // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param
  625. // CHECK:STDOUT: }
  626. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  627. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  628. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  629. // CHECK:STDOUT: } {
  630. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
  631. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  632. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  633. // CHECK:STDOUT: }
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT:
  636. // CHECK:STDOUT: class @C {
  637. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  638. // CHECK:STDOUT:
  639. // CHECK:STDOUT: !members:
  640. // CHECK:STDOUT: .Self = constants.%C
  641. // CHECK:STDOUT: complete_type_witness = %complete_type
  642. // CHECK:STDOUT: }
  643. // CHECK:STDOUT:
  644. // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
  645. // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
  646. // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  647. // CHECK:STDOUT: %array_type.loc6_24.2: type = array_type constants.%int_2, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_24.2 (constants.%array_type.1)]
  648. // CHECK:STDOUT:
  649. // CHECK:STDOUT: !definition:
  650. // CHECK:STDOUT:
  651. // CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_24.2 (%array_type.1)) -> @F.%T.loc6_6.2 (%T) {
  652. // CHECK:STDOUT: !entry:
  653. // CHECK:STDOUT: %a.ref: @F.%array_type.loc6_24.2 (%array_type.1) = name_ref a, %a
  654. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  655. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  656. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32]
  657. // CHECK:STDOUT: %.loc6_44.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  658. // CHECK:STDOUT: %.loc6_44.2: type = converted %int.make_type_signed, %.loc6_44.1 [template = constants.%i32]
  659. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  660. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  661. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  662. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.2]
  663. // CHECK:STDOUT: %.loc6_43.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.2]
  664. // CHECK:STDOUT: %.loc6_43.2: %i32 = converted %int_0, %.loc6_43.1 [template = constants.%int_0.2]
  665. // CHECK:STDOUT: %.loc6_44.3: ref @F.%array_type.loc6_24.2 (%array_type.1) = value_as_ref %a.ref
  666. // CHECK:STDOUT: %.loc6_44.4: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.3, %.loc6_43.2
  667. // CHECK:STDOUT: %.loc6_44.5: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.4
  668. // CHECK:STDOUT: return %.loc6_44.5
  669. // CHECK:STDOUT: }
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT:
  672. // CHECK:STDOUT: fn @G() -> %return.param_patt: %C {
  673. // CHECK:STDOUT: !entry:
  674. // CHECK:STDOUT: %C.ref.loc10: type = name_ref C, file.%C.decl [template = constants.%C]
  675. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  676. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.2]
  677. // CHECK:STDOUT: %a.var: ref %array_type.2 = var a
  678. // CHECK:STDOUT: %a: ref %array_type.2 = bind_name a, %a.var
  679. // CHECK:STDOUT: %.loc10_21.1: %empty_struct_type = struct_literal ()
  680. // CHECK:STDOUT: %.loc10_25.1: %empty_struct_type = struct_literal ()
  681. // CHECK:STDOUT: %.loc10_29.1: %empty_struct_type = struct_literal ()
  682. // CHECK:STDOUT: %.loc10_30.1: %tuple.type = tuple_literal (%.loc10_21.1, %.loc10_25.1, %.loc10_29.1)
  683. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  684. // CHECK:STDOUT: %.loc10_30.2: ref %C = array_index %a.var, %int_0
  685. // CHECK:STDOUT: %.loc10_21.2: init %C = class_init (), %.loc10_30.2 [template = constants.%C.val]
  686. // CHECK:STDOUT: %.loc10_30.3: init %C = converted %.loc10_21.1, %.loc10_21.2 [template = constants.%C.val]
  687. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  688. // CHECK:STDOUT: %.loc10_30.4: ref %C = array_index %a.var, %int_1
  689. // CHECK:STDOUT: %.loc10_25.2: init %C = class_init (), %.loc10_30.4 [template = constants.%C.val]
  690. // CHECK:STDOUT: %.loc10_30.5: init %C = converted %.loc10_25.1, %.loc10_25.2 [template = constants.%C.val]
  691. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  692. // CHECK:STDOUT: %.loc10_30.6: ref %C = array_index %a.var, %int_2
  693. // CHECK:STDOUT: %.loc10_29.2: init %C = class_init (), %.loc10_30.6 [template = constants.%C.val]
  694. // CHECK:STDOUT: %.loc10_30.7: init %C = converted %.loc10_29.1, %.loc10_29.2 [template = constants.%C.val]
  695. // CHECK:STDOUT: %.loc10_30.8: init %array_type.2 = array_init (%.loc10_30.3, %.loc10_30.5, %.loc10_30.7) to %a.var [template = constants.%array]
  696. // CHECK:STDOUT: %.loc10_31: init %array_type.2 = converted %.loc10_30.1, %.loc10_30.8 [template = constants.%array]
  697. // CHECK:STDOUT: assign %a.var, %.loc10_31
  698. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  699. // CHECK:STDOUT: %a.ref: ref %array_type.2 = name_ref a, %a
  700. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [template = constants.%F.specific_fn]
  701. // CHECK:STDOUT: %.loc8: ref %C = splice_block %return {}
  702. // CHECK:STDOUT: %.loc21: %array_type.3 = converted %a.ref, <error> [template = <error>]
  703. // CHECK:STDOUT: %F.call: init %C = call %F.specific_fn(<error>) to %.loc8
  704. // CHECK:STDOUT: return %F.call to %return
  705. // CHECK:STDOUT: }
  706. // CHECK:STDOUT:
  707. // CHECK:STDOUT: specific @F(constants.%T) {
  708. // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
  709. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T
  710. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.1
  711. // CHECK:STDOUT: }
  712. // CHECK:STDOUT:
  713. // CHECK:STDOUT: specific @F(constants.%C) {
  714. // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
  715. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C
  716. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.3
  717. // CHECK:STDOUT:
  718. // CHECK:STDOUT: !definition:
  719. // CHECK:STDOUT: }
  720. // CHECK:STDOUT:
  721. // CHECK:STDOUT: --- fail_type_mismatch.carbon
  722. // CHECK:STDOUT:
  723. // CHECK:STDOUT: constants {
  724. // CHECK:STDOUT: %C: type = class_type @C [template]
  725. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  726. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  727. // CHECK:STDOUT: %D: type = class_type @D [template]
  728. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  729. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  730. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  731. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  732. // CHECK:STDOUT: %N.1: %i32 = bind_symbolic_name N, 0 [symbolic]
  733. // CHECK:STDOUT: %N.patt.1: %i32 = symbolic_binding_pattern N, 0 [symbolic]
  734. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
  735. // CHECK:STDOUT: %Convert.type.13: type = fn_type @Convert.4, @impl.3(%int_32) [template]
  736. // CHECK:STDOUT: %Convert.13: %Convert.type.13 = struct_value () [template]
  737. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.13) [template]
  738. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.1, %Convert.13 [symbolic]
  739. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.4(%int_32) [symbolic]
  740. // CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.1) [symbolic]
  741. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  742. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  743. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  744. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  745. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  746. // CHECK:STDOUT: %array_type: type = array_type %int_3, %D [template]
  747. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  748. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  749. // CHECK:STDOUT: %D.val: %D = struct_value () [template]
  750. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  751. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  752. // CHECK:STDOUT: %array: %array_type = tuple_value (%D.val, %D.val, %D.val) [template]
  753. // CHECK:STDOUT: }
  754. // CHECK:STDOUT:
  755. // CHECK:STDOUT: imports {
  756. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  757. // CHECK:STDOUT: .Int = %import_ref.1
  758. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  759. // CHECK:STDOUT: import Core//prelude
  760. // CHECK:STDOUT: import Core//prelude/...
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT: }
  763. // CHECK:STDOUT:
  764. // CHECK:STDOUT: file {
  765. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  766. // CHECK:STDOUT: .Core = imports.%Core
  767. // CHECK:STDOUT: .C = %C.decl
  768. // CHECK:STDOUT: .D = %D.decl
  769. // CHECK:STDOUT: .F = %F.decl
  770. // CHECK:STDOUT: .G = %G.decl
  771. // CHECK:STDOUT: }
  772. // CHECK:STDOUT: %Core.import = import Core
  773. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  774. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  775. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  776. // CHECK:STDOUT: %N.patt.loc10_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt.1)]
  777. // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc10_6.1, runtime_param<invalid> [symbolic = %N.patt.loc10_6.2 (constants.%N.patt.1)]
  778. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  779. // CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
  780. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  781. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  782. // CHECK:STDOUT: } {
  783. // CHECK:STDOUT: %int_32.loc10_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  784. // CHECK:STDOUT: %int.make_type_signed.loc10_10: init type = call constants.%Int(%int_32.loc10_10) [template = constants.%i32]
  785. // CHECK:STDOUT: %.loc10_10.1: type = value_of_initializer %int.make_type_signed.loc10_10 [template = constants.%i32]
  786. // CHECK:STDOUT: %.loc10_10.2: type = converted %int.make_type_signed.loc10_10, %.loc10_10.1 [template = constants.%i32]
  787. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  788. // CHECK:STDOUT: %N.ref.loc10_22: %i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N.1)]
  789. // CHECK:STDOUT: %impl.elem0: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.13]
  790. // CHECK:STDOUT: %Convert.bound.loc10_22.1: <bound method> = bound_method %N.ref.loc10_22, %impl.elem0 [symbolic = %Convert.bound.loc10_22.2 (constants.%Convert.bound)]
  791. // CHECK:STDOUT: %Convert.specific_fn.loc10_22.1: <specific function> = specific_function %Convert.bound.loc10_22.1, @Convert.4(constants.%int_32) [symbolic = %Convert.specific_fn.loc10_22.2 (constants.%Convert.specific_fn)]
  792. // CHECK:STDOUT: %int.convert_checked.loc10_22.1: init Core.IntLiteral = call %Convert.specific_fn.loc10_22.1(%N.ref.loc10_22) [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  793. // CHECK:STDOUT: %.loc10_22.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc10_22.1 [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  794. // CHECK:STDOUT: %.loc10_22.2: Core.IntLiteral = converted %N.ref.loc10_22, %.loc10_22.1 [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  795. // CHECK:STDOUT: %array_type: type = array_type %.loc10_22.2, %C [template = <error>]
  796. // CHECK:STDOUT: %int_32.loc10_29: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  797. // CHECK:STDOUT: %int.make_type_signed.loc10_29: init type = call constants.%Int(%int_32.loc10_29) [template = constants.%i32]
  798. // CHECK:STDOUT: %.loc10_29.1: type = value_of_initializer %int.make_type_signed.loc10_29 [template = constants.%i32]
  799. // CHECK:STDOUT: %.loc10_29.2: type = converted %int.make_type_signed.loc10_29, %.loc10_29.1 [template = constants.%i32]
  800. // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<invalid>
  801. // CHECK:STDOUT: %N.loc10_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc10_6.2 (constants.%N.1)]
  802. // CHECK:STDOUT: %a.param: <error> = value_param runtime_param0
  803. // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
  804. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  805. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  806. // CHECK:STDOUT: }
  807. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  808. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  809. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  810. // CHECK:STDOUT: } {
  811. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  812. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  813. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  814. // CHECK:STDOUT: }
  815. // CHECK:STDOUT: }
  816. // CHECK:STDOUT:
  817. // CHECK:STDOUT: class @C {
  818. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  819. // CHECK:STDOUT:
  820. // CHECK:STDOUT: !members:
  821. // CHECK:STDOUT: .Self = constants.%C
  822. // CHECK:STDOUT: complete_type_witness = %complete_type
  823. // CHECK:STDOUT: }
  824. // CHECK:STDOUT:
  825. // CHECK:STDOUT: class @D {
  826. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  827. // CHECK:STDOUT:
  828. // CHECK:STDOUT: !members:
  829. // CHECK:STDOUT: .Self = constants.%D
  830. // CHECK:STDOUT: complete_type_witness = %complete_type
  831. // CHECK:STDOUT: }
  832. // CHECK:STDOUT:
  833. // CHECK:STDOUT: generic fn @F(%N.loc10_6.1: %i32) {
  834. // CHECK:STDOUT: %N.loc10_6.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc10_6.2 (constants.%N.1)]
  835. // CHECK:STDOUT: %N.patt.loc10_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt.1)]
  836. // CHECK:STDOUT: %Convert.bound.loc10_22.2: <bound method> = bound_method %N.loc10_6.2, constants.%Convert.13 [symbolic = %Convert.bound.loc10_22.2 (constants.%Convert.bound)]
  837. // CHECK:STDOUT: %Convert.specific_fn.loc10_22.2: <specific function> = specific_function %Convert.bound.loc10_22.2, @Convert.4(constants.%int_32) [symbolic = %Convert.specific_fn.loc10_22.2 (constants.%Convert.specific_fn)]
  838. // CHECK:STDOUT: %int.convert_checked.loc10_22.2: init Core.IntLiteral = call %Convert.specific_fn.loc10_22.2(%N.loc10_6.2) [symbolic = %int.convert_checked.loc10_22.2 (constants.%int.convert_checked)]
  839. // CHECK:STDOUT:
  840. // CHECK:STDOUT: !definition:
  841. // CHECK:STDOUT:
  842. // CHECK:STDOUT: fn[%N.param_patt: %i32](%a.param_patt: <error>) -> %i32 {
  843. // CHECK:STDOUT: !entry:
  844. // CHECK:STDOUT: %N.ref.loc10_42: %i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N.1)]
  845. // CHECK:STDOUT: return %N.ref.loc10_42
  846. // CHECK:STDOUT: }
  847. // CHECK:STDOUT: }
  848. // CHECK:STDOUT:
  849. // CHECK:STDOUT: fn @G() -> %return.param_patt: %C {
  850. // CHECK:STDOUT: !entry:
  851. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  852. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  853. // CHECK:STDOUT: %array_type: type = array_type %int_3, %D [template = constants.%array_type]
  854. // CHECK:STDOUT: %a.var: ref %array_type = var a
  855. // CHECK:STDOUT: %a: ref %array_type = bind_name a, %a.var
  856. // CHECK:STDOUT: %.loc13_21.1: %empty_struct_type = struct_literal ()
  857. // CHECK:STDOUT: %.loc13_25.1: %empty_struct_type = struct_literal ()
  858. // CHECK:STDOUT: %.loc13_29.1: %empty_struct_type = struct_literal ()
  859. // CHECK:STDOUT: %.loc13_30.1: %tuple.type = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
  860. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  861. // CHECK:STDOUT: %.loc13_30.2: ref %D = array_index %a.var, %int_0
  862. // CHECK:STDOUT: %.loc13_21.2: init %D = class_init (), %.loc13_30.2 [template = constants.%D.val]
  863. // CHECK:STDOUT: %.loc13_30.3: init %D = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%D.val]
  864. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  865. // CHECK:STDOUT: %.loc13_30.4: ref %D = array_index %a.var, %int_1
  866. // CHECK:STDOUT: %.loc13_25.2: init %D = class_init (), %.loc13_30.4 [template = constants.%D.val]
  867. // CHECK:STDOUT: %.loc13_30.5: init %D = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%D.val]
  868. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  869. // CHECK:STDOUT: %.loc13_30.6: ref %D = array_index %a.var, %int_2
  870. // CHECK:STDOUT: %.loc13_29.2: init %D = class_init (), %.loc13_30.6 [template = constants.%D.val]
  871. // CHECK:STDOUT: %.loc13_30.7: init %D = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%D.val]
  872. // CHECK:STDOUT: %.loc13_30.8: init %array_type = array_init (%.loc13_30.3, %.loc13_30.5, %.loc13_30.7) to %a.var [template = constants.%array]
  873. // CHECK:STDOUT: %.loc13_31: init %array_type = converted %.loc13_30.1, %.loc13_30.8 [template = constants.%array]
  874. // CHECK:STDOUT: assign %a.var, %.loc13_31
  875. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  876. // CHECK:STDOUT: %a.ref: ref %array_type = name_ref a, %a
  877. // CHECK:STDOUT: return <error> to %return
  878. // CHECK:STDOUT: }
  879. // CHECK:STDOUT:
  880. // CHECK:STDOUT: specific @F(constants.%N.1) {
  881. // CHECK:STDOUT: %N.loc10_6.2 => constants.%N.1
  882. // CHECK:STDOUT: %N.patt.loc10_6.2 => constants.%N.1
  883. // CHECK:STDOUT: %Convert.bound.loc10_22.2 => constants.%Convert.bound
  884. // CHECK:STDOUT: %Convert.specific_fn.loc10_22.2 => constants.%Convert.specific_fn
  885. // CHECK:STDOUT: %int.convert_checked.loc10_22.2 => constants.%int.convert_checked
  886. // CHECK:STDOUT: }
  887. // CHECK:STDOUT: