tuple_pattern.carbon 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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/destroy.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/tuple/tuple_pattern.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/tuple_pattern.carbon
  12. // --- basic.carbon
  13. library "[[@TEST_NAME]]";
  14. fn F() {
  15. //@dump-sem-ir-begin
  16. let (x: {}, y: {}) = ({}, {});
  17. var (a: {}, b: {});
  18. var (c: {}, d: {}) = ({}, {});
  19. //@dump-sem-ir-end
  20. }
  21. // --- variable.carbon
  22. library "[[@TEST_NAME]]";
  23. fn F() {
  24. //@dump-sem-ir-begin
  25. var tuple: ({}, {}) = ({}, {});
  26. var (x: {}, y: {}) = tuple;
  27. //@dump-sem-ir-end
  28. }
  29. fn G() {
  30. //@dump-sem-ir-begin
  31. let tuple: ({}, {}) = ({}, {});
  32. var (x: {}, y: {}) = tuple;
  33. //@dump-sem-ir-end
  34. }
  35. fn MakeTuple() -> ({}, {});
  36. fn H() {
  37. //@dump-sem-ir-begin
  38. var (x: {}, y: {}) = MakeTuple();
  39. //@dump-sem-ir-end
  40. }
  41. // --- nested.carbon
  42. library "[[@TEST_NAME]]";
  43. fn F() {
  44. //@dump-sem-ir-begin
  45. let (x: {}, (y: {}, z: {})) = ({}, ({}, {}));
  46. //@dump-sem-ir-end
  47. }
  48. // --- package_scope.carbon
  49. library "[[@TEST_NAME]]";
  50. //@dump-sem-ir-begin
  51. let (x: {}, y: {}) = ({}, {});
  52. //@dump-sem-ir-end
  53. // --- fail_in_class.carbon
  54. library "[[@TEST_NAME]]";
  55. class C {
  56. // CHECK:STDERR: fail_in_class.carbon:[[@LINE+8]]:7: error: expected identifier in field declaration [ExpectedFieldIdentifier]
  57. // CHECK:STDERR: var (x: {}, y: {});
  58. // CHECK:STDERR: ^
  59. // CHECK:STDERR:
  60. // CHECK:STDERR: fail_in_class.carbon:[[@LINE+4]]:3: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  61. // CHECK:STDERR: var (x: {}, y: {});
  62. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  63. // CHECK:STDERR:
  64. var (x: {}, y: {});
  65. }
  66. // --- fail_initializer_mismatch.carbon
  67. library "[[@TEST_NAME]]";
  68. // CHECK:STDERR: fail_initializer_mismatch.carbon:[[@LINE+4]]:5: error: tuple pattern expects 2 elements, but tuple literal has 1 [TuplePatternSizeDoesntMatchLiteral]
  69. // CHECK:STDERR: let (x: {}, y: {}) = ({},);
  70. // CHECK:STDERR: ^~~~~~~~~~~~~~
  71. // CHECK:STDERR:
  72. let (x: {}, y: {}) = ({},);
  73. // CHECK:STDERR: fail_initializer_mismatch.carbon:[[@LINE+4]]:5: error: tuple pattern expects 2 elements, but tuple literal has 3 [TuplePatternSizeDoesntMatchLiteral]
  74. // CHECK:STDERR: let (a: {}, b: {}) = ({}, {}, {});
  75. // CHECK:STDERR: ^~~~~~~~~~~~~~
  76. // CHECK:STDERR:
  77. let (a: {}, b: {}) = ({}, {}, {});
  78. // CHECK:STDOUT: --- basic.carbon
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: constants {
  81. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  82. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  83. // CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
  84. // CHECK:STDOUT: %tuple.type.b6b: type = tuple_type (%empty_struct_type, %empty_struct_type) [concrete]
  85. // CHECK:STDOUT: %pattern_type.de4: type = pattern_type %tuple.type.b6b [concrete]
  86. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  87. // CHECK:STDOUT: %tuple: %tuple.type.b6b = tuple_value (%empty_struct, %empty_struct) [concrete]
  88. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.730: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%tuple.type.b6b) [concrete]
  89. // CHECK:STDOUT: %T.as.Destroy.impl.Op.b38: %T.as.Destroy.impl.Op.type.730 = struct_value () [concrete]
  90. // CHECK:STDOUT: %ptr.8fc: type = ptr_type %tuple.type.b6b [concrete]
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: imports {
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: fn @F() {
  97. // CHECK:STDOUT: !entry:
  98. // CHECK:STDOUT: name_binding_decl {
  99. // CHECK:STDOUT: %x.patt: %pattern_type.a96 = binding_pattern x [concrete]
  100. // CHECK:STDOUT: %y.patt: %pattern_type.a96 = binding_pattern y [concrete]
  101. // CHECK:STDOUT: %.loc6_20: %pattern_type.de4 = tuple_pattern (%x.patt, %y.patt) [concrete]
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %.loc6_26.1: %empty_struct_type = struct_literal ()
  104. // CHECK:STDOUT: %.loc6_30.1: %empty_struct_type = struct_literal ()
  105. // CHECK:STDOUT: %.loc6_31: %tuple.type.b6b = tuple_literal (%.loc6_26.1, %.loc6_30.1)
  106. // CHECK:STDOUT: %.loc6_12.1: type = splice_block %.loc6_12.3 [concrete = constants.%empty_struct_type] {
  107. // CHECK:STDOUT: %.loc6_12.2: %empty_struct_type = struct_literal ()
  108. // CHECK:STDOUT: %.loc6_12.3: type = converted %.loc6_12.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %empty_struct.loc6_26: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  111. // CHECK:STDOUT: %.loc6_26.2: %empty_struct_type = converted %.loc6_26.1, %empty_struct.loc6_26 [concrete = constants.%empty_struct]
  112. // CHECK:STDOUT: %x: %empty_struct_type = bind_name x, %.loc6_26.2
  113. // CHECK:STDOUT: %.loc6_19.1: type = splice_block %.loc6_19.3 [concrete = constants.%empty_struct_type] {
  114. // CHECK:STDOUT: %.loc6_19.2: %empty_struct_type = struct_literal ()
  115. // CHECK:STDOUT: %.loc6_19.3: type = converted %.loc6_19.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: %empty_struct.loc6_30: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  118. // CHECK:STDOUT: %.loc6_30.2: %empty_struct_type = converted %.loc6_30.1, %empty_struct.loc6_30 [concrete = constants.%empty_struct]
  119. // CHECK:STDOUT: %y: %empty_struct_type = bind_name y, %.loc6_30.2
  120. // CHECK:STDOUT: name_binding_decl {
  121. // CHECK:STDOUT: %a.patt: %pattern_type.a96 = binding_pattern a [concrete]
  122. // CHECK:STDOUT: %b.patt: %pattern_type.a96 = binding_pattern b [concrete]
  123. // CHECK:STDOUT: %.loc7_20: %pattern_type.de4 = tuple_pattern (%a.patt, %b.patt) [concrete]
  124. // CHECK:STDOUT: %.var_patt.loc7: %pattern_type.de4 = var_pattern %.loc7_20 [concrete]
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: %.var.loc7: ref %tuple.type.b6b = var %.var_patt.loc7
  127. // CHECK:STDOUT: %tuple.elem0.loc7: ref %empty_struct_type = tuple_access %.var.loc7, element0
  128. // CHECK:STDOUT: %tuple.elem1.loc7: ref %empty_struct_type = tuple_access %.var.loc7, element1
  129. // CHECK:STDOUT: %.loc7_12.1: type = splice_block %.loc7_12.3 [concrete = constants.%empty_struct_type] {
  130. // CHECK:STDOUT: %.loc7_12.2: %empty_struct_type = struct_literal ()
  131. // CHECK:STDOUT: %.loc7_12.3: type = converted %.loc7_12.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT: %a: ref %empty_struct_type = bind_name a, %tuple.elem0.loc7
  134. // CHECK:STDOUT: %.loc7_19.1: type = splice_block %.loc7_19.3 [concrete = constants.%empty_struct_type] {
  135. // CHECK:STDOUT: %.loc7_19.2: %empty_struct_type = struct_literal ()
  136. // CHECK:STDOUT: %.loc7_19.3: type = converted %.loc7_19.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: %b: ref %empty_struct_type = bind_name b, %tuple.elem1.loc7
  139. // CHECK:STDOUT: name_binding_decl {
  140. // CHECK:STDOUT: %c.patt: %pattern_type.a96 = binding_pattern c [concrete]
  141. // CHECK:STDOUT: %d.patt: %pattern_type.a96 = binding_pattern d [concrete]
  142. // CHECK:STDOUT: %.loc8_20: %pattern_type.de4 = tuple_pattern (%c.patt, %d.patt) [concrete]
  143. // CHECK:STDOUT: %.var_patt.loc8: %pattern_type.de4 = var_pattern %.loc8_20 [concrete]
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %.var.loc8: ref %tuple.type.b6b = var %.var_patt.loc8
  146. // CHECK:STDOUT: %.loc8_26.1: %empty_struct_type = struct_literal ()
  147. // CHECK:STDOUT: %.loc8_30.1: %empty_struct_type = struct_literal ()
  148. // CHECK:STDOUT: %.loc8_31.1: %tuple.type.b6b = tuple_literal (%.loc8_26.1, %.loc8_30.1)
  149. // CHECK:STDOUT: %tuple.elem0.loc8_31: ref %empty_struct_type = tuple_access %.var.loc8, element0
  150. // CHECK:STDOUT: %.loc8_26.2: init %empty_struct_type = struct_init () to %tuple.elem0.loc8_31 [concrete = constants.%empty_struct]
  151. // CHECK:STDOUT: %.loc8_31.2: init %empty_struct_type = converted %.loc8_26.1, %.loc8_26.2 [concrete = constants.%empty_struct]
  152. // CHECK:STDOUT: %tuple.elem1.loc8_31: ref %empty_struct_type = tuple_access %.var.loc8, element1
  153. // CHECK:STDOUT: %.loc8_30.2: init %empty_struct_type = struct_init () to %tuple.elem1.loc8_31 [concrete = constants.%empty_struct]
  154. // CHECK:STDOUT: %.loc8_31.3: init %empty_struct_type = converted %.loc8_30.1, %.loc8_30.2 [concrete = constants.%empty_struct]
  155. // CHECK:STDOUT: %.loc8_31.4: init %tuple.type.b6b = tuple_init (%.loc8_31.2, %.loc8_31.3) to %.var.loc8 [concrete = constants.%tuple]
  156. // CHECK:STDOUT: %.loc8_3: init %tuple.type.b6b = converted %.loc8_31.1, %.loc8_31.4 [concrete = constants.%tuple]
  157. // CHECK:STDOUT: assign %.var.loc8, %.loc8_3
  158. // CHECK:STDOUT: %tuple.elem0.loc8_3: ref %empty_struct_type = tuple_access %.var.loc8, element0
  159. // CHECK:STDOUT: %tuple.elem1.loc8_3: ref %empty_struct_type = tuple_access %.var.loc8, element1
  160. // CHECK:STDOUT: %.loc8_12.1: type = splice_block %.loc8_12.3 [concrete = constants.%empty_struct_type] {
  161. // CHECK:STDOUT: %.loc8_12.2: %empty_struct_type = struct_literal ()
  162. // CHECK:STDOUT: %.loc8_12.3: type = converted %.loc8_12.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT: %c: ref %empty_struct_type = bind_name c, %tuple.elem0.loc8_3
  165. // CHECK:STDOUT: %.loc8_19.1: type = splice_block %.loc8_19.3 [concrete = constants.%empty_struct_type] {
  166. // CHECK:STDOUT: %.loc8_19.2: %empty_struct_type = struct_literal ()
  167. // CHECK:STDOUT: %.loc8_19.3: type = converted %.loc8_19.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: %d: ref %empty_struct_type = bind_name d, %tuple.elem1.loc8_3
  170. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc8: <bound method> = bound_method %.var.loc8, constants.%T.as.Destroy.impl.Op.b38
  171. // CHECK:STDOUT: <elided>
  172. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %.var.loc8, %T.as.Destroy.impl.Op.specific_fn.1
  173. // CHECK:STDOUT: %addr.loc8: %ptr.8fc = addr_of %.var.loc8
  174. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc8: init %empty_tuple.type = call %bound_method.loc8(%addr.loc8)
  175. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc7: <bound method> = bound_method %.var.loc7, constants.%T.as.Destroy.impl.Op.b38
  176. // CHECK:STDOUT: <elided>
  177. // CHECK:STDOUT: %bound_method.loc7: <bound method> = bound_method %.var.loc7, %T.as.Destroy.impl.Op.specific_fn.2
  178. // CHECK:STDOUT: %addr.loc7: %ptr.8fc = addr_of %.var.loc7
  179. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc7: init %empty_tuple.type = call %bound_method.loc7(%addr.loc7)
  180. // CHECK:STDOUT: <elided>
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: --- variable.carbon
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: constants {
  186. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  187. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  188. // CHECK:STDOUT: %tuple.type.b6b: type = tuple_type (%empty_struct_type, %empty_struct_type) [concrete]
  189. // CHECK:STDOUT: %pattern_type.de4: type = pattern_type %tuple.type.b6b [concrete]
  190. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  191. // CHECK:STDOUT: %tuple: %tuple.type.b6b = tuple_value (%empty_struct, %empty_struct) [concrete]
  192. // CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
  193. // CHECK:STDOUT: %T.as.Destroy.impl.Op.type.730: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%tuple.type.b6b) [concrete]
  194. // CHECK:STDOUT: %T.as.Destroy.impl.Op.b38: %T.as.Destroy.impl.Op.type.730 = struct_value () [concrete]
  195. // CHECK:STDOUT: %ptr.8fc: type = ptr_type %tuple.type.b6b [concrete]
  196. // CHECK:STDOUT: %MakeTuple.type: type = fn_type @MakeTuple [concrete]
  197. // CHECK:STDOUT: %MakeTuple: %MakeTuple.type = struct_value () [concrete]
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: imports {
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: fn @F() {
  204. // CHECK:STDOUT: !entry:
  205. // CHECK:STDOUT: name_binding_decl {
  206. // CHECK:STDOUT: %tuple.patt: %pattern_type.de4 = binding_pattern tuple [concrete]
  207. // CHECK:STDOUT: %tuple.var_patt: %pattern_type.de4 = var_pattern %tuple.patt [concrete]
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: %tuple.var: ref %tuple.type.b6b = var %tuple.var_patt
  210. // CHECK:STDOUT: %.loc6_27.1: %empty_struct_type = struct_literal ()
  211. // CHECK:STDOUT: %.loc6_31.1: %empty_struct_type = struct_literal ()
  212. // CHECK:STDOUT: %.loc6_32.1: %tuple.type.b6b = tuple_literal (%.loc6_27.1, %.loc6_31.1)
  213. // CHECK:STDOUT: %tuple.elem0.loc6: ref %empty_struct_type = tuple_access %tuple.var, element0
  214. // CHECK:STDOUT: %.loc6_27.2: init %empty_struct_type = struct_init () to %tuple.elem0.loc6 [concrete = constants.%empty_struct]
  215. // CHECK:STDOUT: %.loc6_32.2: init %empty_struct_type = converted %.loc6_27.1, %.loc6_27.2 [concrete = constants.%empty_struct]
  216. // CHECK:STDOUT: %tuple.elem1.loc6: ref %empty_struct_type = tuple_access %tuple.var, element1
  217. // CHECK:STDOUT: %.loc6_31.2: init %empty_struct_type = struct_init () to %tuple.elem1.loc6 [concrete = constants.%empty_struct]
  218. // CHECK:STDOUT: %.loc6_32.3: init %empty_struct_type = converted %.loc6_31.1, %.loc6_31.2 [concrete = constants.%empty_struct]
  219. // CHECK:STDOUT: %.loc6_32.4: init %tuple.type.b6b = tuple_init (%.loc6_32.2, %.loc6_32.3) to %tuple.var [concrete = constants.%tuple]
  220. // CHECK:STDOUT: %.loc6_3: init %tuple.type.b6b = converted %.loc6_32.1, %.loc6_32.4 [concrete = constants.%tuple]
  221. // CHECK:STDOUT: assign %tuple.var, %.loc6_3
  222. // CHECK:STDOUT: %.loc6_21.1: type = splice_block %.loc6_21.5 [concrete = constants.%tuple.type.b6b] {
  223. // CHECK:STDOUT: %.loc6_16: %empty_struct_type = struct_literal ()
  224. // CHECK:STDOUT: %.loc6_20: %empty_struct_type = struct_literal ()
  225. // CHECK:STDOUT: %.loc6_21.2: %tuple.type.b6b = tuple_literal (%.loc6_16, %.loc6_20)
  226. // CHECK:STDOUT: %.loc6_21.3: type = converted %.loc6_16, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  227. // CHECK:STDOUT: %.loc6_21.4: type = converted %.loc6_20, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  228. // CHECK:STDOUT: %.loc6_21.5: type = converted %.loc6_21.2, constants.%tuple.type.b6b [concrete = constants.%tuple.type.b6b]
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %tuple: ref %tuple.type.b6b = bind_name tuple, %tuple.var
  231. // CHECK:STDOUT: name_binding_decl {
  232. // CHECK:STDOUT: %x.patt: %pattern_type.a96 = binding_pattern x [concrete]
  233. // CHECK:STDOUT: %y.patt: %pattern_type.a96 = binding_pattern y [concrete]
  234. // CHECK:STDOUT: %.loc7_20: %pattern_type.de4 = tuple_pattern (%x.patt, %y.patt) [concrete]
  235. // CHECK:STDOUT: %.var_patt: %pattern_type.de4 = var_pattern %.loc7_20 [concrete]
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT: %.var: ref %tuple.type.b6b = var %.var_patt
  238. // CHECK:STDOUT: %tuple.ref: ref %tuple.type.b6b = name_ref tuple, %tuple
  239. // CHECK:STDOUT: %tuple.elem0.loc7_24.1: ref %empty_struct_type = tuple_access %tuple.ref, element0
  240. // CHECK:STDOUT: %tuple.elem0.loc7_24.2: ref %empty_struct_type = tuple_access %.var, element0
  241. // CHECK:STDOUT: %.loc7_24.1: init %empty_struct_type = struct_init () to %tuple.elem0.loc7_24.2 [concrete = constants.%empty_struct]
  242. // CHECK:STDOUT: %.loc7_24.2: init %empty_struct_type = converted %tuple.elem0.loc7_24.1, %.loc7_24.1 [concrete = constants.%empty_struct]
  243. // CHECK:STDOUT: %tuple.elem1.loc7_24.1: ref %empty_struct_type = tuple_access %tuple.ref, element1
  244. // CHECK:STDOUT: %tuple.elem1.loc7_24.2: ref %empty_struct_type = tuple_access %.var, element1
  245. // CHECK:STDOUT: %.loc7_24.3: init %empty_struct_type = struct_init () to %tuple.elem1.loc7_24.2 [concrete = constants.%empty_struct]
  246. // CHECK:STDOUT: %.loc7_24.4: init %empty_struct_type = converted %tuple.elem1.loc7_24.1, %.loc7_24.3 [concrete = constants.%empty_struct]
  247. // CHECK:STDOUT: %.loc7_24.5: init %tuple.type.b6b = tuple_init (%.loc7_24.2, %.loc7_24.4) to %.var [concrete = constants.%tuple]
  248. // CHECK:STDOUT: %.loc7_3: init %tuple.type.b6b = converted %tuple.ref, %.loc7_24.5 [concrete = constants.%tuple]
  249. // CHECK:STDOUT: assign %.var, %.loc7_3
  250. // CHECK:STDOUT: %tuple.elem0.loc7_3: ref %empty_struct_type = tuple_access %.var, element0
  251. // CHECK:STDOUT: %tuple.elem1.loc7_3: ref %empty_struct_type = tuple_access %.var, element1
  252. // CHECK:STDOUT: %.loc7_12.1: type = splice_block %.loc7_12.3 [concrete = constants.%empty_struct_type] {
  253. // CHECK:STDOUT: %.loc7_12.2: %empty_struct_type = struct_literal ()
  254. // CHECK:STDOUT: %.loc7_12.3: type = converted %.loc7_12.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %tuple.elem0.loc7_3
  257. // CHECK:STDOUT: %.loc7_19.1: type = splice_block %.loc7_19.3 [concrete = constants.%empty_struct_type] {
  258. // CHECK:STDOUT: %.loc7_19.2: %empty_struct_type = struct_literal ()
  259. // CHECK:STDOUT: %.loc7_19.3: type = converted %.loc7_19.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT: %y: ref %empty_struct_type = bind_name y, %tuple.elem1.loc7_3
  262. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc7: <bound method> = bound_method %.var, constants.%T.as.Destroy.impl.Op.b38
  263. // CHECK:STDOUT: <elided>
  264. // CHECK:STDOUT: %bound_method.loc7: <bound method> = bound_method %.var, %T.as.Destroy.impl.Op.specific_fn.1
  265. // CHECK:STDOUT: %addr.loc7: %ptr.8fc = addr_of %.var
  266. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc7: init %empty_tuple.type = call %bound_method.loc7(%addr.loc7)
  267. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound.loc6: <bound method> = bound_method %tuple.var, constants.%T.as.Destroy.impl.Op.b38
  268. // CHECK:STDOUT: <elided>
  269. // CHECK:STDOUT: %bound_method.loc6: <bound method> = bound_method %tuple.var, %T.as.Destroy.impl.Op.specific_fn.2
  270. // CHECK:STDOUT: %addr.loc6: %ptr.8fc = addr_of %tuple.var
  271. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call.loc6: init %empty_tuple.type = call %bound_method.loc6(%addr.loc6)
  272. // CHECK:STDOUT: <elided>
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: fn @G() {
  276. // CHECK:STDOUT: !entry:
  277. // CHECK:STDOUT: name_binding_decl {
  278. // CHECK:STDOUT: %tuple.patt: %pattern_type.de4 = binding_pattern tuple [concrete]
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT: %.loc13_27: %empty_struct_type = struct_literal ()
  281. // CHECK:STDOUT: %.loc13_31: %empty_struct_type = struct_literal ()
  282. // CHECK:STDOUT: %.loc13_32.1: %tuple.type.b6b = tuple_literal (%.loc13_27, %.loc13_31)
  283. // CHECK:STDOUT: %.loc13_21.1: type = splice_block %.loc13_21.5 [concrete = constants.%tuple.type.b6b] {
  284. // CHECK:STDOUT: %.loc13_16: %empty_struct_type = struct_literal ()
  285. // CHECK:STDOUT: %.loc13_20: %empty_struct_type = struct_literal ()
  286. // CHECK:STDOUT: %.loc13_21.2: %tuple.type.b6b = tuple_literal (%.loc13_16, %.loc13_20)
  287. // CHECK:STDOUT: %.loc13_21.3: type = converted %.loc13_16, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  288. // CHECK:STDOUT: %.loc13_21.4: type = converted %.loc13_20, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  289. // CHECK:STDOUT: %.loc13_21.5: type = converted %.loc13_21.2, constants.%tuple.type.b6b [concrete = constants.%tuple.type.b6b]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT: %empty_struct.loc13_27: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  292. // CHECK:STDOUT: %.loc13_32.2: %empty_struct_type = converted %.loc13_27, %empty_struct.loc13_27 [concrete = constants.%empty_struct]
  293. // CHECK:STDOUT: %empty_struct.loc13_31: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  294. // CHECK:STDOUT: %.loc13_32.3: %empty_struct_type = converted %.loc13_31, %empty_struct.loc13_31 [concrete = constants.%empty_struct]
  295. // CHECK:STDOUT: %tuple.loc13_32: %tuple.type.b6b = tuple_value (%.loc13_32.2, %.loc13_32.3) [concrete = constants.%tuple]
  296. // CHECK:STDOUT: %.loc13_32.4: %tuple.type.b6b = converted %.loc13_32.1, %tuple.loc13_32 [concrete = constants.%tuple]
  297. // CHECK:STDOUT: %tuple.loc13_7: %tuple.type.b6b = bind_name tuple, %.loc13_32.4
  298. // CHECK:STDOUT: name_binding_decl {
  299. // CHECK:STDOUT: %x.patt: %pattern_type.a96 = binding_pattern x [concrete]
  300. // CHECK:STDOUT: %y.patt: %pattern_type.a96 = binding_pattern y [concrete]
  301. // CHECK:STDOUT: %.loc14_20: %pattern_type.de4 = tuple_pattern (%x.patt, %y.patt) [concrete]
  302. // CHECK:STDOUT: %.var_patt: %pattern_type.de4 = var_pattern %.loc14_20 [concrete]
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT: %.var: ref %tuple.type.b6b = var %.var_patt
  305. // CHECK:STDOUT: %tuple.ref: %tuple.type.b6b = name_ref tuple, %tuple.loc13_7
  306. // CHECK:STDOUT: %tuple.elem0.loc14_24.1: %empty_struct_type = tuple_access %tuple.ref, element0
  307. // CHECK:STDOUT: %tuple.elem0.loc14_24.2: ref %empty_struct_type = tuple_access %.var, element0
  308. // CHECK:STDOUT: %.loc14_24.1: init %empty_struct_type = struct_init () to %tuple.elem0.loc14_24.2 [concrete = constants.%empty_struct]
  309. // CHECK:STDOUT: %.loc14_24.2: init %empty_struct_type = converted %tuple.elem0.loc14_24.1, %.loc14_24.1 [concrete = constants.%empty_struct]
  310. // CHECK:STDOUT: %tuple.elem1.loc14_24.1: %empty_struct_type = tuple_access %tuple.ref, element1
  311. // CHECK:STDOUT: %tuple.elem1.loc14_24.2: ref %empty_struct_type = tuple_access %.var, element1
  312. // CHECK:STDOUT: %.loc14_24.3: init %empty_struct_type = struct_init () to %tuple.elem1.loc14_24.2 [concrete = constants.%empty_struct]
  313. // CHECK:STDOUT: %.loc14_24.4: init %empty_struct_type = converted %tuple.elem1.loc14_24.1, %.loc14_24.3 [concrete = constants.%empty_struct]
  314. // CHECK:STDOUT: %.loc14_24.5: init %tuple.type.b6b = tuple_init (%.loc14_24.2, %.loc14_24.4) to %.var [concrete = constants.%tuple]
  315. // CHECK:STDOUT: %.loc14_3: init %tuple.type.b6b = converted %tuple.ref, %.loc14_24.5 [concrete = constants.%tuple]
  316. // CHECK:STDOUT: assign %.var, %.loc14_3
  317. // CHECK:STDOUT: %tuple.elem0.loc14_3: ref %empty_struct_type = tuple_access %.var, element0
  318. // CHECK:STDOUT: %tuple.elem1.loc14_3: ref %empty_struct_type = tuple_access %.var, element1
  319. // CHECK:STDOUT: %.loc14_12.1: type = splice_block %.loc14_12.3 [concrete = constants.%empty_struct_type] {
  320. // CHECK:STDOUT: %.loc14_12.2: %empty_struct_type = struct_literal ()
  321. // CHECK:STDOUT: %.loc14_12.3: type = converted %.loc14_12.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %tuple.elem0.loc14_3
  324. // CHECK:STDOUT: %.loc14_19.1: type = splice_block %.loc14_19.3 [concrete = constants.%empty_struct_type] {
  325. // CHECK:STDOUT: %.loc14_19.2: %empty_struct_type = struct_literal ()
  326. // CHECK:STDOUT: %.loc14_19.3: type = converted %.loc14_19.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT: %y: ref %empty_struct_type = bind_name y, %tuple.elem1.loc14_3
  329. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.var, constants.%T.as.Destroy.impl.Op.b38
  330. // CHECK:STDOUT: <elided>
  331. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.var, %T.as.Destroy.impl.Op.specific_fn
  332. // CHECK:STDOUT: %addr: %ptr.8fc = addr_of %.var
  333. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  334. // CHECK:STDOUT: <elided>
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: fn @H() {
  338. // CHECK:STDOUT: !entry:
  339. // CHECK:STDOUT: name_binding_decl {
  340. // CHECK:STDOUT: %x.patt: %pattern_type.a96 = binding_pattern x [concrete]
  341. // CHECK:STDOUT: %y.patt: %pattern_type.a96 = binding_pattern y [concrete]
  342. // CHECK:STDOUT: %.loc22_20: %pattern_type.de4 = tuple_pattern (%x.patt, %y.patt) [concrete]
  343. // CHECK:STDOUT: %.var_patt: %pattern_type.de4 = var_pattern %.loc22_20 [concrete]
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %.var: ref %tuple.type.b6b = var %.var_patt
  346. // CHECK:STDOUT: %MakeTuple.ref: %MakeTuple.type = name_ref MakeTuple, file.%MakeTuple.decl [concrete = constants.%MakeTuple]
  347. // CHECK:STDOUT: %.loc22_3: ref %tuple.type.b6b = splice_block %.var {}
  348. // CHECK:STDOUT: %MakeTuple.call: init %tuple.type.b6b = call %MakeTuple.ref() to %.loc22_3
  349. // CHECK:STDOUT: assign %.var, %MakeTuple.call
  350. // CHECK:STDOUT: %tuple.elem0: ref %empty_struct_type = tuple_access %.var, element0
  351. // CHECK:STDOUT: %tuple.elem1: ref %empty_struct_type = tuple_access %.var, element1
  352. // CHECK:STDOUT: %.loc22_12.1: type = splice_block %.loc22_12.3 [concrete = constants.%empty_struct_type] {
  353. // CHECK:STDOUT: %.loc22_12.2: %empty_struct_type = struct_literal ()
  354. // CHECK:STDOUT: %.loc22_12.3: type = converted %.loc22_12.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %tuple.elem0
  357. // CHECK:STDOUT: %.loc22_19.1: type = splice_block %.loc22_19.3 [concrete = constants.%empty_struct_type] {
  358. // CHECK:STDOUT: %.loc22_19.2: %empty_struct_type = struct_literal ()
  359. // CHECK:STDOUT: %.loc22_19.3: type = converted %.loc22_19.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT: %y: ref %empty_struct_type = bind_name y, %tuple.elem1
  362. // CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: <bound method> = bound_method %.var, constants.%T.as.Destroy.impl.Op.b38
  363. // CHECK:STDOUT: <elided>
  364. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.var, %T.as.Destroy.impl.Op.specific_fn
  365. // CHECK:STDOUT: %addr: %ptr.8fc = addr_of %.var
  366. // CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  367. // CHECK:STDOUT: <elided>
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: --- nested.carbon
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: constants {
  373. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  374. // CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
  375. // CHECK:STDOUT: %tuple.type.b6b: type = tuple_type (%empty_struct_type, %empty_struct_type) [concrete]
  376. // CHECK:STDOUT: %pattern_type.de4: type = pattern_type %tuple.type.b6b [concrete]
  377. // CHECK:STDOUT: %tuple.type.6ca: type = tuple_type (%empty_struct_type, %tuple.type.b6b) [concrete]
  378. // CHECK:STDOUT: %pattern_type.361: type = pattern_type %tuple.type.6ca [concrete]
  379. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: imports {
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: fn @F() {
  386. // CHECK:STDOUT: !entry:
  387. // CHECK:STDOUT: name_binding_decl {
  388. // CHECK:STDOUT: %x.patt: %pattern_type.a96 = binding_pattern x [concrete]
  389. // CHECK:STDOUT: %y.patt: %pattern_type.a96 = binding_pattern y [concrete]
  390. // CHECK:STDOUT: %z.patt: %pattern_type.a96 = binding_pattern z [concrete]
  391. // CHECK:STDOUT: %.loc6_28: %pattern_type.de4 = tuple_pattern (%y.patt, %z.patt) [concrete]
  392. // CHECK:STDOUT: %.loc6_29: %pattern_type.361 = tuple_pattern (%x.patt, %.loc6_28) [concrete]
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT: %.loc6_35.1: %empty_struct_type = struct_literal ()
  395. // CHECK:STDOUT: %.loc6_40.1: %empty_struct_type = struct_literal ()
  396. // CHECK:STDOUT: %.loc6_44.1: %empty_struct_type = struct_literal ()
  397. // CHECK:STDOUT: %.loc6_45: %tuple.type.b6b = tuple_literal (%.loc6_40.1, %.loc6_44.1)
  398. // CHECK:STDOUT: %.loc6_46: %tuple.type.6ca = tuple_literal (%.loc6_35.1, %.loc6_45)
  399. // CHECK:STDOUT: %.loc6_12.1: type = splice_block %.loc6_12.3 [concrete = constants.%empty_struct_type] {
  400. // CHECK:STDOUT: %.loc6_12.2: %empty_struct_type = struct_literal ()
  401. // CHECK:STDOUT: %.loc6_12.3: type = converted %.loc6_12.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT: %empty_struct.loc6_35: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  404. // CHECK:STDOUT: %.loc6_35.2: %empty_struct_type = converted %.loc6_35.1, %empty_struct.loc6_35 [concrete = constants.%empty_struct]
  405. // CHECK:STDOUT: %x: %empty_struct_type = bind_name x, %.loc6_35.2
  406. // CHECK:STDOUT: %.loc6_20.1: type = splice_block %.loc6_20.3 [concrete = constants.%empty_struct_type] {
  407. // CHECK:STDOUT: %.loc6_20.2: %empty_struct_type = struct_literal ()
  408. // CHECK:STDOUT: %.loc6_20.3: type = converted %.loc6_20.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT: %empty_struct.loc6_40: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  411. // CHECK:STDOUT: %.loc6_40.2: %empty_struct_type = converted %.loc6_40.1, %empty_struct.loc6_40 [concrete = constants.%empty_struct]
  412. // CHECK:STDOUT: %y: %empty_struct_type = bind_name y, %.loc6_40.2
  413. // CHECK:STDOUT: %.loc6_27.1: type = splice_block %.loc6_27.3 [concrete = constants.%empty_struct_type] {
  414. // CHECK:STDOUT: %.loc6_27.2: %empty_struct_type = struct_literal ()
  415. // CHECK:STDOUT: %.loc6_27.3: type = converted %.loc6_27.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT: %empty_struct.loc6_44: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  418. // CHECK:STDOUT: %.loc6_44.2: %empty_struct_type = converted %.loc6_44.1, %empty_struct.loc6_44 [concrete = constants.%empty_struct]
  419. // CHECK:STDOUT: %z: %empty_struct_type = bind_name z, %.loc6_44.2
  420. // CHECK:STDOUT: <elided>
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: --- package_scope.carbon
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: constants {
  426. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  427. // CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
  428. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type) [concrete]
  429. // CHECK:STDOUT: %pattern_type.de4: type = pattern_type %tuple.type [concrete]
  430. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: imports {
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: file {
  437. // CHECK:STDOUT: name_binding_decl {
  438. // CHECK:STDOUT: %x.patt: %pattern_type.a96 = binding_pattern x [concrete]
  439. // CHECK:STDOUT: %y.patt: %pattern_type.a96 = binding_pattern y [concrete]
  440. // CHECK:STDOUT: %.loc5_18: %pattern_type.de4 = tuple_pattern (%x.patt, %y.patt) [concrete]
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT: %.loc5_10.1: type = splice_block %.loc5_10.3 [concrete = constants.%empty_struct_type] {
  443. // CHECK:STDOUT: %.loc5_10.2: %empty_struct_type = struct_literal ()
  444. // CHECK:STDOUT: %.loc5_10.3: type = converted %.loc5_10.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT: %empty_struct.loc5_24: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  447. // CHECK:STDOUT: %.loc5_24: %empty_struct_type = converted @__global_init.%.loc5_24, %empty_struct.loc5_24 [concrete = constants.%empty_struct]
  448. // CHECK:STDOUT: %x: %empty_struct_type = bind_name x, %.loc5_24
  449. // CHECK:STDOUT: %.loc5_17.1: type = splice_block %.loc5_17.3 [concrete = constants.%empty_struct_type] {
  450. // CHECK:STDOUT: %.loc5_17.2: %empty_struct_type = struct_literal ()
  451. // CHECK:STDOUT: %.loc5_17.3: type = converted %.loc5_17.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  452. // CHECK:STDOUT: }
  453. // CHECK:STDOUT: %empty_struct.loc5_28: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  454. // CHECK:STDOUT: %.loc5_28: %empty_struct_type = converted @__global_init.%.loc5_28, %empty_struct.loc5_28 [concrete = constants.%empty_struct]
  455. // CHECK:STDOUT: %y: %empty_struct_type = bind_name y, %.loc5_28
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: fn @__global_init() {
  459. // CHECK:STDOUT: !entry:
  460. // CHECK:STDOUT: %.loc5_24: %empty_struct_type = struct_literal ()
  461. // CHECK:STDOUT: %.loc5_28: %empty_struct_type = struct_literal ()
  462. // CHECK:STDOUT: %.loc5_29: %tuple.type = tuple_literal (%.loc5_24, %.loc5_28)
  463. // CHECK:STDOUT: <elided>
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT: