import.carbon 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  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/function/declaration/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/import.carbon
  10. // ============================================================================
  11. // Setup files
  12. // ============================================================================
  13. // --- api.carbon
  14. library "[[@TEST_NAME]]";
  15. fn A();
  16. fn B(b: i32) -> i32;
  17. fn C(c: (i32,)) -> {.c: i32};
  18. extern fn D();
  19. namespace NS;
  20. fn NS.E();
  21. // --- extern_api.carbon
  22. library "[[@TEST_NAME]]";
  23. extern library "redecl_extern_api" fn A();
  24. extern library "redecl_extern_api" fn B(b: i32) -> i32;
  25. extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
  26. extern library "redecl_extern_api" fn D();
  27. namespace NS;
  28. extern library "redecl_extern_api" fn NS.E();
  29. // ============================================================================
  30. // Test files
  31. // ============================================================================
  32. // --- basics.carbon
  33. library "[[@TEST_NAME]]";
  34. import library "api";
  35. var a: () = A();
  36. var b: i32 = B(1);
  37. var c: {.c: i32} = C((1,));
  38. var d: () = D();
  39. var e: () = NS.E();
  40. // --- fail_redecl_api.carbon
  41. library "[[@TEST_NAME]]";
  42. import library "api";
  43. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn A` must match use of `extern` [RedeclExternMismatch]
  44. // CHECK:STDERR: extern fn A();
  45. // CHECK:STDERR: ^~~~~~~~~~~~~~
  46. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-5]]:1: in import [InImport]
  47. // CHECK:STDERR: api.carbon:4:1: note: previously declared here [RedeclPrevDecl]
  48. // CHECK:STDERR: fn A();
  49. // CHECK:STDERR: ^~~~~~~
  50. // CHECK:STDERR:
  51. extern fn A();
  52. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn B` must match use of `extern` [RedeclExternMismatch]
  53. // CHECK:STDERR: extern fn B(b: i32) -> i32;
  54. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-14]]:1: in import [InImport]
  56. // CHECK:STDERR: api.carbon:5:1: note: previously declared here [RedeclPrevDecl]
  57. // CHECK:STDERR: fn B(b: i32) -> i32;
  58. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  59. // CHECK:STDERR:
  60. extern fn B(b: i32) -> i32;
  61. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn C` must match use of `extern` [RedeclExternMismatch]
  62. // CHECK:STDERR: extern fn C(c: (i32,)) -> {.c: i32};
  63. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-23]]:1: in import [InImport]
  65. // CHECK:STDERR: api.carbon:6:1: note: previously declared here [RedeclPrevDecl]
  66. // CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
  67. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. // CHECK:STDERR:
  69. extern fn C(c: (i32,)) -> {.c: i32};
  70. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclaration of `fn D` is redundant [RedeclRedundant]
  71. // CHECK:STDERR: extern fn D();
  72. // CHECK:STDERR: ^~~~~~~~~~~~~~
  73. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-32]]:1: in import [InImport]
  74. // CHECK:STDERR: api.carbon:7:1: note: previously declared here [RedeclPrevDecl]
  75. // CHECK:STDERR: extern fn D();
  76. // CHECK:STDERR: ^~~~~~~~~~~~~~
  77. // CHECK:STDERR:
  78. extern fn D();
  79. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn E` must match use of `extern` [RedeclExternMismatch]
  80. // CHECK:STDERR: extern fn NS.E();
  81. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  82. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-41]]:1: in import [InImport]
  83. // CHECK:STDERR: api.carbon:10:1: note: previously declared here [RedeclPrevDecl]
  84. // CHECK:STDERR: fn NS.E();
  85. // CHECK:STDERR: ^~~~~~~~~~
  86. // CHECK:STDERR:
  87. extern fn NS.E();
  88. var a: () = A();
  89. var b: i32 = B(1);
  90. var c: {.c: i32} = C((1,));
  91. var d: () = D();
  92. var e: () = NS.E();
  93. // --- redecl_extern_api.carbon
  94. library "[[@TEST_NAME]]";
  95. import library "extern_api";
  96. extern fn A();
  97. extern fn B(b: i32) -> i32;
  98. extern fn C(c: (i32,)) -> {.c: i32};
  99. extern fn D();
  100. extern fn NS.E();
  101. var a: () = A();
  102. var b: i32 = B(1);
  103. var c: {.c: i32} = C((1,));
  104. var d: () = D();
  105. var e: () = NS.E();
  106. // --- fail_merge.carbon
  107. library "[[@TEST_NAME]]";
  108. // CHECK:STDERR: fail_merge.carbon:[[@LINE+45]]:1: in import [InImport]
  109. // CHECK:STDERR: extern_api.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  110. // CHECK:STDERR: extern library "redecl_extern_api" fn A();
  111. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112. // CHECK:STDERR: fail_merge.carbon:[[@LINE+41]]:1: in import [InImport]
  113. // CHECK:STDERR: api.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  114. // CHECK:STDERR: fn A();
  115. // CHECK:STDERR: ^~~~~~~
  116. // CHECK:STDERR:
  117. // CHECK:STDERR: fail_merge.carbon:[[@LINE+36]]:1: in import [InImport]
  118. // CHECK:STDERR: extern_api.carbon:5:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  119. // CHECK:STDERR: extern library "redecl_extern_api" fn B(b: i32) -> i32;
  120. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  121. // CHECK:STDERR: fail_merge.carbon:[[@LINE+32]]:1: in import [InImport]
  122. // CHECK:STDERR: api.carbon:5:1: note: name is previously declared here [NameDeclPrevious]
  123. // CHECK:STDERR: fn B(b: i32) -> i32;
  124. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  125. // CHECK:STDERR:
  126. // CHECK:STDERR: fail_merge.carbon:[[@LINE+27]]:1: in import [InImport]
  127. // CHECK:STDERR: extern_api.carbon:6:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  128. // CHECK:STDERR: extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
  129. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  130. // CHECK:STDERR: fail_merge.carbon:[[@LINE+23]]:1: in import [InImport]
  131. // CHECK:STDERR: api.carbon:6:1: note: name is previously declared here [NameDeclPrevious]
  132. // CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
  133. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  134. // CHECK:STDERR:
  135. // CHECK:STDERR: fail_merge.carbon:[[@LINE+18]]:1: in import [InImport]
  136. // CHECK:STDERR: extern_api.carbon:7:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  137. // CHECK:STDERR: extern library "redecl_extern_api" fn D();
  138. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. // CHECK:STDERR: fail_merge.carbon:[[@LINE+14]]:1: in import [InImport]
  140. // CHECK:STDERR: api.carbon:7:1: note: name is previously declared here [NameDeclPrevious]
  141. // CHECK:STDERR: extern fn D();
  142. // CHECK:STDERR: ^~~~~~~~~~~~~~
  143. // CHECK:STDERR:
  144. // CHECK:STDERR: fail_merge.carbon:[[@LINE+9]]:1: in import [InImport]
  145. // CHECK:STDERR: extern_api.carbon:10:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  146. // CHECK:STDERR: extern library "redecl_extern_api" fn NS.E();
  147. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  148. // CHECK:STDERR: fail_merge.carbon:[[@LINE+5]]:1: in import [InImport]
  149. // CHECK:STDERR: api.carbon:10:1: note: name is previously declared here [NameDeclPrevious]
  150. // CHECK:STDERR: fn NS.E();
  151. // CHECK:STDERR: ^~~~~~~~~~
  152. // CHECK:STDERR:
  153. import library "api";
  154. import library "extern_api";
  155. var a: () = A();
  156. var b: i32 = B(1);
  157. var c: {.c: i32} = C((1,));
  158. var d: () = D();
  159. var e: () = NS.E();
  160. // --- fail_merge_reverse.carbon
  161. library "[[@TEST_NAME]]";
  162. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+45]]:1: in import [InImport]
  163. // CHECK:STDERR: api.carbon:4:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  164. // CHECK:STDERR: fn A();
  165. // CHECK:STDERR: ^~~~~~~
  166. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+41]]:1: in import [InImport]
  167. // CHECK:STDERR: extern_api.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  168. // CHECK:STDERR: extern library "redecl_extern_api" fn A();
  169. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. // CHECK:STDERR:
  171. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+36]]:1: in import [InImport]
  172. // CHECK:STDERR: api.carbon:5:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  173. // CHECK:STDERR: fn B(b: i32) -> i32;
  174. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  175. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+32]]:1: in import [InImport]
  176. // CHECK:STDERR: extern_api.carbon:5:1: note: name is previously declared here [NameDeclPrevious]
  177. // CHECK:STDERR: extern library "redecl_extern_api" fn B(b: i32) -> i32;
  178. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. // CHECK:STDERR:
  180. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+27]]:1: in import [InImport]
  181. // CHECK:STDERR: api.carbon:6:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  182. // CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
  183. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  184. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+23]]:1: in import [InImport]
  185. // CHECK:STDERR: extern_api.carbon:6:1: note: name is previously declared here [NameDeclPrevious]
  186. // CHECK:STDERR: extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
  187. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  188. // CHECK:STDERR:
  189. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+18]]:1: in import [InImport]
  190. // CHECK:STDERR: api.carbon:7:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  191. // CHECK:STDERR: extern fn D();
  192. // CHECK:STDERR: ^~~~~~~~~~~~~~
  193. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+14]]:1: in import [InImport]
  194. // CHECK:STDERR: extern_api.carbon:7:1: note: name is previously declared here [NameDeclPrevious]
  195. // CHECK:STDERR: extern library "redecl_extern_api" fn D();
  196. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  197. // CHECK:STDERR:
  198. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+9]]:1: in import [InImport]
  199. // CHECK:STDERR: api.carbon:10:1: error: duplicate name being declared in the same scope [NameDeclDuplicate]
  200. // CHECK:STDERR: fn NS.E();
  201. // CHECK:STDERR: ^~~~~~~~~~
  202. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+5]]:1: in import [InImport]
  203. // CHECK:STDERR: extern_api.carbon:10:1: note: name is previously declared here [NameDeclPrevious]
  204. // CHECK:STDERR: extern library "redecl_extern_api" fn NS.E();
  205. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  206. // CHECK:STDERR:
  207. import library "extern_api";
  208. import library "api";
  209. var a: () = A();
  210. var b: i32 = B(1);
  211. var c: {.c: i32} = C((1,));
  212. var d: () = D();
  213. var e: () = NS.E();
  214. // --- unloaded.carbon
  215. library "[[@TEST_NAME]]";
  216. import library "api";
  217. // --- unloaded_extern.carbon
  218. library "[[@TEST_NAME]]";
  219. import library "extern_api";
  220. // CHECK:STDOUT: --- api.carbon
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: constants {
  223. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  224. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  225. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  226. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  227. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  228. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  229. // CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template]
  230. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
  231. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  232. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  233. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  234. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  235. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  236. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  237. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: imports {
  241. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  242. // CHECK:STDOUT: .Int = %Core.Int
  243. // CHECK:STDOUT: import Core//prelude
  244. // CHECK:STDOUT: import Core//prelude/...
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: file {
  249. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  250. // CHECK:STDOUT: .Core = imports.%Core
  251. // CHECK:STDOUT: .A = %A.decl
  252. // CHECK:STDOUT: .B = %B.decl
  253. // CHECK:STDOUT: .C = %C.decl
  254. // CHECK:STDOUT: .D = %D.decl
  255. // CHECK:STDOUT: .NS = %NS
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT: %Core.import = import Core
  258. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  259. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  260. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  261. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param0
  262. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  263. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  264. // CHECK:STDOUT: } {
  265. // CHECK:STDOUT: %int_32.loc5_17: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  266. // CHECK:STDOUT: %i32.loc5_17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  267. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  268. // CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5_9 [template = constants.%i32] {
  269. // CHECK:STDOUT: %int_32.loc5_9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  270. // CHECK:STDOUT: %i32.loc5_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  273. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  274. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  275. // CHECK:STDOUT: }
  276. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  277. // CHECK:STDOUT: %c.patt: %tuple.type.a1c = binding_pattern c
  278. // CHECK:STDOUT: %c.param_patt: %tuple.type.a1c = value_param_pattern %c.patt, runtime_param0
  279. // CHECK:STDOUT: %return.patt: %struct_type.c = return_slot_pattern
  280. // CHECK:STDOUT: %return.param_patt: %struct_type.c = out_param_pattern %return.patt, runtime_param1
  281. // CHECK:STDOUT: } {
  282. // CHECK:STDOUT: %int_32.loc6_25: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  283. // CHECK:STDOUT: %i32.loc6_25: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  284. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  285. // CHECK:STDOUT: %c.param: %tuple.type.a1c = value_param runtime_param0
  286. // CHECK:STDOUT: %.loc6_14.1: type = splice_block %.loc6_14.3 [template = constants.%tuple.type.a1c] {
  287. // CHECK:STDOUT: %int_32.loc6_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  288. // CHECK:STDOUT: %i32.loc6_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  289. // CHECK:STDOUT: %.loc6_14.2: %tuple.type.85c = tuple_literal (%i32.loc6_10)
  290. // CHECK:STDOUT: %.loc6_14.3: type = converted %.loc6_14.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c]
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT: %c: %tuple.type.a1c = bind_name c, %c.param
  293. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  294. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  297. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  298. // CHECK:STDOUT: .E = %E.decl
  299. // CHECK:STDOUT: }
  300. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: fn @A();
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32;
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.a1c) -> %struct_type.c;
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: extern fn @D();
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: fn @E();
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: --- extern_api.carbon
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: constants {
  316. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  317. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  318. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  319. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  320. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  321. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  322. // CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template]
  323. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
  324. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  325. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  326. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  327. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  328. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  329. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  330. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: imports {
  334. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  335. // CHECK:STDOUT: .Int = %Core.Int
  336. // CHECK:STDOUT: import Core//prelude
  337. // CHECK:STDOUT: import Core//prelude/...
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: file {
  342. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  343. // CHECK:STDOUT: .Core = imports.%Core
  344. // CHECK:STDOUT: .A = %A.decl
  345. // CHECK:STDOUT: .B = %B.decl
  346. // CHECK:STDOUT: .C = %C.decl
  347. // CHECK:STDOUT: .D = %D.decl
  348. // CHECK:STDOUT: .NS = %NS
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT: %Core.import = import Core
  351. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  352. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  353. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  354. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param0
  355. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  356. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  357. // CHECK:STDOUT: } {
  358. // CHECK:STDOUT: %int_32.loc5_52: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  359. // CHECK:STDOUT: %i32.loc5_52: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  360. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  361. // CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5_44 [template = constants.%i32] {
  362. // CHECK:STDOUT: %int_32.loc5_44: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  363. // CHECK:STDOUT: %i32.loc5_44: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  366. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  367. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  370. // CHECK:STDOUT: %c.patt: %tuple.type.a1c = binding_pattern c
  371. // CHECK:STDOUT: %c.param_patt: %tuple.type.a1c = value_param_pattern %c.patt, runtime_param0
  372. // CHECK:STDOUT: %return.patt: %struct_type.c = return_slot_pattern
  373. // CHECK:STDOUT: %return.param_patt: %struct_type.c = out_param_pattern %return.patt, runtime_param1
  374. // CHECK:STDOUT: } {
  375. // CHECK:STDOUT: %int_32.loc6_60: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  376. // CHECK:STDOUT: %i32.loc6_60: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  377. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  378. // CHECK:STDOUT: %c.param: %tuple.type.a1c = value_param runtime_param0
  379. // CHECK:STDOUT: %.loc6_49.1: type = splice_block %.loc6_49.3 [template = constants.%tuple.type.a1c] {
  380. // CHECK:STDOUT: %int_32.loc6_45: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  381. // CHECK:STDOUT: %i32.loc6_45: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  382. // CHECK:STDOUT: %.loc6_49.2: %tuple.type.85c = tuple_literal (%i32.loc6_45)
  383. // CHECK:STDOUT: %.loc6_49.3: type = converted %.loc6_49.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c]
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT: %c: %tuple.type.a1c = bind_name c, %c.param
  386. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  387. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  390. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  391. // CHECK:STDOUT: .E = %E.decl
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: extern fn @A();
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: extern fn @B(%b.param_patt: %i32) -> %i32;
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: extern fn @C(%c.param_patt: %tuple.type.a1c) -> %struct_type.c;
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: extern fn @D();
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: extern fn @E();
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: --- basics.carbon
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: constants {
  409. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  410. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  411. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  412. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  413. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  414. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  415. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  416. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  417. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  418. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  419. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  420. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  421. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  422. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  423. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  424. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  425. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  426. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  427. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  428. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  429. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  430. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
  431. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template]
  432. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_1.5d2) [template]
  433. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  434. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  435. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  436. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: imports {
  440. // CHECK:STDOUT: %Main.A: %A.type = import_ref Main//api, A, loaded [template = constants.%A]
  441. // CHECK:STDOUT: %Main.B: %B.type = import_ref Main//api, B, loaded [template = constants.%B]
  442. // CHECK:STDOUT: %Main.C: %C.type = import_ref Main//api, C, loaded [template = constants.%C]
  443. // CHECK:STDOUT: %Main.D: %D.type = import_ref Main//api, D, loaded [template = constants.%D]
  444. // CHECK:STDOUT: %Main.NS: <namespace> = import_ref Main//api, NS, loaded
  445. // CHECK:STDOUT: %NS: <namespace> = namespace %Main.NS, [template] {
  446. // CHECK:STDOUT: .E = %Main.E
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT: %Main.E: %E.type = import_ref Main//api, E, loaded [template = constants.%E]
  449. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  450. // CHECK:STDOUT: .Int = %Core.Int
  451. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  452. // CHECK:STDOUT: import Core//prelude
  453. // CHECK:STDOUT: import Core//prelude/...
  454. // CHECK:STDOUT: }
  455. // CHECK:STDOUT: }
  456. // CHECK:STDOUT:
  457. // CHECK:STDOUT: file {
  458. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  459. // CHECK:STDOUT: .A = imports.%Main.A
  460. // CHECK:STDOUT: .B = imports.%Main.B
  461. // CHECK:STDOUT: .C = imports.%Main.C
  462. // CHECK:STDOUT: .D = imports.%Main.D
  463. // CHECK:STDOUT: .NS = imports.%NS
  464. // CHECK:STDOUT: .Core = imports.%Core
  465. // CHECK:STDOUT: .a = %a
  466. // CHECK:STDOUT: .b = %b
  467. // CHECK:STDOUT: .c = %c
  468. // CHECK:STDOUT: .d = %d
  469. // CHECK:STDOUT: .e = %e
  470. // CHECK:STDOUT: }
  471. // CHECK:STDOUT: %Core.import = import Core
  472. // CHECK:STDOUT: %default.import = import <none>
  473. // CHECK:STDOUT: name_binding_decl {
  474. // CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
  475. // CHECK:STDOUT: %.loc6_1: %empty_tuple.type = var_pattern %a.patt
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  478. // CHECK:STDOUT: %.loc6_9.1: type = splice_block %.loc6_9.3 [template = constants.%empty_tuple.type] {
  479. // CHECK:STDOUT: %.loc6_9.2: %empty_tuple.type = tuple_literal ()
  480. // CHECK:STDOUT: %.loc6_9.3: type = converted %.loc6_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  483. // CHECK:STDOUT: name_binding_decl {
  484. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  485. // CHECK:STDOUT: %.loc7_1: %i32 = var_pattern %b.patt
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT: %b.var: ref %i32 = var b
  488. // CHECK:STDOUT: %.loc7_8: type = splice_block %i32.loc7 [template = constants.%i32] {
  489. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  490. // CHECK:STDOUT: %i32.loc7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  493. // CHECK:STDOUT: name_binding_decl {
  494. // CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c
  495. // CHECK:STDOUT: %.loc8_1: %struct_type.c = var_pattern %c.patt
  496. // CHECK:STDOUT: }
  497. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  498. // CHECK:STDOUT: %.loc8_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] {
  499. // CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  500. // CHECK:STDOUT: %i32.loc8: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  501. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  504. // CHECK:STDOUT: name_binding_decl {
  505. // CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d
  506. // CHECK:STDOUT: %.loc9_1: %empty_tuple.type = var_pattern %d.patt
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  509. // CHECK:STDOUT: %.loc9_9.1: type = splice_block %.loc9_9.3 [template = constants.%empty_tuple.type] {
  510. // CHECK:STDOUT: %.loc9_9.2: %empty_tuple.type = tuple_literal ()
  511. // CHECK:STDOUT: %.loc9_9.3: type = converted %.loc9_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  512. // CHECK:STDOUT: }
  513. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  514. // CHECK:STDOUT: name_binding_decl {
  515. // CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e
  516. // CHECK:STDOUT: %.loc10_1: %empty_tuple.type = var_pattern %e.patt
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  519. // CHECK:STDOUT: %.loc10_9.1: type = splice_block %.loc10_9.3 [template = constants.%empty_tuple.type] {
  520. // CHECK:STDOUT: %.loc10_9.2: %empty_tuple.type = tuple_literal ()
  521. // CHECK:STDOUT: %.loc10_9.3: type = converted %.loc10_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  522. // CHECK:STDOUT: }
  523. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  524. // CHECK:STDOUT: }
  525. // CHECK:STDOUT:
  526. // CHECK:STDOUT: fn @A() [from "api.carbon"];
  527. // CHECK:STDOUT:
  528. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32 [from "api.carbon"];
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.a1c) -> %struct_type.c [from "api.carbon"];
  531. // CHECK:STDOUT:
  532. // CHECK:STDOUT: extern fn @D() [from "api.carbon"];
  533. // CHECK:STDOUT:
  534. // CHECK:STDOUT: fn @E() [from "api.carbon"];
  535. // CHECK:STDOUT:
  536. // CHECK:STDOUT: fn @__global_init() {
  537. // CHECK:STDOUT: !entry:
  538. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%Main.A [template = constants.%A]
  539. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  540. // CHECK:STDOUT: assign file.%a.var, %A.call
  541. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%Main.B [template = constants.%B]
  542. // CHECK:STDOUT: %int_1.loc7: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  543. // CHECK:STDOUT: %impl.elem0.loc7: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  544. // CHECK:STDOUT: %bound_method.loc7: <bound method> = bound_method %int_1.loc7, %impl.elem0.loc7 [template = constants.%Convert.bound]
  545. // CHECK:STDOUT: %specific_fn.loc7: <specific function> = specific_function %bound_method.loc7, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  546. // CHECK:STDOUT: %int.convert_checked.loc7: init %i32 = call %specific_fn.loc7(%int_1.loc7) [template = constants.%int_1.5d2]
  547. // CHECK:STDOUT: %.loc7_16.1: %i32 = value_of_initializer %int.convert_checked.loc7 [template = constants.%int_1.5d2]
  548. // CHECK:STDOUT: %.loc7_16.2: %i32 = converted %int_1.loc7, %.loc7_16.1 [template = constants.%int_1.5d2]
  549. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc7_16.2)
  550. // CHECK:STDOUT: assign file.%b.var, %B.call
  551. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [template = constants.%C]
  552. // CHECK:STDOUT: %int_1.loc8: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  553. // CHECK:STDOUT: %.loc8_25.1: %tuple.type.985 = tuple_literal (%int_1.loc8)
  554. // CHECK:STDOUT: %impl.elem0.loc8: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  555. // CHECK:STDOUT: %bound_method.loc8: <bound method> = bound_method %int_1.loc8, %impl.elem0.loc8 [template = constants.%Convert.bound]
  556. // CHECK:STDOUT: %specific_fn.loc8: <specific function> = specific_function %bound_method.loc8, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  557. // CHECK:STDOUT: %int.convert_checked.loc8: init %i32 = call %specific_fn.loc8(%int_1.loc8) [template = constants.%int_1.5d2]
  558. // CHECK:STDOUT: %.loc8_25.2: %i32 = value_of_initializer %int.convert_checked.loc8 [template = constants.%int_1.5d2]
  559. // CHECK:STDOUT: %.loc8_25.3: %i32 = converted %int_1.loc8, %.loc8_25.2 [template = constants.%int_1.5d2]
  560. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%.loc8_25.3) [template = constants.%tuple]
  561. // CHECK:STDOUT: %.loc8_25.4: %tuple.type.a1c = converted %.loc8_25.1, %tuple [template = constants.%tuple]
  562. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc8_25.4)
  563. // CHECK:STDOUT: assign file.%c.var, %C.call
  564. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%Main.D [template = constants.%D]
  565. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  566. // CHECK:STDOUT: assign file.%d.var, %D.call
  567. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  568. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%Main.E [template = constants.%E]
  569. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  570. // CHECK:STDOUT: assign file.%e.var, %E.call
  571. // CHECK:STDOUT: return
  572. // CHECK:STDOUT: }
  573. // CHECK:STDOUT:
  574. // CHECK:STDOUT: --- fail_redecl_api.carbon
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: constants {
  577. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  578. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  579. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  580. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  581. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  582. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  583. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  584. // CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template]
  585. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
  586. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  587. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  588. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  589. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  590. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  591. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  592. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  593. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  594. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  595. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  596. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  597. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  598. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  599. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  600. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  601. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  602. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  603. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  604. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template]
  605. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_1.5d2) [template]
  606. // CHECK:STDOUT: }
  607. // CHECK:STDOUT:
  608. // CHECK:STDOUT: imports {
  609. // CHECK:STDOUT: %Main.NS: <namespace> = import_ref Main//api, NS, loaded
  610. // CHECK:STDOUT: %NS: <namespace> = namespace %Main.NS, [template] {
  611. // CHECK:STDOUT: .E = file.%E.decl
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  614. // CHECK:STDOUT: .Int = %Core.Int
  615. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  616. // CHECK:STDOUT: import Core//prelude
  617. // CHECK:STDOUT: import Core//prelude/...
  618. // CHECK:STDOUT: }
  619. // CHECK:STDOUT: }
  620. // CHECK:STDOUT:
  621. // CHECK:STDOUT: file {
  622. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  623. // CHECK:STDOUT: .A = %A.decl
  624. // CHECK:STDOUT: .B = %B.decl
  625. // CHECK:STDOUT: .C = %C.decl
  626. // CHECK:STDOUT: .D = %D.decl
  627. // CHECK:STDOUT: .NS = imports.%NS
  628. // CHECK:STDOUT: .Core = imports.%Core
  629. // CHECK:STDOUT: .a = %a
  630. // CHECK:STDOUT: .b = %b
  631. // CHECK:STDOUT: .c = %c
  632. // CHECK:STDOUT: .d = %d
  633. // CHECK:STDOUT: .e = %e
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT: %Core.import = import Core
  636. // CHECK:STDOUT: %default.import = import <none>
  637. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  638. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {
  639. // CHECK:STDOUT: %int_32.loc23_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  640. // CHECK:STDOUT: %i32.loc23_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  641. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  642. // CHECK:STDOUT: %.loc23: type = splice_block %i32.loc23_16 [template = constants.%i32] {
  643. // CHECK:STDOUT: %int_32.loc23_16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  644. // CHECK:STDOUT: %i32.loc23_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  645. // CHECK:STDOUT: }
  646. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  647. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  648. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  649. // CHECK:STDOUT: }
  650. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} {
  651. // CHECK:STDOUT: %int_32.loc32_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  652. // CHECK:STDOUT: %i32.loc32_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  653. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  654. // CHECK:STDOUT: %c.param: %tuple.type.a1c = value_param runtime_param0
  655. // CHECK:STDOUT: %.loc32_21.1: type = splice_block %.loc32_21.3 [template = constants.%tuple.type.a1c] {
  656. // CHECK:STDOUT: %int_32.loc32_17: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  657. // CHECK:STDOUT: %i32.loc32_17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  658. // CHECK:STDOUT: %.loc32_21.2: %tuple.type.85c = tuple_literal (%i32.loc32_17)
  659. // CHECK:STDOUT: %.loc32_21.3: type = converted %.loc32_21.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c]
  660. // CHECK:STDOUT: }
  661. // CHECK:STDOUT: %c: %tuple.type.a1c = bind_name c, %c.param
  662. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  663. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  664. // CHECK:STDOUT: }
  665. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  666. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  667. // CHECK:STDOUT: name_binding_decl {
  668. // CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
  669. // CHECK:STDOUT: %.loc52_1: %empty_tuple.type = var_pattern %a.patt
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  672. // CHECK:STDOUT: %.loc52_9.1: type = splice_block %.loc52_9.3 [template = constants.%empty_tuple.type] {
  673. // CHECK:STDOUT: %.loc52_9.2: %empty_tuple.type = tuple_literal ()
  674. // CHECK:STDOUT: %.loc52_9.3: type = converted %.loc52_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  675. // CHECK:STDOUT: }
  676. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  677. // CHECK:STDOUT: name_binding_decl {
  678. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  679. // CHECK:STDOUT: %.loc53_1: %i32 = var_pattern %b.patt
  680. // CHECK:STDOUT: }
  681. // CHECK:STDOUT: %b.var: ref %i32 = var b
  682. // CHECK:STDOUT: %.loc53_8: type = splice_block %i32.loc53 [template = constants.%i32] {
  683. // CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  684. // CHECK:STDOUT: %i32.loc53: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  685. // CHECK:STDOUT: }
  686. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  687. // CHECK:STDOUT: name_binding_decl {
  688. // CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c
  689. // CHECK:STDOUT: %.loc54_1: %struct_type.c = var_pattern %c.patt
  690. // CHECK:STDOUT: }
  691. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  692. // CHECK:STDOUT: %.loc54_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] {
  693. // CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  694. // CHECK:STDOUT: %i32.loc54: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  695. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  696. // CHECK:STDOUT: }
  697. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  698. // CHECK:STDOUT: name_binding_decl {
  699. // CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d
  700. // CHECK:STDOUT: %.loc55_1: %empty_tuple.type = var_pattern %d.patt
  701. // CHECK:STDOUT: }
  702. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  703. // CHECK:STDOUT: %.loc55_9.1: type = splice_block %.loc55_9.3 [template = constants.%empty_tuple.type] {
  704. // CHECK:STDOUT: %.loc55_9.2: %empty_tuple.type = tuple_literal ()
  705. // CHECK:STDOUT: %.loc55_9.3: type = converted %.loc55_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  706. // CHECK:STDOUT: }
  707. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  708. // CHECK:STDOUT: name_binding_decl {
  709. // CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e
  710. // CHECK:STDOUT: %.loc56_1: %empty_tuple.type = var_pattern %e.patt
  711. // CHECK:STDOUT: }
  712. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  713. // CHECK:STDOUT: %.loc56_9.1: type = splice_block %.loc56_9.3 [template = constants.%empty_tuple.type] {
  714. // CHECK:STDOUT: %.loc56_9.2: %empty_tuple.type = tuple_literal ()
  715. // CHECK:STDOUT: %.loc56_9.3: type = converted %.loc56_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  716. // CHECK:STDOUT: }
  717. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  718. // CHECK:STDOUT: }
  719. // CHECK:STDOUT:
  720. // CHECK:STDOUT: fn @A() [from "api.carbon"];
  721. // CHECK:STDOUT:
  722. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32 [from "api.carbon"];
  723. // CHECK:STDOUT:
  724. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.a1c) -> %struct_type.c [from "api.carbon"];
  725. // CHECK:STDOUT:
  726. // CHECK:STDOUT: extern fn @D() [from "api.carbon"];
  727. // CHECK:STDOUT:
  728. // CHECK:STDOUT: fn @E() [from "api.carbon"];
  729. // CHECK:STDOUT:
  730. // CHECK:STDOUT: fn @__global_init() {
  731. // CHECK:STDOUT: !entry:
  732. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  733. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  734. // CHECK:STDOUT: assign file.%a.var, %A.call
  735. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  736. // CHECK:STDOUT: %int_1.loc53: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  737. // CHECK:STDOUT: %impl.elem0.loc53: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  738. // CHECK:STDOUT: %bound_method.loc53: <bound method> = bound_method %int_1.loc53, %impl.elem0.loc53 [template = constants.%Convert.bound]
  739. // CHECK:STDOUT: %specific_fn.loc53: <specific function> = specific_function %bound_method.loc53, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  740. // CHECK:STDOUT: %int.convert_checked.loc53: init %i32 = call %specific_fn.loc53(%int_1.loc53) [template = constants.%int_1.5d2]
  741. // CHECK:STDOUT: %.loc53_16.1: %i32 = value_of_initializer %int.convert_checked.loc53 [template = constants.%int_1.5d2]
  742. // CHECK:STDOUT: %.loc53_16.2: %i32 = converted %int_1.loc53, %.loc53_16.1 [template = constants.%int_1.5d2]
  743. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc53_16.2)
  744. // CHECK:STDOUT: assign file.%b.var, %B.call
  745. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  746. // CHECK:STDOUT: %int_1.loc54: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  747. // CHECK:STDOUT: %.loc54_25.1: %tuple.type.985 = tuple_literal (%int_1.loc54)
  748. // CHECK:STDOUT: %impl.elem0.loc54: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  749. // CHECK:STDOUT: %bound_method.loc54: <bound method> = bound_method %int_1.loc54, %impl.elem0.loc54 [template = constants.%Convert.bound]
  750. // CHECK:STDOUT: %specific_fn.loc54: <specific function> = specific_function %bound_method.loc54, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  751. // CHECK:STDOUT: %int.convert_checked.loc54: init %i32 = call %specific_fn.loc54(%int_1.loc54) [template = constants.%int_1.5d2]
  752. // CHECK:STDOUT: %.loc54_25.2: %i32 = value_of_initializer %int.convert_checked.loc54 [template = constants.%int_1.5d2]
  753. // CHECK:STDOUT: %.loc54_25.3: %i32 = converted %int_1.loc54, %.loc54_25.2 [template = constants.%int_1.5d2]
  754. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%.loc54_25.3) [template = constants.%tuple]
  755. // CHECK:STDOUT: %.loc54_25.4: %tuple.type.a1c = converted %.loc54_25.1, %tuple [template = constants.%tuple]
  756. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc54_25.4)
  757. // CHECK:STDOUT: assign file.%c.var, %C.call
  758. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  759. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  760. // CHECK:STDOUT: assign file.%d.var, %D.call
  761. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  762. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  763. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  764. // CHECK:STDOUT: assign file.%e.var, %E.call
  765. // CHECK:STDOUT: return
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT:
  768. // CHECK:STDOUT: --- redecl_extern_api.carbon
  769. // CHECK:STDOUT:
  770. // CHECK:STDOUT: constants {
  771. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  772. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  773. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  774. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  775. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  776. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  777. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  778. // CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [template]
  779. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
  780. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  781. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  782. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  783. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  784. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  785. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  786. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  787. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  788. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  789. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  790. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  791. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  792. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  793. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  794. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  795. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  796. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  797. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  798. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template]
  799. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_1.5d2) [template]
  800. // CHECK:STDOUT: }
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: imports {
  803. // CHECK:STDOUT: %Main.NS: <namespace> = import_ref Main//extern_api, NS, loaded
  804. // CHECK:STDOUT: %NS: <namespace> = namespace %Main.NS, [template] {
  805. // CHECK:STDOUT: .E = file.%E.decl
  806. // CHECK:STDOUT: }
  807. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  808. // CHECK:STDOUT: .Int = %Core.Int
  809. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  810. // CHECK:STDOUT: import Core//prelude
  811. // CHECK:STDOUT: import Core//prelude/...
  812. // CHECK:STDOUT: }
  813. // CHECK:STDOUT: }
  814. // CHECK:STDOUT:
  815. // CHECK:STDOUT: file {
  816. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  817. // CHECK:STDOUT: .A = %A.decl
  818. // CHECK:STDOUT: .B = %B.decl
  819. // CHECK:STDOUT: .C = %C.decl
  820. // CHECK:STDOUT: .D = %D.decl
  821. // CHECK:STDOUT: .NS = imports.%NS
  822. // CHECK:STDOUT: .Core = imports.%Core
  823. // CHECK:STDOUT: .a = %a
  824. // CHECK:STDOUT: .b = %b
  825. // CHECK:STDOUT: .c = %c
  826. // CHECK:STDOUT: .d = %d
  827. // CHECK:STDOUT: .e = %e
  828. // CHECK:STDOUT: }
  829. // CHECK:STDOUT: %Core.import = import Core
  830. // CHECK:STDOUT: %default.import = import <none>
  831. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  832. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {
  833. // CHECK:STDOUT: %int_32.loc7_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  834. // CHECK:STDOUT: %i32.loc7_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  835. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  836. // CHECK:STDOUT: %.loc7: type = splice_block %i32.loc7_16 [template = constants.%i32] {
  837. // CHECK:STDOUT: %int_32.loc7_16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  838. // CHECK:STDOUT: %i32.loc7_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  839. // CHECK:STDOUT: }
  840. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  841. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  842. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  843. // CHECK:STDOUT: }
  844. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} {
  845. // CHECK:STDOUT: %int_32.loc8_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  846. // CHECK:STDOUT: %i32.loc8_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  847. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  848. // CHECK:STDOUT: %c.param: %tuple.type.a1c = value_param runtime_param0
  849. // CHECK:STDOUT: %.loc8_21.1: type = splice_block %.loc8_21.3 [template = constants.%tuple.type.a1c] {
  850. // CHECK:STDOUT: %int_32.loc8_17: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  851. // CHECK:STDOUT: %i32.loc8_17: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  852. // CHECK:STDOUT: %.loc8_21.2: %tuple.type.85c = tuple_literal (%i32.loc8_17)
  853. // CHECK:STDOUT: %.loc8_21.3: type = converted %.loc8_21.2, constants.%tuple.type.a1c [template = constants.%tuple.type.a1c]
  854. // CHECK:STDOUT: }
  855. // CHECK:STDOUT: %c: %tuple.type.a1c = bind_name c, %c.param
  856. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  857. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  858. // CHECK:STDOUT: }
  859. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  860. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  861. // CHECK:STDOUT: name_binding_decl {
  862. // CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
  863. // CHECK:STDOUT: %.loc12_1: %empty_tuple.type = var_pattern %a.patt
  864. // CHECK:STDOUT: }
  865. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  866. // CHECK:STDOUT: %.loc12_9.1: type = splice_block %.loc12_9.3 [template = constants.%empty_tuple.type] {
  867. // CHECK:STDOUT: %.loc12_9.2: %empty_tuple.type = tuple_literal ()
  868. // CHECK:STDOUT: %.loc12_9.3: type = converted %.loc12_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  869. // CHECK:STDOUT: }
  870. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  871. // CHECK:STDOUT: name_binding_decl {
  872. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  873. // CHECK:STDOUT: %.loc13_1: %i32 = var_pattern %b.patt
  874. // CHECK:STDOUT: }
  875. // CHECK:STDOUT: %b.var: ref %i32 = var b
  876. // CHECK:STDOUT: %.loc13_8: type = splice_block %i32.loc13 [template = constants.%i32] {
  877. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  878. // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  879. // CHECK:STDOUT: }
  880. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  881. // CHECK:STDOUT: name_binding_decl {
  882. // CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c
  883. // CHECK:STDOUT: %.loc14_1: %struct_type.c = var_pattern %c.patt
  884. // CHECK:STDOUT: }
  885. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  886. // CHECK:STDOUT: %.loc14_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] {
  887. // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  888. // CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  889. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  890. // CHECK:STDOUT: }
  891. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  892. // CHECK:STDOUT: name_binding_decl {
  893. // CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d
  894. // CHECK:STDOUT: %.loc15_1: %empty_tuple.type = var_pattern %d.patt
  895. // CHECK:STDOUT: }
  896. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  897. // CHECK:STDOUT: %.loc15_9.1: type = splice_block %.loc15_9.3 [template = constants.%empty_tuple.type] {
  898. // CHECK:STDOUT: %.loc15_9.2: %empty_tuple.type = tuple_literal ()
  899. // CHECK:STDOUT: %.loc15_9.3: type = converted %.loc15_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  900. // CHECK:STDOUT: }
  901. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  902. // CHECK:STDOUT: name_binding_decl {
  903. // CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e
  904. // CHECK:STDOUT: %.loc16_1: %empty_tuple.type = var_pattern %e.patt
  905. // CHECK:STDOUT: }
  906. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  907. // CHECK:STDOUT: %.loc16_9.1: type = splice_block %.loc16_9.3 [template = constants.%empty_tuple.type] {
  908. // CHECK:STDOUT: %.loc16_9.2: %empty_tuple.type = tuple_literal ()
  909. // CHECK:STDOUT: %.loc16_9.3: type = converted %.loc16_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  910. // CHECK:STDOUT: }
  911. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  912. // CHECK:STDOUT: }
  913. // CHECK:STDOUT:
  914. // CHECK:STDOUT: extern fn @A();
  915. // CHECK:STDOUT:
  916. // CHECK:STDOUT: extern fn @B(%b.param_patt: %i32) -> %i32;
  917. // CHECK:STDOUT:
  918. // CHECK:STDOUT: extern fn @C(%c.param_patt: %tuple.type.a1c) -> %struct_type.c;
  919. // CHECK:STDOUT:
  920. // CHECK:STDOUT: extern fn @D();
  921. // CHECK:STDOUT:
  922. // CHECK:STDOUT: extern fn @E();
  923. // CHECK:STDOUT:
  924. // CHECK:STDOUT: fn @__global_init() {
  925. // CHECK:STDOUT: !entry:
  926. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  927. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  928. // CHECK:STDOUT: assign file.%a.var, %A.call
  929. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  930. // CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  931. // CHECK:STDOUT: %impl.elem0.loc13: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  932. // CHECK:STDOUT: %bound_method.loc13: <bound method> = bound_method %int_1.loc13, %impl.elem0.loc13 [template = constants.%Convert.bound]
  933. // CHECK:STDOUT: %specific_fn.loc13: <specific function> = specific_function %bound_method.loc13, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  934. // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %specific_fn.loc13(%int_1.loc13) [template = constants.%int_1.5d2]
  935. // CHECK:STDOUT: %.loc13_16.1: %i32 = value_of_initializer %int.convert_checked.loc13 [template = constants.%int_1.5d2]
  936. // CHECK:STDOUT: %.loc13_16.2: %i32 = converted %int_1.loc13, %.loc13_16.1 [template = constants.%int_1.5d2]
  937. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc13_16.2)
  938. // CHECK:STDOUT: assign file.%b.var, %B.call
  939. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  940. // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  941. // CHECK:STDOUT: %.loc14_25.1: %tuple.type.985 = tuple_literal (%int_1.loc14)
  942. // CHECK:STDOUT: %impl.elem0.loc14: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  943. // CHECK:STDOUT: %bound_method.loc14: <bound method> = bound_method %int_1.loc14, %impl.elem0.loc14 [template = constants.%Convert.bound]
  944. // CHECK:STDOUT: %specific_fn.loc14: <specific function> = specific_function %bound_method.loc14, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  945. // CHECK:STDOUT: %int.convert_checked.loc14: init %i32 = call %specific_fn.loc14(%int_1.loc14) [template = constants.%int_1.5d2]
  946. // CHECK:STDOUT: %.loc14_25.2: %i32 = value_of_initializer %int.convert_checked.loc14 [template = constants.%int_1.5d2]
  947. // CHECK:STDOUT: %.loc14_25.3: %i32 = converted %int_1.loc14, %.loc14_25.2 [template = constants.%int_1.5d2]
  948. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%.loc14_25.3) [template = constants.%tuple]
  949. // CHECK:STDOUT: %.loc14_25.4: %tuple.type.a1c = converted %.loc14_25.1, %tuple [template = constants.%tuple]
  950. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc14_25.4)
  951. // CHECK:STDOUT: assign file.%c.var, %C.call
  952. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  953. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  954. // CHECK:STDOUT: assign file.%d.var, %D.call
  955. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  956. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  957. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  958. // CHECK:STDOUT: assign file.%e.var, %E.call
  959. // CHECK:STDOUT: return
  960. // CHECK:STDOUT: }
  961. // CHECK:STDOUT:
  962. // CHECK:STDOUT: --- fail_merge.carbon
  963. // CHECK:STDOUT:
  964. // CHECK:STDOUT: constants {
  965. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  966. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  967. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  968. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  969. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  970. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  971. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  972. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  973. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  974. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  975. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  976. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  977. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  978. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  979. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  980. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  981. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  982. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  983. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  984. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  985. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  986. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
  987. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template]
  988. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_1.5d2) [template]
  989. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  990. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  991. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  992. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  993. // CHECK:STDOUT: }
  994. // CHECK:STDOUT:
  995. // CHECK:STDOUT: imports {
  996. // CHECK:STDOUT: %Main.A: %A.type = import_ref Main//api, A, loaded [template = constants.%A]
  997. // CHECK:STDOUT: %Main.B: %B.type = import_ref Main//api, B, loaded [template = constants.%B]
  998. // CHECK:STDOUT: %Main.C: %C.type = import_ref Main//api, C, loaded [template = constants.%C]
  999. // CHECK:STDOUT: %Main.D: %D.type = import_ref Main//api, D, loaded [template = constants.%D]
  1000. // CHECK:STDOUT: %Main.NS: <namespace> = import_ref Main//api, NS, loaded
  1001. // CHECK:STDOUT: %NS: <namespace> = namespace %Main.NS, [template] {
  1002. // CHECK:STDOUT: .E = %Main.E
  1003. // CHECK:STDOUT: }
  1004. // CHECK:STDOUT: %Main.E: %E.type = import_ref Main//api, E, loaded [template = constants.%E]
  1005. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1006. // CHECK:STDOUT: .Int = %Core.Int
  1007. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1008. // CHECK:STDOUT: import Core//prelude
  1009. // CHECK:STDOUT: import Core//prelude/...
  1010. // CHECK:STDOUT: }
  1011. // CHECK:STDOUT: }
  1012. // CHECK:STDOUT:
  1013. // CHECK:STDOUT: file {
  1014. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1015. // CHECK:STDOUT: .A = imports.%Main.A
  1016. // CHECK:STDOUT: .B = imports.%Main.B
  1017. // CHECK:STDOUT: .C = imports.%Main.C
  1018. // CHECK:STDOUT: .D = imports.%Main.D
  1019. // CHECK:STDOUT: .NS = imports.%NS
  1020. // CHECK:STDOUT: .Core = imports.%Core
  1021. // CHECK:STDOUT: .a = %a
  1022. // CHECK:STDOUT: .b = %b
  1023. // CHECK:STDOUT: .c = %c
  1024. // CHECK:STDOUT: .d = %d
  1025. // CHECK:STDOUT: .e = %e
  1026. // CHECK:STDOUT: }
  1027. // CHECK:STDOUT: %Core.import = import Core
  1028. // CHECK:STDOUT: %default.import = import <none>
  1029. // CHECK:STDOUT: name_binding_decl {
  1030. // CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
  1031. // CHECK:STDOUT: %.loc52_1: %empty_tuple.type = var_pattern %a.patt
  1032. // CHECK:STDOUT: }
  1033. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  1034. // CHECK:STDOUT: %.loc52_9.1: type = splice_block %.loc52_9.3 [template = constants.%empty_tuple.type] {
  1035. // CHECK:STDOUT: %.loc52_9.2: %empty_tuple.type = tuple_literal ()
  1036. // CHECK:STDOUT: %.loc52_9.3: type = converted %.loc52_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1037. // CHECK:STDOUT: }
  1038. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  1039. // CHECK:STDOUT: name_binding_decl {
  1040. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  1041. // CHECK:STDOUT: %.loc53_1: %i32 = var_pattern %b.patt
  1042. // CHECK:STDOUT: }
  1043. // CHECK:STDOUT: %b.var: ref %i32 = var b
  1044. // CHECK:STDOUT: %.loc53_8: type = splice_block %i32.loc53 [template = constants.%i32] {
  1045. // CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1046. // CHECK:STDOUT: %i32.loc53: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1047. // CHECK:STDOUT: }
  1048. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  1049. // CHECK:STDOUT: name_binding_decl {
  1050. // CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c
  1051. // CHECK:STDOUT: %.loc54_1: %struct_type.c = var_pattern %c.patt
  1052. // CHECK:STDOUT: }
  1053. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  1054. // CHECK:STDOUT: %.loc54_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] {
  1055. // CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1056. // CHECK:STDOUT: %i32.loc54: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1057. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  1058. // CHECK:STDOUT: }
  1059. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  1060. // CHECK:STDOUT: name_binding_decl {
  1061. // CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d
  1062. // CHECK:STDOUT: %.loc55_1: %empty_tuple.type = var_pattern %d.patt
  1063. // CHECK:STDOUT: }
  1064. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  1065. // CHECK:STDOUT: %.loc55_9.1: type = splice_block %.loc55_9.3 [template = constants.%empty_tuple.type] {
  1066. // CHECK:STDOUT: %.loc55_9.2: %empty_tuple.type = tuple_literal ()
  1067. // CHECK:STDOUT: %.loc55_9.3: type = converted %.loc55_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1068. // CHECK:STDOUT: }
  1069. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  1070. // CHECK:STDOUT: name_binding_decl {
  1071. // CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e
  1072. // CHECK:STDOUT: %.loc56_1: %empty_tuple.type = var_pattern %e.patt
  1073. // CHECK:STDOUT: }
  1074. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  1075. // CHECK:STDOUT: %.loc56_9.1: type = splice_block %.loc56_9.3 [template = constants.%empty_tuple.type] {
  1076. // CHECK:STDOUT: %.loc56_9.2: %empty_tuple.type = tuple_literal ()
  1077. // CHECK:STDOUT: %.loc56_9.3: type = converted %.loc56_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1078. // CHECK:STDOUT: }
  1079. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  1080. // CHECK:STDOUT: }
  1081. // CHECK:STDOUT:
  1082. // CHECK:STDOUT: fn @A() [from "api.carbon"];
  1083. // CHECK:STDOUT:
  1084. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32 [from "api.carbon"];
  1085. // CHECK:STDOUT:
  1086. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.a1c) -> %struct_type.c [from "api.carbon"];
  1087. // CHECK:STDOUT:
  1088. // CHECK:STDOUT: extern fn @D() [from "api.carbon"];
  1089. // CHECK:STDOUT:
  1090. // CHECK:STDOUT: fn @E() [from "api.carbon"];
  1091. // CHECK:STDOUT:
  1092. // CHECK:STDOUT: fn @__global_init() {
  1093. // CHECK:STDOUT: !entry:
  1094. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%Main.A [template = constants.%A]
  1095. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  1096. // CHECK:STDOUT: assign file.%a.var, %A.call
  1097. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%Main.B [template = constants.%B]
  1098. // CHECK:STDOUT: %int_1.loc53: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  1099. // CHECK:STDOUT: %impl.elem0.loc53: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  1100. // CHECK:STDOUT: %bound_method.loc53: <bound method> = bound_method %int_1.loc53, %impl.elem0.loc53 [template = constants.%Convert.bound]
  1101. // CHECK:STDOUT: %specific_fn.loc53: <specific function> = specific_function %bound_method.loc53, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1102. // CHECK:STDOUT: %int.convert_checked.loc53: init %i32 = call %specific_fn.loc53(%int_1.loc53) [template = constants.%int_1.5d2]
  1103. // CHECK:STDOUT: %.loc53_16.1: %i32 = value_of_initializer %int.convert_checked.loc53 [template = constants.%int_1.5d2]
  1104. // CHECK:STDOUT: %.loc53_16.2: %i32 = converted %int_1.loc53, %.loc53_16.1 [template = constants.%int_1.5d2]
  1105. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc53_16.2)
  1106. // CHECK:STDOUT: assign file.%b.var, %B.call
  1107. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [template = constants.%C]
  1108. // CHECK:STDOUT: %int_1.loc54: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  1109. // CHECK:STDOUT: %.loc54_25.1: %tuple.type.985 = tuple_literal (%int_1.loc54)
  1110. // CHECK:STDOUT: %impl.elem0.loc54: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  1111. // CHECK:STDOUT: %bound_method.loc54: <bound method> = bound_method %int_1.loc54, %impl.elem0.loc54 [template = constants.%Convert.bound]
  1112. // CHECK:STDOUT: %specific_fn.loc54: <specific function> = specific_function %bound_method.loc54, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1113. // CHECK:STDOUT: %int.convert_checked.loc54: init %i32 = call %specific_fn.loc54(%int_1.loc54) [template = constants.%int_1.5d2]
  1114. // CHECK:STDOUT: %.loc54_25.2: %i32 = value_of_initializer %int.convert_checked.loc54 [template = constants.%int_1.5d2]
  1115. // CHECK:STDOUT: %.loc54_25.3: %i32 = converted %int_1.loc54, %.loc54_25.2 [template = constants.%int_1.5d2]
  1116. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%.loc54_25.3) [template = constants.%tuple]
  1117. // CHECK:STDOUT: %.loc54_25.4: %tuple.type.a1c = converted %.loc54_25.1, %tuple [template = constants.%tuple]
  1118. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc54_25.4)
  1119. // CHECK:STDOUT: assign file.%c.var, %C.call
  1120. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%Main.D [template = constants.%D]
  1121. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  1122. // CHECK:STDOUT: assign file.%d.var, %D.call
  1123. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  1124. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%Main.E [template = constants.%E]
  1125. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  1126. // CHECK:STDOUT: assign file.%e.var, %E.call
  1127. // CHECK:STDOUT: return
  1128. // CHECK:STDOUT: }
  1129. // CHECK:STDOUT:
  1130. // CHECK:STDOUT: --- fail_merge_reverse.carbon
  1131. // CHECK:STDOUT:
  1132. // CHECK:STDOUT: constants {
  1133. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  1134. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  1135. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  1136. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  1137. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  1138. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  1139. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  1140. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  1141. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  1142. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  1143. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  1144. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  1145. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  1146. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  1147. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  1148. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  1149. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  1150. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  1151. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  1152. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  1153. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  1154. // CHECK:STDOUT: %tuple.type.a1c: type = tuple_type (%i32) [template]
  1155. // CHECK:STDOUT: %tuple.type.985: type = tuple_type (Core.IntLiteral) [template]
  1156. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%int_1.5d2) [template]
  1157. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  1158. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  1159. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  1160. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  1161. // CHECK:STDOUT: }
  1162. // CHECK:STDOUT:
  1163. // CHECK:STDOUT: imports {
  1164. // CHECK:STDOUT: %Main.A: %A.type = import_ref Main//extern_api, A, loaded [template = constants.%A]
  1165. // CHECK:STDOUT: %Main.B: %B.type = import_ref Main//extern_api, B, loaded [template = constants.%B]
  1166. // CHECK:STDOUT: %Main.C: %C.type = import_ref Main//extern_api, C, loaded [template = constants.%C]
  1167. // CHECK:STDOUT: %Main.D: %D.type = import_ref Main//extern_api, D, loaded [template = constants.%D]
  1168. // CHECK:STDOUT: %Main.NS: <namespace> = import_ref Main//extern_api, NS, loaded
  1169. // CHECK:STDOUT: %NS: <namespace> = namespace %Main.NS, [template] {
  1170. // CHECK:STDOUT: .E = %Main.E
  1171. // CHECK:STDOUT: }
  1172. // CHECK:STDOUT: %Main.E: %E.type = import_ref Main//extern_api, E, loaded [template = constants.%E]
  1173. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1174. // CHECK:STDOUT: .Int = %Core.Int
  1175. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1176. // CHECK:STDOUT: import Core//prelude
  1177. // CHECK:STDOUT: import Core//prelude/...
  1178. // CHECK:STDOUT: }
  1179. // CHECK:STDOUT: }
  1180. // CHECK:STDOUT:
  1181. // CHECK:STDOUT: file {
  1182. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1183. // CHECK:STDOUT: .A = imports.%Main.A
  1184. // CHECK:STDOUT: .B = imports.%Main.B
  1185. // CHECK:STDOUT: .C = imports.%Main.C
  1186. // CHECK:STDOUT: .D = imports.%Main.D
  1187. // CHECK:STDOUT: .NS = imports.%NS
  1188. // CHECK:STDOUT: .Core = imports.%Core
  1189. // CHECK:STDOUT: .a = %a
  1190. // CHECK:STDOUT: .b = %b
  1191. // CHECK:STDOUT: .c = %c
  1192. // CHECK:STDOUT: .d = %d
  1193. // CHECK:STDOUT: .e = %e
  1194. // CHECK:STDOUT: }
  1195. // CHECK:STDOUT: %Core.import = import Core
  1196. // CHECK:STDOUT: %default.import = import <none>
  1197. // CHECK:STDOUT: name_binding_decl {
  1198. // CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
  1199. // CHECK:STDOUT: %.loc52_1: %empty_tuple.type = var_pattern %a.patt
  1200. // CHECK:STDOUT: }
  1201. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  1202. // CHECK:STDOUT: %.loc52_9.1: type = splice_block %.loc52_9.3 [template = constants.%empty_tuple.type] {
  1203. // CHECK:STDOUT: %.loc52_9.2: %empty_tuple.type = tuple_literal ()
  1204. // CHECK:STDOUT: %.loc52_9.3: type = converted %.loc52_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1205. // CHECK:STDOUT: }
  1206. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  1207. // CHECK:STDOUT: name_binding_decl {
  1208. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  1209. // CHECK:STDOUT: %.loc53_1: %i32 = var_pattern %b.patt
  1210. // CHECK:STDOUT: }
  1211. // CHECK:STDOUT: %b.var: ref %i32 = var b
  1212. // CHECK:STDOUT: %.loc53_8: type = splice_block %i32.loc53 [template = constants.%i32] {
  1213. // CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1214. // CHECK:STDOUT: %i32.loc53: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1215. // CHECK:STDOUT: }
  1216. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  1217. // CHECK:STDOUT: name_binding_decl {
  1218. // CHECK:STDOUT: %c.patt: %struct_type.c = binding_pattern c
  1219. // CHECK:STDOUT: %.loc54_1: %struct_type.c = var_pattern %c.patt
  1220. // CHECK:STDOUT: }
  1221. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  1222. // CHECK:STDOUT: %.loc54_16: type = splice_block %struct_type.c [template = constants.%struct_type.c] {
  1223. // CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1224. // CHECK:STDOUT: %i32.loc54: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1225. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  1226. // CHECK:STDOUT: }
  1227. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  1228. // CHECK:STDOUT: name_binding_decl {
  1229. // CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d
  1230. // CHECK:STDOUT: %.loc55_1: %empty_tuple.type = var_pattern %d.patt
  1231. // CHECK:STDOUT: }
  1232. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  1233. // CHECK:STDOUT: %.loc55_9.1: type = splice_block %.loc55_9.3 [template = constants.%empty_tuple.type] {
  1234. // CHECK:STDOUT: %.loc55_9.2: %empty_tuple.type = tuple_literal ()
  1235. // CHECK:STDOUT: %.loc55_9.3: type = converted %.loc55_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1236. // CHECK:STDOUT: }
  1237. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  1238. // CHECK:STDOUT: name_binding_decl {
  1239. // CHECK:STDOUT: %e.patt: %empty_tuple.type = binding_pattern e
  1240. // CHECK:STDOUT: %.loc56_1: %empty_tuple.type = var_pattern %e.patt
  1241. // CHECK:STDOUT: }
  1242. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  1243. // CHECK:STDOUT: %.loc56_9.1: type = splice_block %.loc56_9.3 [template = constants.%empty_tuple.type] {
  1244. // CHECK:STDOUT: %.loc56_9.2: %empty_tuple.type = tuple_literal ()
  1245. // CHECK:STDOUT: %.loc56_9.3: type = converted %.loc56_9.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1246. // CHECK:STDOUT: }
  1247. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  1248. // CHECK:STDOUT: }
  1249. // CHECK:STDOUT:
  1250. // CHECK:STDOUT: extern fn @A();
  1251. // CHECK:STDOUT:
  1252. // CHECK:STDOUT: extern fn @B(%b.param_patt: %i32) -> %i32;
  1253. // CHECK:STDOUT:
  1254. // CHECK:STDOUT: extern fn @C(%c.param_patt: %tuple.type.a1c) -> %struct_type.c;
  1255. // CHECK:STDOUT:
  1256. // CHECK:STDOUT: extern fn @D();
  1257. // CHECK:STDOUT:
  1258. // CHECK:STDOUT: extern fn @E();
  1259. // CHECK:STDOUT:
  1260. // CHECK:STDOUT: fn @__global_init() {
  1261. // CHECK:STDOUT: !entry:
  1262. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%Main.A [template = constants.%A]
  1263. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  1264. // CHECK:STDOUT: assign file.%a.var, %A.call
  1265. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%Main.B [template = constants.%B]
  1266. // CHECK:STDOUT: %int_1.loc53: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  1267. // CHECK:STDOUT: %impl.elem0.loc53: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  1268. // CHECK:STDOUT: %bound_method.loc53: <bound method> = bound_method %int_1.loc53, %impl.elem0.loc53 [template = constants.%Convert.bound]
  1269. // CHECK:STDOUT: %specific_fn.loc53: <specific function> = specific_function %bound_method.loc53, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1270. // CHECK:STDOUT: %int.convert_checked.loc53: init %i32 = call %specific_fn.loc53(%int_1.loc53) [template = constants.%int_1.5d2]
  1271. // CHECK:STDOUT: %.loc53_16.1: %i32 = value_of_initializer %int.convert_checked.loc53 [template = constants.%int_1.5d2]
  1272. // CHECK:STDOUT: %.loc53_16.2: %i32 = converted %int_1.loc53, %.loc53_16.1 [template = constants.%int_1.5d2]
  1273. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc53_16.2)
  1274. // CHECK:STDOUT: assign file.%b.var, %B.call
  1275. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Main.C [template = constants.%C]
  1276. // CHECK:STDOUT: %int_1.loc54: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  1277. // CHECK:STDOUT: %.loc54_25.1: %tuple.type.985 = tuple_literal (%int_1.loc54)
  1278. // CHECK:STDOUT: %impl.elem0.loc54: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  1279. // CHECK:STDOUT: %bound_method.loc54: <bound method> = bound_method %int_1.loc54, %impl.elem0.loc54 [template = constants.%Convert.bound]
  1280. // CHECK:STDOUT: %specific_fn.loc54: <specific function> = specific_function %bound_method.loc54, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1281. // CHECK:STDOUT: %int.convert_checked.loc54: init %i32 = call %specific_fn.loc54(%int_1.loc54) [template = constants.%int_1.5d2]
  1282. // CHECK:STDOUT: %.loc54_25.2: %i32 = value_of_initializer %int.convert_checked.loc54 [template = constants.%int_1.5d2]
  1283. // CHECK:STDOUT: %.loc54_25.3: %i32 = converted %int_1.loc54, %.loc54_25.2 [template = constants.%int_1.5d2]
  1284. // CHECK:STDOUT: %tuple: %tuple.type.a1c = tuple_value (%.loc54_25.3) [template = constants.%tuple]
  1285. // CHECK:STDOUT: %.loc54_25.4: %tuple.type.a1c = converted %.loc54_25.1, %tuple [template = constants.%tuple]
  1286. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc54_25.4)
  1287. // CHECK:STDOUT: assign file.%c.var, %C.call
  1288. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%Main.D [template = constants.%D]
  1289. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  1290. // CHECK:STDOUT: assign file.%d.var, %D.call
  1291. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  1292. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%Main.E [template = constants.%E]
  1293. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  1294. // CHECK:STDOUT: assign file.%e.var, %E.call
  1295. // CHECK:STDOUT: return
  1296. // CHECK:STDOUT: }
  1297. // CHECK:STDOUT:
  1298. // CHECK:STDOUT: --- unloaded.carbon
  1299. // CHECK:STDOUT:
  1300. // CHECK:STDOUT: imports {
  1301. // CHECK:STDOUT: %Main.A = import_ref Main//api, A, unloaded
  1302. // CHECK:STDOUT: %Main.B = import_ref Main//api, B, unloaded
  1303. // CHECK:STDOUT: %Main.C = import_ref Main//api, C, unloaded
  1304. // CHECK:STDOUT: %Main.D = import_ref Main//api, D, unloaded
  1305. // CHECK:STDOUT: %Main.NS: <namespace> = import_ref Main//api, NS, loaded
  1306. // CHECK:STDOUT: %NS: <namespace> = namespace %Main.NS, [template] {
  1307. // CHECK:STDOUT: .E = %Main.E
  1308. // CHECK:STDOUT: }
  1309. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1310. // CHECK:STDOUT: import Core//prelude
  1311. // CHECK:STDOUT: import Core//prelude/...
  1312. // CHECK:STDOUT: }
  1313. // CHECK:STDOUT: }
  1314. // CHECK:STDOUT:
  1315. // CHECK:STDOUT: file {
  1316. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1317. // CHECK:STDOUT: .A = imports.%Main.A
  1318. // CHECK:STDOUT: .B = imports.%Main.B
  1319. // CHECK:STDOUT: .C = imports.%Main.C
  1320. // CHECK:STDOUT: .D = imports.%Main.D
  1321. // CHECK:STDOUT: .NS = imports.%NS
  1322. // CHECK:STDOUT: .Core = imports.%Core
  1323. // CHECK:STDOUT: }
  1324. // CHECK:STDOUT: %Core.import = import Core
  1325. // CHECK:STDOUT: %default.import = import <none>
  1326. // CHECK:STDOUT: }
  1327. // CHECK:STDOUT:
  1328. // CHECK:STDOUT: --- unloaded_extern.carbon
  1329. // CHECK:STDOUT:
  1330. // CHECK:STDOUT: imports {
  1331. // CHECK:STDOUT: %Main.A = import_ref Main//extern_api, A, unloaded
  1332. // CHECK:STDOUT: %Main.B = import_ref Main//extern_api, B, unloaded
  1333. // CHECK:STDOUT: %Main.C = import_ref Main//extern_api, C, unloaded
  1334. // CHECK:STDOUT: %Main.D = import_ref Main//extern_api, D, unloaded
  1335. // CHECK:STDOUT: %Main.NS: <namespace> = import_ref Main//extern_api, NS, loaded
  1336. // CHECK:STDOUT: %NS: <namespace> = namespace %Main.NS, [template] {
  1337. // CHECK:STDOUT: .E = %Main.E
  1338. // CHECK:STDOUT: }
  1339. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1340. // CHECK:STDOUT: import Core//prelude
  1341. // CHECK:STDOUT: import Core//prelude/...
  1342. // CHECK:STDOUT: }
  1343. // CHECK:STDOUT: }
  1344. // CHECK:STDOUT:
  1345. // CHECK:STDOUT: file {
  1346. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1347. // CHECK:STDOUT: .A = imports.%Main.A
  1348. // CHECK:STDOUT: .B = imports.%Main.B
  1349. // CHECK:STDOUT: .C = imports.%Main.C
  1350. // CHECK:STDOUT: .D = imports.%Main.D
  1351. // CHECK:STDOUT: .NS = imports.%NS
  1352. // CHECK:STDOUT: .Core = imports.%Core
  1353. // CHECK:STDOUT: }
  1354. // CHECK:STDOUT: %Core.import = import Core
  1355. // CHECK:STDOUT: %default.import = import <none>
  1356. // CHECK:STDOUT: }
  1357. // CHECK:STDOUT: