tuple_pattern.carbon 29 KB

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