import.carbon 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/tuple/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/import.carbon
  10. // --- implicit.carbon
  11. package Implicit;
  12. var a_ref: (i32,) = (0,);
  13. var b_ref: (((i32,), i32), (i32, i32)) = (((0,), 1), (2, 3));
  14. class C(X:! (i32, i32)) {}
  15. fn F() -> C((1, 2));
  16. // --- implicit.impl.carbon
  17. impl package Implicit;
  18. var a: (i32,) = a_ref;
  19. var b: (((i32,), i32), (i32, i32)) = b_ref;
  20. var c: C((1, 2)) = F();
  21. // --- fail_bad_type.impl.carbon
  22. impl package Implicit;
  23. // CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+4]]:14: error: cannot initialize tuple of 2 element(s) from tuple with 3 element(s).
  24. // CHECK:STDERR: var c_bad: C((1, 2, 3)) = F();
  25. // CHECK:STDERR: ^~~~~~~~~
  26. // CHECK:STDERR:
  27. var c_bad: C((1, 2, 3)) = F();
  28. // --- fail_bad_value.impl.carbon
  29. impl package Implicit;
  30. // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+6]]:1: error: cannot implicitly convert from `C` to `C`
  31. // CHECK:STDERR: var c_bad: C((3, 4)) = F();
  32. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+3]]:1: note: type `C` does not implement interface `ImplicitAs`
  34. // CHECK:STDERR: var c_bad: C((3, 4)) = F();
  35. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. var c_bad: C((3, 4)) = F();
  37. // CHECK:STDOUT: --- implicit.carbon
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: constants {
  40. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  41. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  42. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  43. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  44. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  45. // CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
  46. // CHECK:STDOUT: %tuple.1: %.3 = tuple_value (%.4) [template]
  47. // CHECK:STDOUT: %.5: type = tuple_type (%.2, type) [template]
  48. // CHECK:STDOUT: %.6: type = tuple_type (type, type) [template]
  49. // CHECK:STDOUT: %.7: type = tuple_type (%.5, %.6) [template]
  50. // CHECK:STDOUT: %.8: type = tuple_type (%.3, i32) [template]
  51. // CHECK:STDOUT: %.9: type = tuple_type (i32, i32) [template]
  52. // CHECK:STDOUT: %.10: type = tuple_type (%.8, %.9) [template]
  53. // CHECK:STDOUT: %.11: type = ptr_type %.9 [template]
  54. // CHECK:STDOUT: %.12: type = ptr_type %.8 [template]
  55. // CHECK:STDOUT: %.13: type = tuple_type (%.12, %.11) [template]
  56. // CHECK:STDOUT: %.14: type = ptr_type %.13 [template]
  57. // CHECK:STDOUT: %.15: i32 = int_literal 1 [template]
  58. // CHECK:STDOUT: %.16: i32 = int_literal 2 [template]
  59. // CHECK:STDOUT: %.17: i32 = int_literal 3 [template]
  60. // CHECK:STDOUT: %tuple.2: %.8 = tuple_value (%tuple.1, %.15) [template]
  61. // CHECK:STDOUT: %tuple.3: %.9 = tuple_value (%.16, %.17) [template]
  62. // CHECK:STDOUT: %tuple.4: %.10 = tuple_value (%tuple.2, %tuple.3) [template]
  63. // CHECK:STDOUT: %X: %.9 = bind_symbolic_name X, 0 [symbolic]
  64. // CHECK:STDOUT: %X.patt: %.9 = symbolic_binding_pattern X, 0 [symbolic]
  65. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  66. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  67. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic]
  68. // CHECK:STDOUT: %.18: type = struct_type {} [template]
  69. // CHECK:STDOUT: %.19: <witness> = complete_type_witness %.18 [template]
  70. // CHECK:STDOUT: %tuple.5: %.9 = tuple_value (%.15, %.16) [template]
  71. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple.5) [template]
  72. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  73. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: imports {
  77. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  78. // CHECK:STDOUT: .Int32 = %import_ref
  79. // CHECK:STDOUT: import Core//prelude
  80. // CHECK:STDOUT: import Core//prelude/operators
  81. // CHECK:STDOUT: import Core//prelude/types
  82. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  83. // CHECK:STDOUT: import Core//prelude/operators/as
  84. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  85. // CHECK:STDOUT: import Core//prelude/operators/comparison
  86. // CHECK:STDOUT: import Core//prelude/types/bool
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: file {
  92. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  93. // CHECK:STDOUT: .Core = imports.%Core
  94. // CHECK:STDOUT: .a_ref = %a_ref
  95. // CHECK:STDOUT: .b_ref = %b_ref
  96. // CHECK:STDOUT: .C = %C.decl
  97. // CHECK:STDOUT: .F = %F.decl
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: %Core.import = import Core
  100. // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
  101. // CHECK:STDOUT: %.loc4_17.1: %.2 = tuple_literal (%int.make_type_32.loc4)
  102. // CHECK:STDOUT: %.loc4_17.2: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
  103. // CHECK:STDOUT: %.loc4_17.3: type = converted %int.make_type_32.loc4, %.loc4_17.2 [template = i32]
  104. // CHECK:STDOUT: %.loc4_17.4: type = converted %.loc4_17.1, constants.%.3 [template = constants.%.3]
  105. // CHECK:STDOUT: %a_ref.var: ref %.3 = var a_ref
  106. // CHECK:STDOUT: %a_ref: ref %.3 = bind_name a_ref, %a_ref.var
  107. // CHECK:STDOUT: %int.make_type_32.loc5_15: init type = call constants.%Int32() [template = i32]
  108. // CHECK:STDOUT: %.loc5_19: %.2 = tuple_literal (%int.make_type_32.loc5_15)
  109. // CHECK:STDOUT: %int.make_type_32.loc5_22: init type = call constants.%Int32() [template = i32]
  110. // CHECK:STDOUT: %.loc5_25: %.5 = tuple_literal (%.loc5_19, %int.make_type_32.loc5_22)
  111. // CHECK:STDOUT: %int.make_type_32.loc5_29: init type = call constants.%Int32() [template = i32]
  112. // CHECK:STDOUT: %int.make_type_32.loc5_34: init type = call constants.%Int32() [template = i32]
  113. // CHECK:STDOUT: %.loc5_37: %.6 = tuple_literal (%int.make_type_32.loc5_29, %int.make_type_32.loc5_34)
  114. // CHECK:STDOUT: %.loc5_38.1: %.7 = tuple_literal (%.loc5_25, %.loc5_37)
  115. // CHECK:STDOUT: %.loc5_38.2: type = value_of_initializer %int.make_type_32.loc5_15 [template = i32]
  116. // CHECK:STDOUT: %.loc5_38.3: type = converted %int.make_type_32.loc5_15, %.loc5_38.2 [template = i32]
  117. // CHECK:STDOUT: %.loc5_38.4: type = converted %.loc5_19, constants.%.3 [template = constants.%.3]
  118. // CHECK:STDOUT: %.loc5_38.5: type = value_of_initializer %int.make_type_32.loc5_22 [template = i32]
  119. // CHECK:STDOUT: %.loc5_38.6: type = converted %int.make_type_32.loc5_22, %.loc5_38.5 [template = i32]
  120. // CHECK:STDOUT: %.loc5_38.7: type = converted %.loc5_25, constants.%.8 [template = constants.%.8]
  121. // CHECK:STDOUT: %.loc5_38.8: type = value_of_initializer %int.make_type_32.loc5_29 [template = i32]
  122. // CHECK:STDOUT: %.loc5_38.9: type = converted %int.make_type_32.loc5_29, %.loc5_38.8 [template = i32]
  123. // CHECK:STDOUT: %.loc5_38.10: type = value_of_initializer %int.make_type_32.loc5_34 [template = i32]
  124. // CHECK:STDOUT: %.loc5_38.11: type = converted %int.make_type_32.loc5_34, %.loc5_38.10 [template = i32]
  125. // CHECK:STDOUT: %.loc5_38.12: type = converted %.loc5_37, constants.%.9 [template = constants.%.9]
  126. // CHECK:STDOUT: %.loc5_38.13: type = converted %.loc5_38.1, constants.%.10 [template = constants.%.10]
  127. // CHECK:STDOUT: %b_ref.var: ref %.10 = var b_ref
  128. // CHECK:STDOUT: %b_ref: ref %.10 = bind_name b_ref, %b_ref.var
  129. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] {
  130. // CHECK:STDOUT: %X.patt.loc7_9.1: %.9 = symbolic_binding_pattern X, 0 [symbolic = %X.patt.loc7_9.2 (constants.%X.patt)]
  131. // CHECK:STDOUT: %X.param_patt: %.9 = param_pattern %X.patt.loc7_9.1, runtime_param<invalid> [symbolic = %X.patt.loc7_9.2 (constants.%X.patt)]
  132. // CHECK:STDOUT: } {
  133. // CHECK:STDOUT: %int.make_type_32.loc7_14: init type = call constants.%Int32() [template = i32]
  134. // CHECK:STDOUT: %int.make_type_32.loc7_19: init type = call constants.%Int32() [template = i32]
  135. // CHECK:STDOUT: %.loc7_22.1: %.6 = tuple_literal (%int.make_type_32.loc7_14, %int.make_type_32.loc7_19)
  136. // CHECK:STDOUT: %.loc7_22.2: type = value_of_initializer %int.make_type_32.loc7_14 [template = i32]
  137. // CHECK:STDOUT: %.loc7_22.3: type = converted %int.make_type_32.loc7_14, %.loc7_22.2 [template = i32]
  138. // CHECK:STDOUT: %.loc7_22.4: type = value_of_initializer %int.make_type_32.loc7_19 [template = i32]
  139. // CHECK:STDOUT: %.loc7_22.5: type = converted %int.make_type_32.loc7_19, %.loc7_22.4 [template = i32]
  140. // CHECK:STDOUT: %.loc7_22.6: type = converted %.loc7_22.1, constants.%.9 [template = constants.%.9]
  141. // CHECK:STDOUT: %param: %.9 = param runtime_param<invalid>
  142. // CHECK:STDOUT: %X.loc7_9.1: %.9 = bind_symbolic_name X, 0, %param [symbolic = %X.loc7_9.2 (constants.%X)]
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  145. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.1]
  146. // CHECK:STDOUT: %.loc9_14: i32 = int_literal 1 [template = constants.%.15]
  147. // CHECK:STDOUT: %.loc9_17: i32 = int_literal 2 [template = constants.%.16]
  148. // CHECK:STDOUT: %.loc9_18: %.9 = tuple_literal (%.loc9_14, %.loc9_17)
  149. // CHECK:STDOUT: %tuple: %.9 = tuple_value (%.loc9_14, %.loc9_17) [template = constants.%tuple.5]
  150. // CHECK:STDOUT: %.loc9_12: %.9 = converted %.loc9_18, %tuple [template = constants.%tuple.5]
  151. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%tuple.5) [template = constants.%C.3]
  152. // CHECK:STDOUT: %return: ref %C.3 = var <return slot>
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: generic class @C(%X.loc7_9.1: %.9) {
  157. // CHECK:STDOUT: %X.loc7_9.2: %.9 = bind_symbolic_name X, 0 [symbolic = %X.loc7_9.2 (constants.%X)]
  158. // CHECK:STDOUT: %X.patt.loc7_9.2: %.9 = symbolic_binding_pattern X, 0 [symbolic = %X.patt.loc7_9.2 (constants.%X.patt)]
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: !definition:
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: class {
  163. // CHECK:STDOUT: %.loc7_26: <witness> = complete_type_witness %.18 [template = constants.%.19]
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: !members:
  166. // CHECK:STDOUT: .Self = constants.%C.2
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: fn @F() -> %C.3;
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: fn @__global_init() {
  175. // CHECK:STDOUT: !entry:
  176. // CHECK:STDOUT: %.loc4_22: i32 = int_literal 0 [template = constants.%.4]
  177. // CHECK:STDOUT: %.loc4_24.1: %.3 = tuple_literal (%.loc4_22)
  178. // CHECK:STDOUT: %.loc4_24.2: init %.3 = tuple_init (%.loc4_22) to file.%a_ref.var [template = constants.%tuple.1]
  179. // CHECK:STDOUT: %.loc4_25: init %.3 = converted %.loc4_24.1, %.loc4_24.2 [template = constants.%tuple.1]
  180. // CHECK:STDOUT: assign file.%a_ref.var, %.loc4_25
  181. // CHECK:STDOUT: %.loc5_45: i32 = int_literal 0 [template = constants.%.4]
  182. // CHECK:STDOUT: %.loc5_47.1: %.3 = tuple_literal (%.loc5_45)
  183. // CHECK:STDOUT: %.loc5_50: i32 = int_literal 1 [template = constants.%.15]
  184. // CHECK:STDOUT: %.loc5_51.1: %.8 = tuple_literal (%.loc5_47.1, %.loc5_50)
  185. // CHECK:STDOUT: %.loc5_55: i32 = int_literal 2 [template = constants.%.16]
  186. // CHECK:STDOUT: %.loc5_58: i32 = int_literal 3 [template = constants.%.17]
  187. // CHECK:STDOUT: %.loc5_59.1: %.9 = tuple_literal (%.loc5_55, %.loc5_58)
  188. // CHECK:STDOUT: %.loc5_60.1: %.10 = tuple_literal (%.loc5_51.1, %.loc5_59.1)
  189. // CHECK:STDOUT: %.loc5_60.2: ref %.8 = tuple_access file.%b_ref.var, element0
  190. // CHECK:STDOUT: %.loc5_51.2: ref %.3 = tuple_access %.loc5_60.2, element0
  191. // CHECK:STDOUT: %.loc5_47.2: init %.3 = tuple_init (%.loc5_45) to %.loc5_51.2 [template = constants.%tuple.1]
  192. // CHECK:STDOUT: %.loc5_51.3: init %.3 = converted %.loc5_47.1, %.loc5_47.2 [template = constants.%tuple.1]
  193. // CHECK:STDOUT: %.loc5_51.4: init %.3 = initialize_from %.loc5_51.3 to %.loc5_51.2 [template = constants.%tuple.1]
  194. // CHECK:STDOUT: %.loc5_51.5: ref i32 = tuple_access %.loc5_60.2, element1
  195. // CHECK:STDOUT: %.loc5_51.6: init i32 = initialize_from %.loc5_50 to %.loc5_51.5 [template = constants.%.15]
  196. // CHECK:STDOUT: %.loc5_51.7: init %.8 = tuple_init (%.loc5_51.4, %.loc5_51.6) to %.loc5_60.2 [template = constants.%tuple.2]
  197. // CHECK:STDOUT: %.loc5_60.3: init %.8 = converted %.loc5_51.1, %.loc5_51.7 [template = constants.%tuple.2]
  198. // CHECK:STDOUT: %.loc5_60.4: ref %.9 = tuple_access file.%b_ref.var, element1
  199. // CHECK:STDOUT: %.loc5_59.2: ref i32 = tuple_access %.loc5_60.4, element0
  200. // CHECK:STDOUT: %.loc5_59.3: init i32 = initialize_from %.loc5_55 to %.loc5_59.2 [template = constants.%.16]
  201. // CHECK:STDOUT: %.loc5_59.4: ref i32 = tuple_access %.loc5_60.4, element1
  202. // CHECK:STDOUT: %.loc5_59.5: init i32 = initialize_from %.loc5_58 to %.loc5_59.4 [template = constants.%.17]
  203. // CHECK:STDOUT: %.loc5_59.6: init %.9 = tuple_init (%.loc5_59.3, %.loc5_59.5) to %.loc5_60.4 [template = constants.%tuple.3]
  204. // CHECK:STDOUT: %.loc5_60.5: init %.9 = converted %.loc5_59.1, %.loc5_59.6 [template = constants.%tuple.3]
  205. // CHECK:STDOUT: %.loc5_60.6: init %.10 = tuple_init (%.loc5_60.3, %.loc5_60.5) to file.%b_ref.var [template = constants.%tuple.4]
  206. // CHECK:STDOUT: %.loc5_61: init %.10 = converted %.loc5_60.1, %.loc5_60.6 [template = constants.%tuple.4]
  207. // CHECK:STDOUT: assign file.%b_ref.var, %.loc5_61
  208. // CHECK:STDOUT: return
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: specific @C(constants.%X) {
  212. // CHECK:STDOUT: %X.loc7_9.2 => constants.%X
  213. // CHECK:STDOUT: %X.patt.loc7_9.2 => constants.%X
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: specific @C(constants.%tuple.5) {
  217. // CHECK:STDOUT: %X.loc7_9.2 => constants.%tuple.5
  218. // CHECK:STDOUT: %X.patt.loc7_9.2 => constants.%tuple.5
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: --- implicit.impl.carbon
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: constants {
  224. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  225. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  226. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  227. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  228. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  229. // CHECK:STDOUT: %.4: type = tuple_type (%.2, type) [template]
  230. // CHECK:STDOUT: %.5: type = tuple_type (type, type) [template]
  231. // CHECK:STDOUT: %.6: type = tuple_type (%.4, %.5) [template]
  232. // CHECK:STDOUT: %.7: type = tuple_type (%.3, i32) [template]
  233. // CHECK:STDOUT: %.8: type = tuple_type (i32, i32) [template]
  234. // CHECK:STDOUT: %.9: type = tuple_type (%.7, %.8) [template]
  235. // CHECK:STDOUT: %.10: type = ptr_type %.8 [template]
  236. // CHECK:STDOUT: %.11: type = ptr_type %.7 [template]
  237. // CHECK:STDOUT: %.12: type = tuple_type (%.11, %.10) [template]
  238. // CHECK:STDOUT: %.13: type = ptr_type %.12 [template]
  239. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  240. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  241. // CHECK:STDOUT: %.14: type = struct_type {} [template]
  242. // CHECK:STDOUT: %.15: <witness> = complete_type_witness %.14 [template]
  243. // CHECK:STDOUT: %X: %.8 = bind_symbolic_name X, 0 [symbolic]
  244. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic]
  245. // CHECK:STDOUT: %X.patt: %.8 = symbolic_binding_pattern X, 0 [symbolic]
  246. // CHECK:STDOUT: %.16: i32 = int_literal 1 [template]
  247. // CHECK:STDOUT: %.17: i32 = int_literal 2 [template]
  248. // CHECK:STDOUT: %tuple: %.8 = tuple_value (%.16, %.17) [template]
  249. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple) [template]
  250. // CHECK:STDOUT: %.18: type = ptr_type %.14 [template]
  251. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  252. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: imports {
  256. // CHECK:STDOUT: %import_ref.1: ref %.3 = import_ref Implicit//default, inst+17, loaded
  257. // CHECK:STDOUT: %import_ref.2: ref %.9 = import_ref Implicit//default, inst+57, loaded
  258. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+106, loaded [template = constants.%C.1]
  259. // CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+125, loaded [template = constants.%F]
  260. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  261. // CHECK:STDOUT: .Int32 = %import_ref.5
  262. // CHECK:STDOUT: import Core//prelude
  263. // CHECK:STDOUT: import Core//prelude/operators
  264. // CHECK:STDOUT: import Core//prelude/types
  265. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  266. // CHECK:STDOUT: import Core//prelude/operators/as
  267. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  268. // CHECK:STDOUT: import Core//prelude/operators/comparison
  269. // CHECK:STDOUT: import Core//prelude/types/bool
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
  272. // CHECK:STDOUT: %import_ref.6 = import_ref Implicit//default, inst+111, unloaded
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: file {
  276. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  277. // CHECK:STDOUT: .a_ref = imports.%import_ref.1
  278. // CHECK:STDOUT: .b_ref = imports.%import_ref.2
  279. // CHECK:STDOUT: .C = imports.%import_ref.3
  280. // CHECK:STDOUT: .F = imports.%import_ref.4
  281. // CHECK:STDOUT: .Core = imports.%Core
  282. // CHECK:STDOUT: .a = %a
  283. // CHECK:STDOUT: .b = %b
  284. // CHECK:STDOUT: .c = %c
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT: %Implicit.import = import Implicit
  287. // CHECK:STDOUT: %default.import = import <invalid>
  288. // CHECK:STDOUT: %Core.import = import Core
  289. // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
  290. // CHECK:STDOUT: %.loc4_13.1: %.2 = tuple_literal (%int.make_type_32.loc4)
  291. // CHECK:STDOUT: %.loc4_13.2: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
  292. // CHECK:STDOUT: %.loc4_13.3: type = converted %int.make_type_32.loc4, %.loc4_13.2 [template = i32]
  293. // CHECK:STDOUT: %.loc4_13.4: type = converted %.loc4_13.1, constants.%.3 [template = constants.%.3]
  294. // CHECK:STDOUT: %a.var: ref %.3 = var a
  295. // CHECK:STDOUT: %a: ref %.3 = bind_name a, %a.var
  296. // CHECK:STDOUT: %int.make_type_32.loc5_11: init type = call constants.%Int32() [template = i32]
  297. // CHECK:STDOUT: %.loc5_15: %.2 = tuple_literal (%int.make_type_32.loc5_11)
  298. // CHECK:STDOUT: %int.make_type_32.loc5_18: init type = call constants.%Int32() [template = i32]
  299. // CHECK:STDOUT: %.loc5_21: %.4 = tuple_literal (%.loc5_15, %int.make_type_32.loc5_18)
  300. // CHECK:STDOUT: %int.make_type_32.loc5_25: init type = call constants.%Int32() [template = i32]
  301. // CHECK:STDOUT: %int.make_type_32.loc5_30: init type = call constants.%Int32() [template = i32]
  302. // CHECK:STDOUT: %.loc5_33: %.5 = tuple_literal (%int.make_type_32.loc5_25, %int.make_type_32.loc5_30)
  303. // CHECK:STDOUT: %.loc5_34.1: %.6 = tuple_literal (%.loc5_21, %.loc5_33)
  304. // CHECK:STDOUT: %.loc5_34.2: type = value_of_initializer %int.make_type_32.loc5_11 [template = i32]
  305. // CHECK:STDOUT: %.loc5_34.3: type = converted %int.make_type_32.loc5_11, %.loc5_34.2 [template = i32]
  306. // CHECK:STDOUT: %.loc5_34.4: type = converted %.loc5_15, constants.%.3 [template = constants.%.3]
  307. // CHECK:STDOUT: %.loc5_34.5: type = value_of_initializer %int.make_type_32.loc5_18 [template = i32]
  308. // CHECK:STDOUT: %.loc5_34.6: type = converted %int.make_type_32.loc5_18, %.loc5_34.5 [template = i32]
  309. // CHECK:STDOUT: %.loc5_34.7: type = converted %.loc5_21, constants.%.7 [template = constants.%.7]
  310. // CHECK:STDOUT: %.loc5_34.8: type = value_of_initializer %int.make_type_32.loc5_25 [template = i32]
  311. // CHECK:STDOUT: %.loc5_34.9: type = converted %int.make_type_32.loc5_25, %.loc5_34.8 [template = i32]
  312. // CHECK:STDOUT: %.loc5_34.10: type = value_of_initializer %int.make_type_32.loc5_30 [template = i32]
  313. // CHECK:STDOUT: %.loc5_34.11: type = converted %int.make_type_32.loc5_30, %.loc5_34.10 [template = i32]
  314. // CHECK:STDOUT: %.loc5_34.12: type = converted %.loc5_33, constants.%.8 [template = constants.%.8]
  315. // CHECK:STDOUT: %.loc5_34.13: type = converted %.loc5_34.1, constants.%.9 [template = constants.%.9]
  316. // CHECK:STDOUT: %b.var: ref %.9 = var b
  317. // CHECK:STDOUT: %b: ref %.9 = bind_name b, %b.var
  318. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1]
  319. // CHECK:STDOUT: %.loc6_11: i32 = int_literal 1 [template = constants.%.16]
  320. // CHECK:STDOUT: %.loc6_14: i32 = int_literal 2 [template = constants.%.17]
  321. // CHECK:STDOUT: %.loc6_15: %.8 = tuple_literal (%.loc6_11, %.loc6_14)
  322. // CHECK:STDOUT: %tuple: %.8 = tuple_value (%.loc6_11, %.loc6_14) [template = constants.%tuple]
  323. // CHECK:STDOUT: %.loc6_9: %.8 = converted %.loc6_15, %tuple [template = constants.%tuple]
  324. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%tuple) [template = constants.%C.3]
  325. // CHECK:STDOUT: %c.var: ref %C.3 = var c
  326. // CHECK:STDOUT: %c: ref %C.3 = bind_name c, %c.var
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: generic class @C(constants.%X: %.8) {
  330. // CHECK:STDOUT: %X: %.8 = bind_symbolic_name X, 0 [symbolic = %X (constants.%X)]
  331. // CHECK:STDOUT: %X.patt: %.8 = symbolic_binding_pattern X, 0 [symbolic = %X.patt (constants.%X.patt)]
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: !definition:
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: class {
  336. // CHECK:STDOUT: !members:
  337. // CHECK:STDOUT: .Self = imports.%import_ref.6
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: fn @F() -> %C.3;
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: fn @__global_init() {
  346. // CHECK:STDOUT: !entry:
  347. // CHECK:STDOUT: %a_ref.ref: ref %.3 = name_ref a_ref, imports.%import_ref.1
  348. // CHECK:STDOUT: %.loc4_17.1: ref i32 = tuple_access %a_ref.ref, element0
  349. // CHECK:STDOUT: %.loc4_17.2: i32 = bind_value %.loc4_17.1
  350. // CHECK:STDOUT: %.loc4_17.3: init %.3 = tuple_init (%.loc4_17.2) to file.%a.var
  351. // CHECK:STDOUT: %.loc4_22: init %.3 = converted %a_ref.ref, %.loc4_17.3
  352. // CHECK:STDOUT: assign file.%a.var, %.loc4_22
  353. // CHECK:STDOUT: %b_ref.ref: ref %.9 = name_ref b_ref, imports.%import_ref.2
  354. // CHECK:STDOUT: %.loc5_38.1: ref %.7 = tuple_access %b_ref.ref, element0
  355. // CHECK:STDOUT: %.loc5_38.2: ref %.3 = tuple_access %.loc5_38.1, element0
  356. // CHECK:STDOUT: %.loc5_38.3: ref i32 = tuple_access %.loc5_38.2, element0
  357. // CHECK:STDOUT: %.loc5_38.4: i32 = bind_value %.loc5_38.3
  358. // CHECK:STDOUT: %.loc5_38.5: ref %.7 = tuple_access file.%b.var, element0
  359. // CHECK:STDOUT: %.loc5_38.6: ref %.3 = tuple_access %.loc5_38.5, element0
  360. // CHECK:STDOUT: %.loc5_38.7: init %.3 = tuple_init (%.loc5_38.4) to %.loc5_38.6
  361. // CHECK:STDOUT: %.loc5_38.8: init %.3 = converted %.loc5_38.2, %.loc5_38.7
  362. // CHECK:STDOUT: %.loc5_38.9: init %.3 = initialize_from %.loc5_38.8 to %.loc5_38.6
  363. // CHECK:STDOUT: %.loc5_38.10: ref i32 = tuple_access %.loc5_38.1, element1
  364. // CHECK:STDOUT: %.loc5_38.11: i32 = bind_value %.loc5_38.10
  365. // CHECK:STDOUT: %.loc5_38.12: ref i32 = tuple_access %.loc5_38.5, element1
  366. // CHECK:STDOUT: %.loc5_38.13: init i32 = initialize_from %.loc5_38.11 to %.loc5_38.12
  367. // CHECK:STDOUT: %.loc5_38.14: init %.7 = tuple_init (%.loc5_38.9, %.loc5_38.13) to %.loc5_38.5
  368. // CHECK:STDOUT: %.loc5_38.15: init %.7 = converted %.loc5_38.1, %.loc5_38.14
  369. // CHECK:STDOUT: %.loc5_38.16: ref %.8 = tuple_access %b_ref.ref, element1
  370. // CHECK:STDOUT: %.loc5_38.17: ref i32 = tuple_access %.loc5_38.16, element0
  371. // CHECK:STDOUT: %.loc5_38.18: i32 = bind_value %.loc5_38.17
  372. // CHECK:STDOUT: %.loc5_38.19: ref %.8 = tuple_access file.%b.var, element1
  373. // CHECK:STDOUT: %.loc5_38.20: ref i32 = tuple_access %.loc5_38.19, element0
  374. // CHECK:STDOUT: %.loc5_38.21: init i32 = initialize_from %.loc5_38.18 to %.loc5_38.20
  375. // CHECK:STDOUT: %.loc5_38.22: ref i32 = tuple_access %.loc5_38.16, element1
  376. // CHECK:STDOUT: %.loc5_38.23: i32 = bind_value %.loc5_38.22
  377. // CHECK:STDOUT: %.loc5_38.24: ref i32 = tuple_access %.loc5_38.19, element1
  378. // CHECK:STDOUT: %.loc5_38.25: init i32 = initialize_from %.loc5_38.23 to %.loc5_38.24
  379. // CHECK:STDOUT: %.loc5_38.26: init %.8 = tuple_init (%.loc5_38.21, %.loc5_38.25) to %.loc5_38.19
  380. // CHECK:STDOUT: %.loc5_38.27: init %.8 = converted %.loc5_38.16, %.loc5_38.26
  381. // CHECK:STDOUT: %.loc5_38.28: init %.9 = tuple_init (%.loc5_38.15, %.loc5_38.27) to file.%b.var
  382. // CHECK:STDOUT: %.loc5_43: init %.9 = converted %b_ref.ref, %.loc5_38.28
  383. // CHECK:STDOUT: assign file.%b.var, %.loc5_43
  384. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F]
  385. // CHECK:STDOUT: %.loc6: ref %C.3 = splice_block file.%c.var {}
  386. // CHECK:STDOUT: %F.call: init %C.3 = call %F.ref() to %.loc6
  387. // CHECK:STDOUT: assign file.%c.var, %F.call
  388. // CHECK:STDOUT: return
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: specific @C(constants.%X) {
  392. // CHECK:STDOUT: %X => constants.%X
  393. // CHECK:STDOUT: %X.patt => constants.%X
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: specific @C(constants.%tuple) {
  397. // CHECK:STDOUT: %X => constants.%tuple
  398. // CHECK:STDOUT: %X.patt => constants.%tuple
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: !definition:
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: --- fail_bad_type.impl.carbon
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: constants {
  406. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  407. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  408. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  409. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  410. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  411. // CHECK:STDOUT: %.4: type = tuple_type (i32, i32) [template]
  412. // CHECK:STDOUT: %X: %.4 = bind_symbolic_name X, 0 [symbolic]
  413. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic]
  414. // CHECK:STDOUT: %X.patt: %.4 = symbolic_binding_pattern X, 0 [symbolic]
  415. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  416. // CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
  417. // CHECK:STDOUT: %.7: i32 = int_literal 3 [template]
  418. // CHECK:STDOUT: %.8: type = tuple_type (i32, i32, i32) [template]
  419. // CHECK:STDOUT: %.9: type = ptr_type %.4 [template]
  420. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  421. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  422. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.5, %.6) [template]
  423. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple) [template]
  424. // CHECK:STDOUT: %.10: type = ptr_type %.2 [template]
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: imports {
  428. // CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
  429. // CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+57, unloaded
  430. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+106, loaded [template = constants.%C.1]
  431. // CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+125, loaded [template = constants.%F]
  432. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  433. // CHECK:STDOUT: import Core//prelude
  434. // CHECK:STDOUT: import Core//prelude/operators
  435. // CHECK:STDOUT: import Core//prelude/types
  436. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  437. // CHECK:STDOUT: import Core//prelude/operators/as
  438. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  439. // CHECK:STDOUT: import Core//prelude/operators/comparison
  440. // CHECK:STDOUT: import Core//prelude/types/bool
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+111, unloaded
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: file {
  446. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  447. // CHECK:STDOUT: .a_ref = imports.%import_ref.1
  448. // CHECK:STDOUT: .b_ref = imports.%import_ref.2
  449. // CHECK:STDOUT: .C = imports.%import_ref.3
  450. // CHECK:STDOUT: .F = imports.%import_ref.4
  451. // CHECK:STDOUT: .Core = imports.%Core
  452. // CHECK:STDOUT: .c_bad = %c_bad
  453. // CHECK:STDOUT: }
  454. // CHECK:STDOUT: %Implicit.import = import Implicit
  455. // CHECK:STDOUT: %default.import = import <invalid>
  456. // CHECK:STDOUT: %Core.import = import Core
  457. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1]
  458. // CHECK:STDOUT: %.loc8_15: i32 = int_literal 1 [template = constants.%.5]
  459. // CHECK:STDOUT: %.loc8_18: i32 = int_literal 2 [template = constants.%.6]
  460. // CHECK:STDOUT: %.loc8_21: i32 = int_literal 3 [template = constants.%.7]
  461. // CHECK:STDOUT: %.loc8_22: %.8 = tuple_literal (%.loc8_15, %.loc8_18, %.loc8_21)
  462. // CHECK:STDOUT: %c_bad.var: ref <error> = var c_bad
  463. // CHECK:STDOUT: %c_bad: ref <error> = bind_name c_bad, %c_bad.var
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: generic class @C(constants.%X: %.4) {
  467. // CHECK:STDOUT: %X: %.4 = bind_symbolic_name X, 0 [symbolic = %X (constants.%X)]
  468. // CHECK:STDOUT: %X.patt: %.4 = symbolic_binding_pattern X, 0 [symbolic = %X.patt (constants.%X.patt)]
  469. // CHECK:STDOUT:
  470. // CHECK:STDOUT: !definition:
  471. // CHECK:STDOUT:
  472. // CHECK:STDOUT: class {
  473. // CHECK:STDOUT: !members:
  474. // CHECK:STDOUT: .Self = imports.%import_ref.5
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT:
  478. // CHECK:STDOUT: fn @F() -> %C.3;
  479. // CHECK:STDOUT:
  480. // CHECK:STDOUT: fn @__global_init() {
  481. // CHECK:STDOUT: !entry:
  482. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F]
  483. // CHECK:STDOUT: %.loc8: ref %C.3 = temporary_storage
  484. // CHECK:STDOUT: %F.call: init %C.3 = call %F.ref() to %.loc8
  485. // CHECK:STDOUT: assign file.%c_bad.var, <error>
  486. // CHECK:STDOUT: return
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT:
  489. // CHECK:STDOUT: specific @C(constants.%X) {
  490. // CHECK:STDOUT: %X => constants.%X
  491. // CHECK:STDOUT: %X.patt => constants.%X
  492. // CHECK:STDOUT: }
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: specific @C(constants.%tuple) {
  495. // CHECK:STDOUT: %X => constants.%tuple
  496. // CHECK:STDOUT: %X.patt => constants.%tuple
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: !definition:
  499. // CHECK:STDOUT: }
  500. // CHECK:STDOUT:
  501. // CHECK:STDOUT: --- fail_bad_value.impl.carbon
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: constants {
  504. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  505. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  506. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  507. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  508. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  509. // CHECK:STDOUT: %.4: type = tuple_type (i32, i32) [template]
  510. // CHECK:STDOUT: %X: %.4 = bind_symbolic_name X, 0 [symbolic]
  511. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%X) [symbolic]
  512. // CHECK:STDOUT: %X.patt: %.4 = symbolic_binding_pattern X, 0 [symbolic]
  513. // CHECK:STDOUT: %.5: i32 = int_literal 3 [template]
  514. // CHECK:STDOUT: %.6: i32 = int_literal 4 [template]
  515. // CHECK:STDOUT: %.7: type = ptr_type %.4 [template]
  516. // CHECK:STDOUT: %tuple.1: %.4 = tuple_value (%.5, %.6) [template]
  517. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%tuple.1) [template]
  518. // CHECK:STDOUT: %.8: type = ptr_type %.2 [template]
  519. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  520. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  521. // CHECK:STDOUT: %.9: i32 = int_literal 2 [template]
  522. // CHECK:STDOUT: %.10: i32 = int_literal 1 [template]
  523. // CHECK:STDOUT: %tuple.2: %.4 = tuple_value (%.10, %.9) [template]
  524. // CHECK:STDOUT: %C.4: type = class_type @C, @C(%tuple.2) [template]
  525. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  526. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  527. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  528. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  529. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  530. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  531. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  532. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  533. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  534. // CHECK:STDOUT: %.11: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  535. // CHECK:STDOUT: %.12: %.11 = assoc_entity element0, imports.%import_ref.10 [symbolic]
  536. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%C.3) [template]
  537. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%C.3) [template]
  538. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  539. // CHECK:STDOUT: %.13: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  540. // CHECK:STDOUT: %.14: %.13 = assoc_entity element0, imports.%import_ref.10 [template]
  541. // CHECK:STDOUT: %.15: %.11 = assoc_entity element0, imports.%import_ref.11 [symbolic]
  542. // CHECK:STDOUT: }
  543. // CHECK:STDOUT:
  544. // CHECK:STDOUT: imports {
  545. // CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
  546. // CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+57, unloaded
  547. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+106, loaded [template = constants.%C.1]
  548. // CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+125, loaded [template = constants.%F]
  549. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  550. // CHECK:STDOUT: .ImplicitAs = %import_ref.6
  551. // CHECK:STDOUT: import Core//prelude
  552. // CHECK:STDOUT: import Core//prelude/operators
  553. // CHECK:STDOUT: import Core//prelude/types
  554. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  555. // CHECK:STDOUT: import Core//prelude/operators/as
  556. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  557. // CHECK:STDOUT: import Core//prelude/operators/comparison
  558. // CHECK:STDOUT: import Core//prelude/types/bool
  559. // CHECK:STDOUT: }
  560. // CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+111, unloaded
  561. // CHECK:STDOUT: %import_ref.6: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+46, loaded [template = constants.%ImplicitAs]
  562. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+52, unloaded
  563. // CHECK:STDOUT: %import_ref.8: @ImplicitAs.%.1 (%.11) = import_ref Core//prelude/operators/as, inst+71, loaded [symbolic = @ImplicitAs.%.2 (constants.%.15)]
  564. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/as, inst+64, unloaded
  565. // CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/as, inst+64, unloaded
  566. // CHECK:STDOUT: %import_ref.11 = import_ref Core//prelude/operators/as, inst+64, unloaded
  567. // CHECK:STDOUT: }
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: file {
  570. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  571. // CHECK:STDOUT: .a_ref = imports.%import_ref.1
  572. // CHECK:STDOUT: .b_ref = imports.%import_ref.2
  573. // CHECK:STDOUT: .C = imports.%import_ref.3
  574. // CHECK:STDOUT: .F = imports.%import_ref.4
  575. // CHECK:STDOUT: .Core = imports.%Core
  576. // CHECK:STDOUT: .c_bad = %c_bad
  577. // CHECK:STDOUT: }
  578. // CHECK:STDOUT: %Implicit.import = import Implicit
  579. // CHECK:STDOUT: %default.import = import <invalid>
  580. // CHECK:STDOUT: %Core.import = import Core
  581. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1]
  582. // CHECK:STDOUT: %.loc10_15: i32 = int_literal 3 [template = constants.%.5]
  583. // CHECK:STDOUT: %.loc10_18: i32 = int_literal 4 [template = constants.%.6]
  584. // CHECK:STDOUT: %.loc10_19: %.4 = tuple_literal (%.loc10_15, %.loc10_18)
  585. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc10_15, %.loc10_18) [template = constants.%tuple.1]
  586. // CHECK:STDOUT: %.loc10_13: %.4 = converted %.loc10_19, %tuple [template = constants.%tuple.1]
  587. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%tuple.1) [template = constants.%C.3]
  588. // CHECK:STDOUT: %c_bad.var: ref %C.3 = var c_bad
  589. // CHECK:STDOUT: %c_bad: ref %C.3 = bind_name c_bad, %c_bad.var
  590. // CHECK:STDOUT: }
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  593. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  594. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  595. // CHECK:STDOUT:
  596. // CHECK:STDOUT: !definition:
  597. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  598. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  599. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  600. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  601. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.11)]
  602. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.11) = assoc_entity element0, imports.%import_ref.10 [symbolic = %.2 (constants.%.12)]
  603. // CHECK:STDOUT:
  604. // CHECK:STDOUT: interface {
  605. // CHECK:STDOUT: !members:
  606. // CHECK:STDOUT: .Self = imports.%import_ref.7
  607. // CHECK:STDOUT: .Convert = imports.%import_ref.8
  608. // CHECK:STDOUT: witness = (imports.%import_ref.9)
  609. // CHECK:STDOUT: }
  610. // CHECK:STDOUT: }
  611. // CHECK:STDOUT:
  612. // CHECK:STDOUT: generic class @C(constants.%X: %.4) {
  613. // CHECK:STDOUT: %X: %.4 = bind_symbolic_name X, 0 [symbolic = %X (constants.%X)]
  614. // CHECK:STDOUT: %X.patt: %.4 = symbolic_binding_pattern X, 0 [symbolic = %X.patt (constants.%X.patt)]
  615. // CHECK:STDOUT:
  616. // CHECK:STDOUT: !definition:
  617. // CHECK:STDOUT:
  618. // CHECK:STDOUT: class {
  619. // CHECK:STDOUT: !members:
  620. // CHECK:STDOUT: .Self = imports.%import_ref.5
  621. // CHECK:STDOUT: }
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT:
  624. // CHECK:STDOUT: fn @F() -> %C.4;
  625. // CHECK:STDOUT:
  626. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  627. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  628. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  629. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  630. // CHECK:STDOUT:
  631. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  632. // CHECK:STDOUT: }
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: fn @__global_init() {
  635. // CHECK:STDOUT: !entry:
  636. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F]
  637. // CHECK:STDOUT: %.loc10_25.1: ref %C.4 = temporary_storage
  638. // CHECK:STDOUT: %F.call: init %C.4 = call %F.ref() to %.loc10_25.1
  639. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%C.3) [template = constants.%ImplicitAs.type.3]
  640. // CHECK:STDOUT: %.loc10_27.1: %.13 = specific_constant imports.%import_ref.8, @ImplicitAs(constants.%C.3) [template = constants.%.14]
  641. // CHECK:STDOUT: %Convert.ref: %.13 = name_ref Convert, %.loc10_27.1 [template = constants.%.14]
  642. // CHECK:STDOUT: %.loc10_25.2: ref %C.4 = temporary %.loc10_25.1, %F.call
  643. // CHECK:STDOUT: %.loc10_27.2: %C.3 = converted %F.call, <error> [template = <error>]
  644. // CHECK:STDOUT: assign file.%c_bad.var, <error>
  645. // CHECK:STDOUT: return
  646. // CHECK:STDOUT: }
  647. // CHECK:STDOUT:
  648. // CHECK:STDOUT: specific @C(constants.%X) {
  649. // CHECK:STDOUT: %X => constants.%X
  650. // CHECK:STDOUT: %X.patt => constants.%X
  651. // CHECK:STDOUT: }
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: specific @C(constants.%tuple.1) {
  654. // CHECK:STDOUT: %X => constants.%tuple.1
  655. // CHECK:STDOUT: %X.patt => constants.%tuple.1
  656. // CHECK:STDOUT:
  657. // CHECK:STDOUT: !definition:
  658. // CHECK:STDOUT: }
  659. // CHECK:STDOUT:
  660. // CHECK:STDOUT: specific @C(constants.%tuple.2) {
  661. // CHECK:STDOUT: %X => constants.%tuple.2
  662. // CHECK:STDOUT: %X.patt => constants.%tuple.2
  663. // CHECK:STDOUT:
  664. // CHECK:STDOUT: !definition:
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT:
  667. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  668. // CHECK:STDOUT: %Dest => constants.%Dest
  669. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT:
  672. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  673. // CHECK:STDOUT: %Dest => constants.%Dest
  674. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  675. // CHECK:STDOUT: }
  676. // CHECK:STDOUT:
  677. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  678. // CHECK:STDOUT: %Dest => constants.%Dest
  679. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  680. // CHECK:STDOUT: }
  681. // CHECK:STDOUT:
  682. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  683. // CHECK:STDOUT: %Dest => constants.%Dest
  684. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  685. // CHECK:STDOUT: %Self => constants.%Self.1
  686. // CHECK:STDOUT: }
  687. // CHECK:STDOUT:
  688. // CHECK:STDOUT: specific @ImplicitAs(constants.%C.3) {
  689. // CHECK:STDOUT: %Dest => constants.%C.3
  690. // CHECK:STDOUT: %Dest.patt => constants.%C.3
  691. // CHECK:STDOUT:
  692. // CHECK:STDOUT: !definition:
  693. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  694. // CHECK:STDOUT: %Self => constants.%Self.2
  695. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  696. // CHECK:STDOUT: %Convert => constants.%Convert.2
  697. // CHECK:STDOUT: %.1 => constants.%.13
  698. // CHECK:STDOUT: %.2 => constants.%.14
  699. // CHECK:STDOUT: }
  700. // CHECK:STDOUT: