basics.carbon 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/array/basics.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/basics.carbon
  12. // --- assign_var.carbon
  13. library "[[@TEST_NAME]]";
  14. var a: ((), (), ());
  15. //@dump-sem-ir-begin
  16. var b: array((), 3) = a;
  17. //@dump-sem-ir-end
  18. // --- assign_arity.carbon
  19. var a0: array((), 0) = ();
  20. var a1: array((), 1) = ((),);
  21. var a2: array((), 2) = ((), ());
  22. // --- array_in_place.carbon
  23. library "[[@TEST_NAME]]";
  24. class C {}
  25. fn F() -> (C, C, C);
  26. fn G() {
  27. //@dump-sem-ir-begin
  28. var v: array((C, C, C), 2) = (F(), F());
  29. //@dump-sem-ir-end
  30. }
  31. // --- array_vs_tuple.carbon
  32. library "[[@TEST_NAME]]";
  33. fn G() {
  34. // These should have two different constant values.
  35. //@dump-sem-ir-begin
  36. var a: array((), 3);
  37. var b: ((), (), ());
  38. //@dump-sem-ir-end
  39. }
  40. // --- assign_return_value.carbon
  41. library "[[@TEST_NAME]]";
  42. fn F() -> ((),) { return ((),); }
  43. fn Run() {
  44. //@dump-sem-ir-begin
  45. var t: array((), 1) = F();
  46. //@dump-sem-ir-end
  47. }
  48. // --- nine_elements.carbon
  49. library "[[@TEST_NAME]]";
  50. var a: ((), (), (), (), (), (), (), (), ()) =
  51. ((), (), (), (), (), (), (), (), ());
  52. // Regression test for APInt handling.
  53. //@dump-sem-ir-begin
  54. var b: array((), 9) = a;
  55. //@dump-sem-ir-end
  56. // --- fail_incomplete_element.carbon
  57. library "[[@TEST_NAME]]";
  58. class Incomplete;
  59. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+7]]:8: error: binding pattern has incomplete type `array(Incomplete, 1)` in name binding declaration [IncompleteTypeInBindingDecl]
  60. // CHECK:STDERR: var a: array(Incomplete, 1);
  61. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  62. // CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
  63. // CHECK:STDERR: class Incomplete;
  64. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  65. // CHECK:STDERR:
  66. var a: array(Incomplete, 1);
  67. var p: Incomplete* = &a[0];
  68. // --- fail_invalid_element.carbon
  69. library "[[@TEST_NAME]]";
  70. // CHECK:STDERR: fail_invalid_element.carbon:[[@LINE+7]]:14: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
  71. // CHECK:STDERR: var a: array(1, 1);
  72. // CHECK:STDERR: ^
  73. // CHECK:STDERR: fail_invalid_element.carbon:[[@LINE+4]]:14: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  74. // CHECK:STDERR: var a: array(1, 1);
  75. // CHECK:STDERR: ^
  76. // CHECK:STDERR:
  77. var a: array(1, 1);
  78. // CHECK:STDOUT: --- assign_var.carbon
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: constants {
  81. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  82. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
  83. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
  84. // CHECK:STDOUT: %array_type: type = array_type %int_3, %empty_tuple.type [concrete]
  85. // CHECK:STDOUT: %pattern_type.035: type = pattern_type %array_type [concrete]
  86. // CHECK:STDOUT: %tuple.elem0: ref %empty_tuple.type = tuple_access file.%a.var, element0 [concrete]
  87. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  88. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  89. // CHECK:STDOUT: %tuple.elem1: ref %empty_tuple.type = tuple_access file.%a.var, element1 [concrete]
  90. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  91. // CHECK:STDOUT: %tuple.elem2: ref %empty_tuple.type = tuple_access file.%a.var, element2 [concrete]
  92. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
  93. // CHECK:STDOUT: %array: %array_type = tuple_value (%empty_tuple, %empty_tuple, %empty_tuple) [concrete]
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: imports {
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: file {
  100. // CHECK:STDOUT: name_binding_decl {
  101. // CHECK:STDOUT: %b.patt: %pattern_type.035 = ref_binding_pattern b [concrete]
  102. // CHECK:STDOUT: %b.var_patt: %pattern_type.035 = var_pattern %b.patt [concrete]
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: %b.var: ref %array_type = var %b.var_patt [concrete]
  105. // CHECK:STDOUT: %.loc6_19: type = splice_block %array_type [concrete = constants.%array_type] {
  106. // CHECK:STDOUT: %.loc6_15.1: %empty_tuple.type = tuple_literal ()
  107. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
  108. // CHECK:STDOUT: %.loc6_15.2: type = converted %.loc6_15.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  109. // CHECK:STDOUT: %array_type: type = array_type %int_3, %.loc6_15.2 [concrete = constants.%array_type]
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: %b: ref %array_type = ref_binding b, %b.var [concrete = %b.var]
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: fn @__global_init() {
  115. // CHECK:STDOUT: !entry:
  116. // CHECK:STDOUT: %a.ref: ref %tuple.type = name_ref a, file.%a [concrete = file.%a.var]
  117. // CHECK:STDOUT: %tuple.elem0: ref %empty_tuple.type = tuple_access %a.ref, element0 [concrete = constants.%tuple.elem0]
  118. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  119. // CHECK:STDOUT: %.loc6_23.1: ref %empty_tuple.type = array_index file.%b.var, %int_0
  120. // CHECK:STDOUT: %.loc6_23.2: init %empty_tuple.type = tuple_init () to %.loc6_23.1 [concrete = constants.%empty_tuple]
  121. // CHECK:STDOUT: %.loc6_23.3: init %empty_tuple.type = converted %tuple.elem0, %.loc6_23.2 [concrete = constants.%empty_tuple]
  122. // CHECK:STDOUT: %tuple.elem1: ref %empty_tuple.type = tuple_access %a.ref, element1 [concrete = constants.%tuple.elem1]
  123. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  124. // CHECK:STDOUT: %.loc6_23.4: ref %empty_tuple.type = array_index file.%b.var, %int_1
  125. // CHECK:STDOUT: %.loc6_23.5: init %empty_tuple.type = tuple_init () to %.loc6_23.4 [concrete = constants.%empty_tuple]
  126. // CHECK:STDOUT: %.loc6_23.6: init %empty_tuple.type = converted %tuple.elem1, %.loc6_23.5 [concrete = constants.%empty_tuple]
  127. // CHECK:STDOUT: %tuple.elem2: ref %empty_tuple.type = tuple_access %a.ref, element2 [concrete = constants.%tuple.elem2]
  128. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
  129. // CHECK:STDOUT: %.loc6_23.7: ref %empty_tuple.type = array_index file.%b.var, %int_2
  130. // CHECK:STDOUT: %.loc6_23.8: init %empty_tuple.type = tuple_init () to %.loc6_23.7 [concrete = constants.%empty_tuple]
  131. // CHECK:STDOUT: %.loc6_23.9: init %empty_tuple.type = converted %tuple.elem2, %.loc6_23.8 [concrete = constants.%empty_tuple]
  132. // CHECK:STDOUT: %.loc6_23.10: init %array_type = array_init (%.loc6_23.3, %.loc6_23.6, %.loc6_23.9) to file.%b.var [concrete = constants.%array]
  133. // CHECK:STDOUT: %.loc6_1: init %array_type = converted %a.ref, %.loc6_23.10 [concrete = constants.%array]
  134. // CHECK:STDOUT: assign file.%b.var, %.loc6_1
  135. // CHECK:STDOUT: <elided>
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: --- array_in_place.carbon
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: constants {
  141. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  142. // CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
  143. // CHECK:STDOUT: %tuple.type.734: type = tuple_type (%C, %C, %C) [concrete]
  144. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  145. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  146. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  147. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
  148. // CHECK:STDOUT: %array_type: type = array_type %int_2, %tuple.type.734 [concrete]
  149. // CHECK:STDOUT: %ptr.c6b: type = ptr_type %array_type [concrete]
  150. // CHECK:STDOUT: %pattern_type.e0b: type = pattern_type %array_type [concrete]
  151. // CHECK:STDOUT: %tuple.type.14a: type = tuple_type (%tuple.type.734, %tuple.type.734) [concrete]
  152. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  153. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  154. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  155. // CHECK:STDOUT: %facet_value: %type_where = facet_value %array_type, () [concrete]
  156. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d84: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [concrete]
  157. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.e4e: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.d84 = struct_value () [concrete]
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: imports {
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: fn @G() {
  164. // CHECK:STDOUT: !entry:
  165. // CHECK:STDOUT: name_binding_decl {
  166. // CHECK:STDOUT: %v.patt: %pattern_type.e0b = ref_binding_pattern v [concrete]
  167. // CHECK:STDOUT: %v.var_patt: %pattern_type.e0b = var_pattern %v.patt [concrete]
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: %v.var: ref %array_type = var %v.var_patt
  170. // CHECK:STDOUT: %F.ref.loc10_33: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  171. // CHECK:STDOUT: %.loc10_41.1: ref %tuple.type.734 = splice_block %.loc10_41.6 {
  172. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  173. // CHECK:STDOUT: %.loc10_41.6: ref %tuple.type.734 = array_index %v.var, %int_0
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT: %F.call.loc10_35: init %tuple.type.734 = call %F.ref.loc10_33() to %.loc10_41.1
  176. // CHECK:STDOUT: %F.ref.loc10_38: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  177. // CHECK:STDOUT: %.loc10_41.2: ref %tuple.type.734 = splice_block %.loc10_41.5 {
  178. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  179. // CHECK:STDOUT: %.loc10_41.5: ref %tuple.type.734 = array_index %v.var, %int_1
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT: %F.call.loc10_40: init %tuple.type.734 = call %F.ref.loc10_38() to %.loc10_41.2
  182. // CHECK:STDOUT: %.loc10_41.3: %tuple.type.14a = tuple_literal (%F.call.loc10_35, %F.call.loc10_40)
  183. // CHECK:STDOUT: %.loc10_41.4: init %array_type = array_init (%F.call.loc10_35, %F.call.loc10_40) to %v.var
  184. // CHECK:STDOUT: %.loc10_3: init %array_type = converted %.loc10_41.3, %.loc10_41.4
  185. // CHECK:STDOUT: assign %v.var, %.loc10_3
  186. // CHECK:STDOUT: %.loc10_28: type = splice_block %array_type [concrete = constants.%array_type] {
  187. // CHECK:STDOUT: %C.ref.loc10_17: type = name_ref C, file.%C.decl [concrete = constants.%C]
  188. // CHECK:STDOUT: %C.ref.loc10_20: type = name_ref C, file.%C.decl [concrete = constants.%C]
  189. // CHECK:STDOUT: %C.ref.loc10_23: type = name_ref C, file.%C.decl [concrete = constants.%C]
  190. // CHECK:STDOUT: %.loc10_24.1: %tuple.type.ff9 = tuple_literal (%C.ref.loc10_17, %C.ref.loc10_20, %C.ref.loc10_23)
  191. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
  192. // CHECK:STDOUT: %.loc10_24.2: type = converted %.loc10_24.1, constants.%tuple.type.734 [concrete = constants.%tuple.type.734]
  193. // CHECK:STDOUT: %array_type: type = array_type %int_2, %.loc10_24.2 [concrete = constants.%array_type]
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT: %v: ref %array_type = ref_binding v, %v.var
  196. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %v.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.e4e
  197. // CHECK:STDOUT: <elided>
  198. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %v.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn
  199. // CHECK:STDOUT: %addr: %ptr.c6b = addr_of %v.var
  200. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  201. // CHECK:STDOUT: <elided>
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: --- array_vs_tuple.carbon
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: constants {
  207. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  208. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
  209. // CHECK:STDOUT: %array_type: type = array_type %int_3, %empty_tuple.type [concrete]
  210. // CHECK:STDOUT: %ptr.20b: type = ptr_type %array_type [concrete]
  211. // CHECK:STDOUT: %pattern_type.035: type = pattern_type %array_type [concrete]
  212. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
  213. // CHECK:STDOUT: %ptr.7fe: type = ptr_type %tuple.type [concrete]
  214. // CHECK:STDOUT: %pattern_type.8c1: type = pattern_type %tuple.type [concrete]
  215. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  216. // CHECK:STDOUT: %facet_value.c7f: %type_where = facet_value %tuple.type, () [concrete]
  217. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.f25: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.c7f) [concrete]
  218. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.69a: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.f25 = struct_value () [concrete]
  219. // CHECK:STDOUT: %facet_value.4cf: %type_where = facet_value %array_type, () [concrete]
  220. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.5ee: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.4cf) [concrete]
  221. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.012: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.5ee = struct_value () [concrete]
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: imports {
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: fn @G() {
  228. // CHECK:STDOUT: !entry:
  229. // CHECK:STDOUT: name_binding_decl {
  230. // CHECK:STDOUT: %a.patt: %pattern_type.035 = ref_binding_pattern a [concrete]
  231. // CHECK:STDOUT: %a.var_patt: %pattern_type.035 = var_pattern %a.patt [concrete]
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT: %a.var: ref %array_type = var %a.var_patt
  234. // CHECK:STDOUT: %.loc7_21: type = splice_block %array_type [concrete = constants.%array_type] {
  235. // CHECK:STDOUT: %.loc7_17.1: %empty_tuple.type = tuple_literal ()
  236. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
  237. // CHECK:STDOUT: %.loc7_17.2: type = converted %.loc7_17.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  238. // CHECK:STDOUT: %array_type: type = array_type %int_3, %.loc7_17.2 [concrete = constants.%array_type]
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT: %a: ref %array_type = ref_binding a, %a.var
  241. // CHECK:STDOUT: name_binding_decl {
  242. // CHECK:STDOUT: %b.patt: %pattern_type.8c1 = ref_binding_pattern b [concrete]
  243. // CHECK:STDOUT: %b.var_patt: %pattern_type.8c1 = var_pattern %b.patt [concrete]
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT: %b.var: ref %tuple.type = var %b.var_patt
  246. // CHECK:STDOUT: %.loc8_21.1: type = splice_block %.loc8_21.6 [concrete = constants.%tuple.type] {
  247. // CHECK:STDOUT: %.loc8_12: %empty_tuple.type = tuple_literal ()
  248. // CHECK:STDOUT: %.loc8_16: %empty_tuple.type = tuple_literal ()
  249. // CHECK:STDOUT: %.loc8_20: %empty_tuple.type = tuple_literal ()
  250. // CHECK:STDOUT: %.loc8_21.2: %tuple.type = tuple_literal (%.loc8_12, %.loc8_16, %.loc8_20)
  251. // CHECK:STDOUT: %.loc8_21.3: type = converted %.loc8_12, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  252. // CHECK:STDOUT: %.loc8_21.4: type = converted %.loc8_16, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  253. // CHECK:STDOUT: %.loc8_21.5: type = converted %.loc8_20, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  254. // CHECK:STDOUT: %.loc8_21.6: type = converted %.loc8_21.2, constants.%tuple.type [concrete = constants.%tuple.type]
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT: %b: ref %tuple.type = ref_binding b, %b.var
  257. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc8: <bound method> = bound_method %b.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.69a
  258. // CHECK:STDOUT: <elided>
  259. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %b.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.1
  260. // CHECK:STDOUT: %addr.loc8: %ptr.7fe = addr_of %b.var
  261. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc8: init %empty_tuple.type = call %bound_method.loc8(%addr.loc8)
  262. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc7: <bound method> = bound_method %a.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.012
  263. // CHECK:STDOUT: <elided>
  264. // CHECK:STDOUT: %bound_method.loc7: <bound method> = bound_method %a.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.2
  265. // CHECK:STDOUT: %addr.loc7: %ptr.20b = addr_of %a.var
  266. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc7: init %empty_tuple.type = call %bound_method.loc7(%addr.loc7)
  267. // CHECK:STDOUT: <elided>
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: --- assign_return_value.carbon
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: constants {
  273. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  274. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type) [concrete]
  275. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  276. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  277. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  278. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  279. // CHECK:STDOUT: %array_type: type = array_type %int_1, %empty_tuple.type [concrete]
  280. // CHECK:STDOUT: %ptr.b99: type = ptr_type %array_type [concrete]
  281. // CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %array_type [concrete]
  282. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  283. // CHECK:STDOUT: %array: %array_type = tuple_value (%empty_tuple) [concrete]
  284. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  285. // CHECK:STDOUT: %facet_value.132: %type_where = facet_value %tuple.type, () [concrete]
  286. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.892: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.132) [concrete]
  287. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.452: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.892 = struct_value () [concrete]
  288. // CHECK:STDOUT: %ptr.652: type = ptr_type %tuple.type [concrete]
  289. // CHECK:STDOUT: %facet_value.c1b: %type_where = facet_value %array_type, () [concrete]
  290. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.53f: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.c1b) [concrete]
  291. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.731: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.53f = struct_value () [concrete]
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: imports {
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: fn @Run() {
  298. // CHECK:STDOUT: !entry:
  299. // CHECK:STDOUT: name_binding_decl {
  300. // CHECK:STDOUT: %t.patt: %pattern_type.fe8 = ref_binding_pattern t [concrete]
  301. // CHECK:STDOUT: %t.var_patt: %pattern_type.fe8 = var_pattern %t.patt [concrete]
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %t.var: ref %array_type = var %t.var_patt
  304. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  305. // CHECK:STDOUT: %F.call: init %tuple.type = call %F.ref()
  306. // CHECK:STDOUT: %.loc8_27.1: ref %tuple.type = temporary_storage
  307. // CHECK:STDOUT: %.loc8_27.2: ref %tuple.type = temporary %.loc8_27.1, %F.call
  308. // CHECK:STDOUT: %tuple.elem0: ref %empty_tuple.type = tuple_access %.loc8_27.2, element0
  309. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  310. // CHECK:STDOUT: %.loc8_27.3: ref %empty_tuple.type = array_index %t.var, %int_0
  311. // CHECK:STDOUT: %.loc8_27.4: init %empty_tuple.type = tuple_init () to %.loc8_27.3 [concrete = constants.%empty_tuple]
  312. // CHECK:STDOUT: %.loc8_27.5: init %empty_tuple.type = converted %tuple.elem0, %.loc8_27.4 [concrete = constants.%empty_tuple]
  313. // CHECK:STDOUT: %.loc8_27.6: init %array_type = array_init (%.loc8_27.5) to %t.var [concrete = constants.%array]
  314. // CHECK:STDOUT: %.loc8_3: init %array_type = converted %F.call, %.loc8_27.6 [concrete = constants.%array]
  315. // CHECK:STDOUT: assign %t.var, %.loc8_3
  316. // CHECK:STDOUT: %.loc8_21: type = splice_block %array_type [concrete = constants.%array_type] {
  317. // CHECK:STDOUT: %.loc8_17.1: %empty_tuple.type = tuple_literal ()
  318. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  319. // CHECK:STDOUT: %.loc8_17.2: type = converted %.loc8_17.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  320. // CHECK:STDOUT: %array_type: type = array_type %int_1, %.loc8_17.2 [concrete = constants.%array_type]
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: %t: ref %array_type = ref_binding t, %t.var
  323. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc8_27: <bound method> = bound_method %.loc8_27.2, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.452
  324. // CHECK:STDOUT: <elided>
  325. // CHECK:STDOUT: %bound_method.loc8_27: <bound method> = bound_method %.loc8_27.2, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.1
  326. // CHECK:STDOUT: %addr.loc8_27: %ptr.652 = addr_of %.loc8_27.2
  327. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc8_27: init %empty_tuple.type = call %bound_method.loc8_27(%addr.loc8_27)
  328. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc8_3: <bound method> = bound_method %t.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.731
  329. // CHECK:STDOUT: <elided>
  330. // CHECK:STDOUT: %bound_method.loc8_3: <bound method> = bound_method %t.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.2
  331. // CHECK:STDOUT: %addr.loc8_3: %ptr.b99 = addr_of %t.var
  332. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc8_3: init %empty_tuple.type = call %bound_method.loc8_3(%addr.loc8_3)
  333. // CHECK:STDOUT: <elided>
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: --- nine_elements.carbon
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: constants {
  339. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  340. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
  341. // CHECK:STDOUT: %tuple.elem0: ref %empty_tuple.type = tuple_access file.%a.var, element0 [concrete]
  342. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  343. // CHECK:STDOUT: %tuple.elem1: ref %empty_tuple.type = tuple_access file.%a.var, element1 [concrete]
  344. // CHECK:STDOUT: %tuple.elem2: ref %empty_tuple.type = tuple_access file.%a.var, element2 [concrete]
  345. // CHECK:STDOUT: %tuple.elem3: ref %empty_tuple.type = tuple_access file.%a.var, element3 [concrete]
  346. // CHECK:STDOUT: %tuple.elem4: ref %empty_tuple.type = tuple_access file.%a.var, element4 [concrete]
  347. // CHECK:STDOUT: %tuple.elem5: ref %empty_tuple.type = tuple_access file.%a.var, element5 [concrete]
  348. // CHECK:STDOUT: %tuple.elem6: ref %empty_tuple.type = tuple_access file.%a.var, element6 [concrete]
  349. // CHECK:STDOUT: %tuple.elem7: ref %empty_tuple.type = tuple_access file.%a.var, element7 [concrete]
  350. // CHECK:STDOUT: %tuple.elem8: ref %empty_tuple.type = tuple_access file.%a.var, element8 [concrete]
  351. // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete]
  352. // CHECK:STDOUT: %array_type: type = array_type %int_9, %empty_tuple.type [concrete]
  353. // CHECK:STDOUT: %pattern_type.3db: type = pattern_type %array_type [concrete]
  354. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  355. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  356. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete]
  357. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete]
  358. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete]
  359. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete]
  360. // CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [concrete]
  361. // CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete]
  362. // CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete]
  363. // CHECK:STDOUT: %array: %array_type = tuple_value (%empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple, %empty_tuple) [concrete]
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: imports {
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT:
  369. // CHECK:STDOUT: file {
  370. // CHECK:STDOUT: name_binding_decl {
  371. // CHECK:STDOUT: %b.patt: %pattern_type.3db = ref_binding_pattern b [concrete]
  372. // CHECK:STDOUT: %b.var_patt: %pattern_type.3db = var_pattern %b.patt [concrete]
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT: %b.var: ref %array_type = var %b.var_patt [concrete]
  375. // CHECK:STDOUT: %.loc9_19: type = splice_block %array_type [concrete = constants.%array_type] {
  376. // CHECK:STDOUT: %.loc9_15.1: %empty_tuple.type = tuple_literal ()
  377. // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9]
  378. // CHECK:STDOUT: %.loc9_15.2: type = converted %.loc9_15.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  379. // CHECK:STDOUT: %array_type: type = array_type %int_9, %.loc9_15.2 [concrete = constants.%array_type]
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT: %b: ref %array_type = ref_binding b, %b.var [concrete = %b.var]
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: fn @__global_init() {
  385. // CHECK:STDOUT: !entry:
  386. // CHECK:STDOUT: <elided>
  387. // CHECK:STDOUT: %a.ref: ref %tuple.type = name_ref a, file.%a [concrete = file.%a.var]
  388. // CHECK:STDOUT: %tuple.elem0.loc9: ref %empty_tuple.type = tuple_access %a.ref, element0 [concrete = constants.%tuple.elem0]
  389. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  390. // CHECK:STDOUT: %.loc9_23.1: ref %empty_tuple.type = array_index file.%b.var, %int_0
  391. // CHECK:STDOUT: %.loc9_23.2: init %empty_tuple.type = tuple_init () to %.loc9_23.1 [concrete = constants.%empty_tuple]
  392. // CHECK:STDOUT: %.loc9_23.3: init %empty_tuple.type = converted %tuple.elem0.loc9, %.loc9_23.2 [concrete = constants.%empty_tuple]
  393. // CHECK:STDOUT: %tuple.elem1.loc9: ref %empty_tuple.type = tuple_access %a.ref, element1 [concrete = constants.%tuple.elem1]
  394. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  395. // CHECK:STDOUT: %.loc9_23.4: ref %empty_tuple.type = array_index file.%b.var, %int_1
  396. // CHECK:STDOUT: %.loc9_23.5: init %empty_tuple.type = tuple_init () to %.loc9_23.4 [concrete = constants.%empty_tuple]
  397. // CHECK:STDOUT: %.loc9_23.6: init %empty_tuple.type = converted %tuple.elem1.loc9, %.loc9_23.5 [concrete = constants.%empty_tuple]
  398. // CHECK:STDOUT: %tuple.elem2.loc9: ref %empty_tuple.type = tuple_access %a.ref, element2 [concrete = constants.%tuple.elem2]
  399. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2]
  400. // CHECK:STDOUT: %.loc9_23.7: ref %empty_tuple.type = array_index file.%b.var, %int_2
  401. // CHECK:STDOUT: %.loc9_23.8: init %empty_tuple.type = tuple_init () to %.loc9_23.7 [concrete = constants.%empty_tuple]
  402. // CHECK:STDOUT: %.loc9_23.9: init %empty_tuple.type = converted %tuple.elem2.loc9, %.loc9_23.8 [concrete = constants.%empty_tuple]
  403. // CHECK:STDOUT: %tuple.elem3.loc9: ref %empty_tuple.type = tuple_access %a.ref, element3 [concrete = constants.%tuple.elem3]
  404. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3]
  405. // CHECK:STDOUT: %.loc9_23.10: ref %empty_tuple.type = array_index file.%b.var, %int_3
  406. // CHECK:STDOUT: %.loc9_23.11: init %empty_tuple.type = tuple_init () to %.loc9_23.10 [concrete = constants.%empty_tuple]
  407. // CHECK:STDOUT: %.loc9_23.12: init %empty_tuple.type = converted %tuple.elem3.loc9, %.loc9_23.11 [concrete = constants.%empty_tuple]
  408. // CHECK:STDOUT: %tuple.elem4.loc9: ref %empty_tuple.type = tuple_access %a.ref, element4 [concrete = constants.%tuple.elem4]
  409. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4]
  410. // CHECK:STDOUT: %.loc9_23.13: ref %empty_tuple.type = array_index file.%b.var, %int_4
  411. // CHECK:STDOUT: %.loc9_23.14: init %empty_tuple.type = tuple_init () to %.loc9_23.13 [concrete = constants.%empty_tuple]
  412. // CHECK:STDOUT: %.loc9_23.15: init %empty_tuple.type = converted %tuple.elem4.loc9, %.loc9_23.14 [concrete = constants.%empty_tuple]
  413. // CHECK:STDOUT: %tuple.elem5.loc9: ref %empty_tuple.type = tuple_access %a.ref, element5 [concrete = constants.%tuple.elem5]
  414. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5]
  415. // CHECK:STDOUT: %.loc9_23.16: ref %empty_tuple.type = array_index file.%b.var, %int_5
  416. // CHECK:STDOUT: %.loc9_23.17: init %empty_tuple.type = tuple_init () to %.loc9_23.16 [concrete = constants.%empty_tuple]
  417. // CHECK:STDOUT: %.loc9_23.18: init %empty_tuple.type = converted %tuple.elem5.loc9, %.loc9_23.17 [concrete = constants.%empty_tuple]
  418. // CHECK:STDOUT: %tuple.elem6.loc9: ref %empty_tuple.type = tuple_access %a.ref, element6 [concrete = constants.%tuple.elem6]
  419. // CHECK:STDOUT: %int_6: Core.IntLiteral = int_value 6 [concrete = constants.%int_6]
  420. // CHECK:STDOUT: %.loc9_23.19: ref %empty_tuple.type = array_index file.%b.var, %int_6
  421. // CHECK:STDOUT: %.loc9_23.20: init %empty_tuple.type = tuple_init () to %.loc9_23.19 [concrete = constants.%empty_tuple]
  422. // CHECK:STDOUT: %.loc9_23.21: init %empty_tuple.type = converted %tuple.elem6.loc9, %.loc9_23.20 [concrete = constants.%empty_tuple]
  423. // CHECK:STDOUT: %tuple.elem7.loc9: ref %empty_tuple.type = tuple_access %a.ref, element7 [concrete = constants.%tuple.elem7]
  424. // CHECK:STDOUT: %int_7: Core.IntLiteral = int_value 7 [concrete = constants.%int_7]
  425. // CHECK:STDOUT: %.loc9_23.22: ref %empty_tuple.type = array_index file.%b.var, %int_7
  426. // CHECK:STDOUT: %.loc9_23.23: init %empty_tuple.type = tuple_init () to %.loc9_23.22 [concrete = constants.%empty_tuple]
  427. // CHECK:STDOUT: %.loc9_23.24: init %empty_tuple.type = converted %tuple.elem7.loc9, %.loc9_23.23 [concrete = constants.%empty_tuple]
  428. // CHECK:STDOUT: %tuple.elem8.loc9: ref %empty_tuple.type = tuple_access %a.ref, element8 [concrete = constants.%tuple.elem8]
  429. // CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete = constants.%int_8]
  430. // CHECK:STDOUT: %.loc9_23.25: ref %empty_tuple.type = array_index file.%b.var, %int_8
  431. // CHECK:STDOUT: %.loc9_23.26: init %empty_tuple.type = tuple_init () to %.loc9_23.25 [concrete = constants.%empty_tuple]
  432. // CHECK:STDOUT: %.loc9_23.27: init %empty_tuple.type = converted %tuple.elem8.loc9, %.loc9_23.26 [concrete = constants.%empty_tuple]
  433. // CHECK:STDOUT: %.loc9_23.28: init %array_type = array_init (%.loc9_23.3, %.loc9_23.6, %.loc9_23.9, %.loc9_23.12, %.loc9_23.15, %.loc9_23.18, %.loc9_23.21, %.loc9_23.24, %.loc9_23.27) to file.%b.var [concrete = constants.%array]
  434. // CHECK:STDOUT: %.loc9_1: init %array_type = converted %a.ref, %.loc9_23.28 [concrete = constants.%array]
  435. // CHECK:STDOUT: assign file.%b.var, %.loc9_1
  436. // CHECK:STDOUT: <elided>
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT: