import.carbon 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  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+44]]: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+40]]: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+35]]: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+31]]: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+26]]: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+22]]: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+17]]: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+13]]: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+8]]: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+4]]: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. import library "extern_api";
  207. import library "api";
  208. var a: () = A();
  209. var b: i32 = B(1);
  210. var c: {.c: i32} = C((1,));
  211. var d: () = D();
  212. var e: () = NS.E();
  213. // --- unloaded.carbon
  214. library "[[@TEST_NAME]]";
  215. import library "api";
  216. // --- unloaded_extern.carbon
  217. library "[[@TEST_NAME]]";
  218. import library "extern_api";
  219. // CHECK:STDOUT: --- api.carbon
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: constants {
  222. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  223. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  224. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  225. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  226. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  227. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  228. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  229. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  230. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  231. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32) [template]
  232. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  233. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  234. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  235. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  236. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  237. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  238. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: imports {
  242. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  243. // CHECK:STDOUT: .Int = %import_ref
  244. // CHECK:STDOUT: import Core//prelude
  245. // CHECK:STDOUT: import Core//prelude/...
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT: }
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: file {
  250. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  251. // CHECK:STDOUT: .Core = imports.%Core
  252. // CHECK:STDOUT: .A = %A.decl
  253. // CHECK:STDOUT: .B = %B.decl
  254. // CHECK:STDOUT: .C = %C.decl
  255. // CHECK:STDOUT: .D = %D.decl
  256. // CHECK:STDOUT: .NS = %NS
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT: %Core.import = import Core
  259. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  260. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  261. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  262. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param0
  263. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  264. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  265. // CHECK:STDOUT: } {
  266. // CHECK:STDOUT: %int_32.loc5_9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  267. // CHECK:STDOUT: %int.make_type_signed.loc5_9: init type = call constants.%Int(%int_32.loc5_9) [template = constants.%i32]
  268. // CHECK:STDOUT: %.loc5_9.1: type = value_of_initializer %int.make_type_signed.loc5_9 [template = constants.%i32]
  269. // CHECK:STDOUT: %.loc5_9.2: type = converted %int.make_type_signed.loc5_9, %.loc5_9.1 [template = constants.%i32]
  270. // CHECK:STDOUT: %int_32.loc5_17: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  271. // CHECK:STDOUT: %int.make_type_signed.loc5_17: init type = call constants.%Int(%int_32.loc5_17) [template = constants.%i32]
  272. // CHECK:STDOUT: %.loc5_17.1: type = value_of_initializer %int.make_type_signed.loc5_17 [template = constants.%i32]
  273. // CHECK:STDOUT: %.loc5_17.2: type = converted %int.make_type_signed.loc5_17, %.loc5_17.1 [template = constants.%i32]
  274. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  275. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  276. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  277. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  280. // CHECK:STDOUT: %c.patt: %tuple.type.2 = binding_pattern c
  281. // CHECK:STDOUT: %c.param_patt: %tuple.type.2 = value_param_pattern %c.patt, runtime_param0
  282. // CHECK:STDOUT: %return.patt: %struct_type.c = return_slot_pattern
  283. // CHECK:STDOUT: %return.param_patt: %struct_type.c = out_param_pattern %return.patt, runtime_param1
  284. // CHECK:STDOUT: } {
  285. // CHECK:STDOUT: %int_32.loc6_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  286. // CHECK:STDOUT: %int.make_type_signed.loc6_10: init type = call constants.%Int(%int_32.loc6_10) [template = constants.%i32]
  287. // CHECK:STDOUT: %.loc6_14.1: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc6_10)
  288. // CHECK:STDOUT: %.loc6_14.2: type = value_of_initializer %int.make_type_signed.loc6_10 [template = constants.%i32]
  289. // CHECK:STDOUT: %.loc6_14.3: type = converted %int.make_type_signed.loc6_10, %.loc6_14.2 [template = constants.%i32]
  290. // CHECK:STDOUT: %.loc6_14.4: type = converted %.loc6_14.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  291. // CHECK:STDOUT: %int_32.loc6_25: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  292. // CHECK:STDOUT: %int.make_type_signed.loc6_25: init type = call constants.%Int(%int_32.loc6_25) [template = constants.%i32]
  293. // CHECK:STDOUT: %.loc6_25.1: type = value_of_initializer %int.make_type_signed.loc6_25 [template = constants.%i32]
  294. // CHECK:STDOUT: %.loc6_25.2: type = converted %int.make_type_signed.loc6_25, %.loc6_25.1 [template = constants.%i32]
  295. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  296. // CHECK:STDOUT: %c.param: %tuple.type.2 = value_param runtime_param0
  297. // CHECK:STDOUT: %c: %tuple.type.2 = bind_name c, %c.param
  298. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  299. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  302. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  303. // CHECK:STDOUT: .E = %E.decl
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: fn @A();
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32;
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.2) -> %struct_type.c;
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: extern fn @D();
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: fn @E();
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: --- extern_api.carbon
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: constants {
  321. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  322. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  323. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  324. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  325. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  326. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  327. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  328. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  329. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  330. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32) [template]
  331. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  332. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  333. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  334. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  335. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  336. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  337. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: imports {
  341. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  342. // CHECK:STDOUT: .Int = %import_ref
  343. // CHECK:STDOUT: import Core//prelude
  344. // CHECK:STDOUT: import Core//prelude/...
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: file {
  349. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  350. // CHECK:STDOUT: .Core = imports.%Core
  351. // CHECK:STDOUT: .A = %A.decl
  352. // CHECK:STDOUT: .B = %B.decl
  353. // CHECK:STDOUT: .C = %C.decl
  354. // CHECK:STDOUT: .D = %D.decl
  355. // CHECK:STDOUT: .NS = %NS
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT: %Core.import = import Core
  358. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  359. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  360. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  361. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param0
  362. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  363. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  364. // CHECK:STDOUT: } {
  365. // CHECK:STDOUT: %int_32.loc5_44: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  366. // CHECK:STDOUT: %int.make_type_signed.loc5_44: init type = call constants.%Int(%int_32.loc5_44) [template = constants.%i32]
  367. // CHECK:STDOUT: %.loc5_44.1: type = value_of_initializer %int.make_type_signed.loc5_44 [template = constants.%i32]
  368. // CHECK:STDOUT: %.loc5_44.2: type = converted %int.make_type_signed.loc5_44, %.loc5_44.1 [template = constants.%i32]
  369. // CHECK:STDOUT: %int_32.loc5_52: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  370. // CHECK:STDOUT: %int.make_type_signed.loc5_52: init type = call constants.%Int(%int_32.loc5_52) [template = constants.%i32]
  371. // CHECK:STDOUT: %.loc5_52.1: type = value_of_initializer %int.make_type_signed.loc5_52 [template = constants.%i32]
  372. // CHECK:STDOUT: %.loc5_52.2: type = converted %int.make_type_signed.loc5_52, %.loc5_52.1 [template = constants.%i32]
  373. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  374. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  375. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  376. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  379. // CHECK:STDOUT: %c.patt: %tuple.type.2 = binding_pattern c
  380. // CHECK:STDOUT: %c.param_patt: %tuple.type.2 = value_param_pattern %c.patt, runtime_param0
  381. // CHECK:STDOUT: %return.patt: %struct_type.c = return_slot_pattern
  382. // CHECK:STDOUT: %return.param_patt: %struct_type.c = out_param_pattern %return.patt, runtime_param1
  383. // CHECK:STDOUT: } {
  384. // CHECK:STDOUT: %int_32.loc6_45: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  385. // CHECK:STDOUT: %int.make_type_signed.loc6_45: init type = call constants.%Int(%int_32.loc6_45) [template = constants.%i32]
  386. // CHECK:STDOUT: %.loc6_49.1: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc6_45)
  387. // CHECK:STDOUT: %.loc6_49.2: type = value_of_initializer %int.make_type_signed.loc6_45 [template = constants.%i32]
  388. // CHECK:STDOUT: %.loc6_49.3: type = converted %int.make_type_signed.loc6_45, %.loc6_49.2 [template = constants.%i32]
  389. // CHECK:STDOUT: %.loc6_49.4: type = converted %.loc6_49.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  390. // CHECK:STDOUT: %int_32.loc6_60: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  391. // CHECK:STDOUT: %int.make_type_signed.loc6_60: init type = call constants.%Int(%int_32.loc6_60) [template = constants.%i32]
  392. // CHECK:STDOUT: %.loc6_60.1: type = value_of_initializer %int.make_type_signed.loc6_60 [template = constants.%i32]
  393. // CHECK:STDOUT: %.loc6_60.2: type = converted %int.make_type_signed.loc6_60, %.loc6_60.1 [template = constants.%i32]
  394. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  395. // CHECK:STDOUT: %c.param: %tuple.type.2 = value_param runtime_param0
  396. // CHECK:STDOUT: %c: %tuple.type.2 = bind_name c, %c.param
  397. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  398. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  401. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  402. // CHECK:STDOUT: .E = %E.decl
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT:
  407. // CHECK:STDOUT: extern fn @A();
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: extern fn @B(%b.param_patt: %i32) -> %i32;
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: extern fn @C(%c.param_patt: %tuple.type.2) -> %struct_type.c;
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: extern fn @D();
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: extern fn @E();
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: --- basics.carbon
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: constants {
  420. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  421. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  422. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  423. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  424. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  425. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  426. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  427. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  428. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  429. // CHECK:STDOUT: %int_1.1: Core.IntLiteral = int_value 1 [template]
  430. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  431. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  432. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  433. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  434. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.1, %Convert.14 [template]
  435. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  436. // CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
  437. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  438. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  439. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  440. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (%i32) [template]
  441. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (Core.IntLiteral) [template]
  442. // CHECK:STDOUT: %tuple: %tuple.type.1 = tuple_value (%int_1.2) [template]
  443. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  444. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  445. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  446. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: imports {
  450. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, A, loaded [template = constants.%A]
  451. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, B, loaded [template = constants.%B]
  452. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, C, loaded [template = constants.%C]
  453. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, D, loaded [template = constants.%D]
  454. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, NS, loaded
  455. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  456. // CHECK:STDOUT: .E = %import_ref.6
  457. // CHECK:STDOUT: }
  458. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, E, loaded [template = constants.%E]
  459. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  460. // CHECK:STDOUT: .Int = %import_ref.7
  461. // CHECK:STDOUT: .ImplicitAs = %import_ref.8
  462. // CHECK:STDOUT: import Core//prelude
  463. // CHECK:STDOUT: import Core//prelude/...
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: file {
  468. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  469. // CHECK:STDOUT: .A = imports.%import_ref.1
  470. // CHECK:STDOUT: .B = imports.%import_ref.2
  471. // CHECK:STDOUT: .C = imports.%import_ref.3
  472. // CHECK:STDOUT: .D = imports.%import_ref.4
  473. // CHECK:STDOUT: .NS = imports.%NS
  474. // CHECK:STDOUT: .Core = imports.%Core
  475. // CHECK:STDOUT: .a = %a
  476. // CHECK:STDOUT: .b = %b
  477. // CHECK:STDOUT: .c = %c
  478. // CHECK:STDOUT: .d = %d
  479. // CHECK:STDOUT: .e = %e
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT: %Core.import = import Core
  482. // CHECK:STDOUT: %default.import = import <invalid>
  483. // CHECK:STDOUT: %.loc6_9.1: %empty_tuple.type = tuple_literal ()
  484. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  485. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  486. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  487. // CHECK:STDOUT: %int_32.loc7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  488. // CHECK:STDOUT: %int.make_type_signed.loc7: init type = call constants.%Int(%int_32.loc7) [template = constants.%i32]
  489. // CHECK:STDOUT: %.loc7_8.1: type = value_of_initializer %int.make_type_signed.loc7 [template = constants.%i32]
  490. // CHECK:STDOUT: %.loc7_8.2: type = converted %int.make_type_signed.loc7, %.loc7_8.1 [template = constants.%i32]
  491. // CHECK:STDOUT: %b.var: ref %i32 = var b
  492. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  493. // CHECK:STDOUT: %int_32.loc8: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  494. // CHECK:STDOUT: %int.make_type_signed.loc8: init type = call constants.%Int(%int_32.loc8) [template = constants.%i32]
  495. // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_signed.loc8 [template = constants.%i32]
  496. // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_signed.loc8, %.loc8_13.1 [template = constants.%i32]
  497. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  498. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  499. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  500. // CHECK:STDOUT: %.loc9_9.1: %empty_tuple.type = tuple_literal ()
  501. // CHECK:STDOUT: %.loc9_9.2: type = converted %.loc9_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  502. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  503. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  504. // CHECK:STDOUT: %.loc10_9.1: %empty_tuple.type = tuple_literal ()
  505. // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  506. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  507. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: fn @A() [from "api.carbon"];
  511. // CHECK:STDOUT:
  512. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32 [from "api.carbon"];
  513. // CHECK:STDOUT:
  514. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.1) -> %struct_type.c [from "api.carbon"];
  515. // CHECK:STDOUT:
  516. // CHECK:STDOUT: extern fn @D() [from "api.carbon"];
  517. // CHECK:STDOUT:
  518. // CHECK:STDOUT: fn @E() [from "api.carbon"];
  519. // CHECK:STDOUT:
  520. // CHECK:STDOUT: fn @__global_init() {
  521. // CHECK:STDOUT: !entry:
  522. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  523. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  524. // CHECK:STDOUT: assign file.%a.var, %A.call
  525. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  526. // CHECK:STDOUT: %int_1.loc7: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  527. // CHECK:STDOUT: %impl.elem0.loc7: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  528. // CHECK:STDOUT: %Convert.bound.loc7: <bound method> = bound_method %int_1.loc7, %impl.elem0.loc7 [template = constants.%Convert.bound]
  529. // CHECK:STDOUT: %Convert.specific_fn.loc7: <specific function> = specific_function %Convert.bound.loc7, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  530. // CHECK:STDOUT: %int.convert_checked.loc7: init %i32 = call %Convert.specific_fn.loc7(%int_1.loc7) [template = constants.%int_1.2]
  531. // CHECK:STDOUT: %.loc7_16.1: %i32 = value_of_initializer %int.convert_checked.loc7 [template = constants.%int_1.2]
  532. // CHECK:STDOUT: %.loc7_16.2: %i32 = converted %int_1.loc7, %.loc7_16.1 [template = constants.%int_1.2]
  533. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc7_16.2)
  534. // CHECK:STDOUT: assign file.%b.var, %B.call
  535. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  536. // CHECK:STDOUT: %int_1.loc8: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  537. // CHECK:STDOUT: %.loc8_25.1: %tuple.type.2 = tuple_literal (%int_1.loc8)
  538. // CHECK:STDOUT: %impl.elem0.loc8: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  539. // CHECK:STDOUT: %Convert.bound.loc8: <bound method> = bound_method %int_1.loc8, %impl.elem0.loc8 [template = constants.%Convert.bound]
  540. // CHECK:STDOUT: %Convert.specific_fn.loc8: <specific function> = specific_function %Convert.bound.loc8, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  541. // CHECK:STDOUT: %int.convert_checked.loc8: init %i32 = call %Convert.specific_fn.loc8(%int_1.loc8) [template = constants.%int_1.2]
  542. // CHECK:STDOUT: %.loc8_25.2: %i32 = value_of_initializer %int.convert_checked.loc8 [template = constants.%int_1.2]
  543. // CHECK:STDOUT: %.loc8_25.3: %i32 = converted %int_1.loc8, %.loc8_25.2 [template = constants.%int_1.2]
  544. // CHECK:STDOUT: %tuple: %tuple.type.1 = tuple_value (%.loc8_25.3) [template = constants.%tuple]
  545. // CHECK:STDOUT: %.loc8_25.4: %tuple.type.1 = converted %.loc8_25.1, %tuple [template = constants.%tuple]
  546. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc8_25.4)
  547. // CHECK:STDOUT: assign file.%c.var, %C.call
  548. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  549. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  550. // CHECK:STDOUT: assign file.%d.var, %D.call
  551. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  552. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  553. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  554. // CHECK:STDOUT: assign file.%e.var, %E.call
  555. // CHECK:STDOUT: return
  556. // CHECK:STDOUT: }
  557. // CHECK:STDOUT:
  558. // CHECK:STDOUT: --- fail_redecl_api.carbon
  559. // CHECK:STDOUT:
  560. // CHECK:STDOUT: constants {
  561. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  562. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  563. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  564. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  565. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  566. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  567. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  568. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  569. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  570. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  571. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32) [template]
  572. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  573. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  574. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  575. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  576. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  577. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  578. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  579. // CHECK:STDOUT: %int_1.1: Core.IntLiteral = int_value 1 [template]
  580. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  581. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  582. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  583. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  584. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.1, %Convert.14 [template]
  585. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  586. // CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
  587. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (Core.IntLiteral) [template]
  588. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%int_1.2) [template]
  589. // CHECK:STDOUT: }
  590. // CHECK:STDOUT:
  591. // CHECK:STDOUT: imports {
  592. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, NS, loaded
  593. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  594. // CHECK:STDOUT: .E = file.%E.decl
  595. // CHECK:STDOUT: }
  596. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  597. // CHECK:STDOUT: .Int = %import_ref.7
  598. // CHECK:STDOUT: .ImplicitAs = %import_ref.8
  599. // CHECK:STDOUT: import Core//prelude
  600. // CHECK:STDOUT: import Core//prelude/...
  601. // CHECK:STDOUT: }
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT:
  604. // CHECK:STDOUT: file {
  605. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  606. // CHECK:STDOUT: .A = %A.decl
  607. // CHECK:STDOUT: .B = %B.decl
  608. // CHECK:STDOUT: .C = %C.decl
  609. // CHECK:STDOUT: .D = %D.decl
  610. // CHECK:STDOUT: .NS = imports.%NS
  611. // CHECK:STDOUT: .Core = imports.%Core
  612. // CHECK:STDOUT: .a = %a
  613. // CHECK:STDOUT: .b = %b
  614. // CHECK:STDOUT: .c = %c
  615. // CHECK:STDOUT: .d = %d
  616. // CHECK:STDOUT: .e = %e
  617. // CHECK:STDOUT: }
  618. // CHECK:STDOUT: %Core.import = import Core
  619. // CHECK:STDOUT: %default.import = import <invalid>
  620. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  621. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {
  622. // CHECK:STDOUT: %int_32.loc23_16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  623. // CHECK:STDOUT: %int.make_type_signed.loc23_16: init type = call constants.%Int(%int_32.loc23_16) [template = constants.%i32]
  624. // CHECK:STDOUT: %.loc23_16.1: type = value_of_initializer %int.make_type_signed.loc23_16 [template = constants.%i32]
  625. // CHECK:STDOUT: %.loc23_16.2: type = converted %int.make_type_signed.loc23_16, %.loc23_16.1 [template = constants.%i32]
  626. // CHECK:STDOUT: %int_32.loc23_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  627. // CHECK:STDOUT: %int.make_type_signed.loc23_24: init type = call constants.%Int(%int_32.loc23_24) [template = constants.%i32]
  628. // CHECK:STDOUT: %.loc23_24.1: type = value_of_initializer %int.make_type_signed.loc23_24 [template = constants.%i32]
  629. // CHECK:STDOUT: %.loc23_24.2: type = converted %int.make_type_signed.loc23_24, %.loc23_24.1 [template = constants.%i32]
  630. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  631. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  632. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  633. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} {
  636. // CHECK:STDOUT: %int_32.loc32_17: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  637. // CHECK:STDOUT: %int.make_type_signed.loc32_17: init type = call constants.%Int(%int_32.loc32_17) [template = constants.%i32]
  638. // CHECK:STDOUT: %.loc32_21.1: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc32_17)
  639. // CHECK:STDOUT: %.loc32_21.2: type = value_of_initializer %int.make_type_signed.loc32_17 [template = constants.%i32]
  640. // CHECK:STDOUT: %.loc32_21.3: type = converted %int.make_type_signed.loc32_17, %.loc32_21.2 [template = constants.%i32]
  641. // CHECK:STDOUT: %.loc32_21.4: type = converted %.loc32_21.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  642. // CHECK:STDOUT: %int_32.loc32_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  643. // CHECK:STDOUT: %int.make_type_signed.loc32_32: init type = call constants.%Int(%int_32.loc32_32) [template = constants.%i32]
  644. // CHECK:STDOUT: %.loc32_32.1: type = value_of_initializer %int.make_type_signed.loc32_32 [template = constants.%i32]
  645. // CHECK:STDOUT: %.loc32_32.2: type = converted %int.make_type_signed.loc32_32, %.loc32_32.1 [template = constants.%i32]
  646. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  647. // CHECK:STDOUT: %c.param: %tuple.type.2 = value_param runtime_param0
  648. // CHECK:STDOUT: %c: %tuple.type.2 = bind_name c, %c.param
  649. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  650. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  651. // CHECK:STDOUT: }
  652. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  653. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  654. // CHECK:STDOUT: %.loc52_9.1: %empty_tuple.type = tuple_literal ()
  655. // CHECK:STDOUT: %.loc52_9.2: type = converted %.loc52_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  656. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  657. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  658. // CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  659. // CHECK:STDOUT: %int.make_type_signed.loc53: init type = call constants.%Int(%int_32.loc53) [template = constants.%i32]
  660. // CHECK:STDOUT: %.loc53_8.1: type = value_of_initializer %int.make_type_signed.loc53 [template = constants.%i32]
  661. // CHECK:STDOUT: %.loc53_8.2: type = converted %int.make_type_signed.loc53, %.loc53_8.1 [template = constants.%i32]
  662. // CHECK:STDOUT: %b.var: ref %i32 = var b
  663. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  664. // CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  665. // CHECK:STDOUT: %int.make_type_signed.loc54: init type = call constants.%Int(%int_32.loc54) [template = constants.%i32]
  666. // CHECK:STDOUT: %.loc54_13.1: type = value_of_initializer %int.make_type_signed.loc54 [template = constants.%i32]
  667. // CHECK:STDOUT: %.loc54_13.2: type = converted %int.make_type_signed.loc54, %.loc54_13.1 [template = constants.%i32]
  668. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  669. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  670. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  671. // CHECK:STDOUT: %.loc55_9.1: %empty_tuple.type = tuple_literal ()
  672. // CHECK:STDOUT: %.loc55_9.2: type = converted %.loc55_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  673. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  674. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  675. // CHECK:STDOUT: %.loc56_9.1: %empty_tuple.type = tuple_literal ()
  676. // CHECK:STDOUT: %.loc56_9.2: type = converted %.loc56_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  677. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  678. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  679. // CHECK:STDOUT: }
  680. // CHECK:STDOUT:
  681. // CHECK:STDOUT: fn @A() [from "api.carbon"];
  682. // CHECK:STDOUT:
  683. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32 [from "api.carbon"];
  684. // CHECK:STDOUT:
  685. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.2) -> %struct_type.c [from "api.carbon"];
  686. // CHECK:STDOUT:
  687. // CHECK:STDOUT: extern fn @D() [from "api.carbon"];
  688. // CHECK:STDOUT:
  689. // CHECK:STDOUT: fn @E() [from "api.carbon"];
  690. // CHECK:STDOUT:
  691. // CHECK:STDOUT: fn @__global_init() {
  692. // CHECK:STDOUT: !entry:
  693. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  694. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  695. // CHECK:STDOUT: assign file.%a.var, %A.call
  696. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  697. // CHECK:STDOUT: %int_1.loc53: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  698. // CHECK:STDOUT: %impl.elem0.loc53: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  699. // CHECK:STDOUT: %Convert.bound.loc53: <bound method> = bound_method %int_1.loc53, %impl.elem0.loc53 [template = constants.%Convert.bound]
  700. // CHECK:STDOUT: %Convert.specific_fn.loc53: <specific function> = specific_function %Convert.bound.loc53, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  701. // CHECK:STDOUT: %int.convert_checked.loc53: init %i32 = call %Convert.specific_fn.loc53(%int_1.loc53) [template = constants.%int_1.2]
  702. // CHECK:STDOUT: %.loc53_16.1: %i32 = value_of_initializer %int.convert_checked.loc53 [template = constants.%int_1.2]
  703. // CHECK:STDOUT: %.loc53_16.2: %i32 = converted %int_1.loc53, %.loc53_16.1 [template = constants.%int_1.2]
  704. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc53_16.2)
  705. // CHECK:STDOUT: assign file.%b.var, %B.call
  706. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  707. // CHECK:STDOUT: %int_1.loc54: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  708. // CHECK:STDOUT: %.loc54_25.1: %tuple.type.3 = tuple_literal (%int_1.loc54)
  709. // CHECK:STDOUT: %impl.elem0.loc54: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  710. // CHECK:STDOUT: %Convert.bound.loc54: <bound method> = bound_method %int_1.loc54, %impl.elem0.loc54 [template = constants.%Convert.bound]
  711. // CHECK:STDOUT: %Convert.specific_fn.loc54: <specific function> = specific_function %Convert.bound.loc54, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  712. // CHECK:STDOUT: %int.convert_checked.loc54: init %i32 = call %Convert.specific_fn.loc54(%int_1.loc54) [template = constants.%int_1.2]
  713. // CHECK:STDOUT: %.loc54_25.2: %i32 = value_of_initializer %int.convert_checked.loc54 [template = constants.%int_1.2]
  714. // CHECK:STDOUT: %.loc54_25.3: %i32 = converted %int_1.loc54, %.loc54_25.2 [template = constants.%int_1.2]
  715. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.loc54_25.3) [template = constants.%tuple]
  716. // CHECK:STDOUT: %.loc54_25.4: %tuple.type.2 = converted %.loc54_25.1, %tuple [template = constants.%tuple]
  717. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc54_25.4)
  718. // CHECK:STDOUT: assign file.%c.var, %C.call
  719. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  720. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  721. // CHECK:STDOUT: assign file.%d.var, %D.call
  722. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  723. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  724. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  725. // CHECK:STDOUT: assign file.%e.var, %E.call
  726. // CHECK:STDOUT: return
  727. // CHECK:STDOUT: }
  728. // CHECK:STDOUT:
  729. // CHECK:STDOUT: --- redecl_extern_api.carbon
  730. // CHECK:STDOUT:
  731. // CHECK:STDOUT: constants {
  732. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  733. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  734. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  735. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  736. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  737. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  738. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  739. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  740. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  741. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  742. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32) [template]
  743. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  744. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  745. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  746. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  747. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  748. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  749. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  750. // CHECK:STDOUT: %int_1.1: Core.IntLiteral = int_value 1 [template]
  751. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  752. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  753. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  754. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  755. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.1, %Convert.14 [template]
  756. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  757. // CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
  758. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (Core.IntLiteral) [template]
  759. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%int_1.2) [template]
  760. // CHECK:STDOUT: }
  761. // CHECK:STDOUT:
  762. // CHECK:STDOUT: imports {
  763. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, NS, loaded
  764. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  765. // CHECK:STDOUT: .E = file.%E.decl
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  768. // CHECK:STDOUT: .Int = %import_ref.7
  769. // CHECK:STDOUT: .ImplicitAs = %import_ref.8
  770. // CHECK:STDOUT: import Core//prelude
  771. // CHECK:STDOUT: import Core//prelude/...
  772. // CHECK:STDOUT: }
  773. // CHECK:STDOUT: }
  774. // CHECK:STDOUT:
  775. // CHECK:STDOUT: file {
  776. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  777. // CHECK:STDOUT: .A = %A.decl
  778. // CHECK:STDOUT: .B = %B.decl
  779. // CHECK:STDOUT: .C = %C.decl
  780. // CHECK:STDOUT: .D = %D.decl
  781. // CHECK:STDOUT: .NS = imports.%NS
  782. // CHECK:STDOUT: .Core = imports.%Core
  783. // CHECK:STDOUT: .a = %a
  784. // CHECK:STDOUT: .b = %b
  785. // CHECK:STDOUT: .c = %c
  786. // CHECK:STDOUT: .d = %d
  787. // CHECK:STDOUT: .e = %e
  788. // CHECK:STDOUT: }
  789. // CHECK:STDOUT: %Core.import = import Core
  790. // CHECK:STDOUT: %default.import = import <invalid>
  791. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {} {}
  792. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {} {
  793. // CHECK:STDOUT: %int_32.loc7_16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  794. // CHECK:STDOUT: %int.make_type_signed.loc7_16: init type = call constants.%Int(%int_32.loc7_16) [template = constants.%i32]
  795. // CHECK:STDOUT: %.loc7_16.1: type = value_of_initializer %int.make_type_signed.loc7_16 [template = constants.%i32]
  796. // CHECK:STDOUT: %.loc7_16.2: type = converted %int.make_type_signed.loc7_16, %.loc7_16.1 [template = constants.%i32]
  797. // CHECK:STDOUT: %int_32.loc7_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  798. // CHECK:STDOUT: %int.make_type_signed.loc7_24: init type = call constants.%Int(%int_32.loc7_24) [template = constants.%i32]
  799. // CHECK:STDOUT: %.loc7_24.1: type = value_of_initializer %int.make_type_signed.loc7_24 [template = constants.%i32]
  800. // CHECK:STDOUT: %.loc7_24.2: type = converted %int.make_type_signed.loc7_24, %.loc7_24.1 [template = constants.%i32]
  801. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param0
  802. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  803. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  804. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  805. // CHECK:STDOUT: }
  806. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {} {
  807. // CHECK:STDOUT: %int_32.loc8_17: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  808. // CHECK:STDOUT: %int.make_type_signed.loc8_17: init type = call constants.%Int(%int_32.loc8_17) [template = constants.%i32]
  809. // CHECK:STDOUT: %.loc8_21.1: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc8_17)
  810. // CHECK:STDOUT: %.loc8_21.2: type = value_of_initializer %int.make_type_signed.loc8_17 [template = constants.%i32]
  811. // CHECK:STDOUT: %.loc8_21.3: type = converted %int.make_type_signed.loc8_17, %.loc8_21.2 [template = constants.%i32]
  812. // CHECK:STDOUT: %.loc8_21.4: type = converted %.loc8_21.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  813. // CHECK:STDOUT: %int_32.loc8_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  814. // CHECK:STDOUT: %int.make_type_signed.loc8_32: init type = call constants.%Int(%int_32.loc8_32) [template = constants.%i32]
  815. // CHECK:STDOUT: %.loc8_32.1: type = value_of_initializer %int.make_type_signed.loc8_32 [template = constants.%i32]
  816. // CHECK:STDOUT: %.loc8_32.2: type = converted %int.make_type_signed.loc8_32, %.loc8_32.1 [template = constants.%i32]
  817. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  818. // CHECK:STDOUT: %c.param: %tuple.type.2 = value_param runtime_param0
  819. // CHECK:STDOUT: %c: %tuple.type.2 = bind_name c, %c.param
  820. // CHECK:STDOUT: %return.param: ref %struct_type.c = out_param runtime_param1
  821. // CHECK:STDOUT: %return: ref %struct_type.c = return_slot %return.param
  822. // CHECK:STDOUT: }
  823. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {} {}
  824. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {} {}
  825. // CHECK:STDOUT: %.loc12_9.1: %empty_tuple.type = tuple_literal ()
  826. // CHECK:STDOUT: %.loc12_9.2: type = converted %.loc12_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  827. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  828. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  829. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  830. // CHECK:STDOUT: %int.make_type_signed.loc13: init type = call constants.%Int(%int_32.loc13) [template = constants.%i32]
  831. // CHECK:STDOUT: %.loc13_8.1: type = value_of_initializer %int.make_type_signed.loc13 [template = constants.%i32]
  832. // CHECK:STDOUT: %.loc13_8.2: type = converted %int.make_type_signed.loc13, %.loc13_8.1 [template = constants.%i32]
  833. // CHECK:STDOUT: %b.var: ref %i32 = var b
  834. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  835. // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  836. // CHECK:STDOUT: %int.make_type_signed.loc14: init type = call constants.%Int(%int_32.loc14) [template = constants.%i32]
  837. // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_signed.loc14 [template = constants.%i32]
  838. // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_signed.loc14, %.loc14_13.1 [template = constants.%i32]
  839. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  840. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  841. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  842. // CHECK:STDOUT: %.loc15_9.1: %empty_tuple.type = tuple_literal ()
  843. // CHECK:STDOUT: %.loc15_9.2: type = converted %.loc15_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  844. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  845. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  846. // CHECK:STDOUT: %.loc16_9.1: %empty_tuple.type = tuple_literal ()
  847. // CHECK:STDOUT: %.loc16_9.2: type = converted %.loc16_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  848. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  849. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  850. // CHECK:STDOUT: }
  851. // CHECK:STDOUT:
  852. // CHECK:STDOUT: extern fn @A();
  853. // CHECK:STDOUT:
  854. // CHECK:STDOUT: extern fn @B(%b.param_patt: %i32) -> %i32;
  855. // CHECK:STDOUT:
  856. // CHECK:STDOUT: extern fn @C(%c.param_patt: %tuple.type.2) -> %struct_type.c;
  857. // CHECK:STDOUT:
  858. // CHECK:STDOUT: extern fn @D();
  859. // CHECK:STDOUT:
  860. // CHECK:STDOUT: extern fn @E();
  861. // CHECK:STDOUT:
  862. // CHECK:STDOUT: fn @__global_init() {
  863. // CHECK:STDOUT: !entry:
  864. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  865. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  866. // CHECK:STDOUT: assign file.%a.var, %A.call
  867. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  868. // CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  869. // CHECK:STDOUT: %impl.elem0.loc13: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  870. // CHECK:STDOUT: %Convert.bound.loc13: <bound method> = bound_method %int_1.loc13, %impl.elem0.loc13 [template = constants.%Convert.bound]
  871. // CHECK:STDOUT: %Convert.specific_fn.loc13: <specific function> = specific_function %Convert.bound.loc13, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  872. // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %Convert.specific_fn.loc13(%int_1.loc13) [template = constants.%int_1.2]
  873. // CHECK:STDOUT: %.loc13_16.1: %i32 = value_of_initializer %int.convert_checked.loc13 [template = constants.%int_1.2]
  874. // CHECK:STDOUT: %.loc13_16.2: %i32 = converted %int_1.loc13, %.loc13_16.1 [template = constants.%int_1.2]
  875. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc13_16.2)
  876. // CHECK:STDOUT: assign file.%b.var, %B.call
  877. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  878. // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  879. // CHECK:STDOUT: %.loc14_25.1: %tuple.type.3 = tuple_literal (%int_1.loc14)
  880. // CHECK:STDOUT: %impl.elem0.loc14: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  881. // CHECK:STDOUT: %Convert.bound.loc14: <bound method> = bound_method %int_1.loc14, %impl.elem0.loc14 [template = constants.%Convert.bound]
  882. // CHECK:STDOUT: %Convert.specific_fn.loc14: <specific function> = specific_function %Convert.bound.loc14, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  883. // CHECK:STDOUT: %int.convert_checked.loc14: init %i32 = call %Convert.specific_fn.loc14(%int_1.loc14) [template = constants.%int_1.2]
  884. // CHECK:STDOUT: %.loc14_25.2: %i32 = value_of_initializer %int.convert_checked.loc14 [template = constants.%int_1.2]
  885. // CHECK:STDOUT: %.loc14_25.3: %i32 = converted %int_1.loc14, %.loc14_25.2 [template = constants.%int_1.2]
  886. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.loc14_25.3) [template = constants.%tuple]
  887. // CHECK:STDOUT: %.loc14_25.4: %tuple.type.2 = converted %.loc14_25.1, %tuple [template = constants.%tuple]
  888. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc14_25.4)
  889. // CHECK:STDOUT: assign file.%c.var, %C.call
  890. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  891. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  892. // CHECK:STDOUT: assign file.%d.var, %D.call
  893. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  894. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  895. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  896. // CHECK:STDOUT: assign file.%e.var, %E.call
  897. // CHECK:STDOUT: return
  898. // CHECK:STDOUT: }
  899. // CHECK:STDOUT:
  900. // CHECK:STDOUT: --- fail_merge.carbon
  901. // CHECK:STDOUT:
  902. // CHECK:STDOUT: constants {
  903. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  904. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  905. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  906. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  907. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  908. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  909. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  910. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  911. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  912. // CHECK:STDOUT: %int_1.1: Core.IntLiteral = int_value 1 [template]
  913. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  914. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  915. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  916. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  917. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.1, %Convert.14 [template]
  918. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  919. // CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
  920. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  921. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  922. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  923. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (%i32) [template]
  924. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (Core.IntLiteral) [template]
  925. // CHECK:STDOUT: %tuple: %tuple.type.1 = tuple_value (%int_1.2) [template]
  926. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  927. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  928. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  929. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  930. // CHECK:STDOUT: }
  931. // CHECK:STDOUT:
  932. // CHECK:STDOUT: imports {
  933. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, A, loaded [template = constants.%A]
  934. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, B, loaded [template = constants.%B]
  935. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, C, loaded [template = constants.%C]
  936. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, D, loaded [template = constants.%D]
  937. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, NS, loaded
  938. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  939. // CHECK:STDOUT: .E = %import_ref.6
  940. // CHECK:STDOUT: }
  941. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, E, loaded [template = constants.%E]
  942. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  943. // CHECK:STDOUT: .Int = %import_ref.12
  944. // CHECK:STDOUT: .ImplicitAs = %import_ref.13
  945. // CHECK:STDOUT: import Core//prelude
  946. // CHECK:STDOUT: import Core//prelude/...
  947. // CHECK:STDOUT: }
  948. // CHECK:STDOUT: }
  949. // CHECK:STDOUT:
  950. // CHECK:STDOUT: file {
  951. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  952. // CHECK:STDOUT: .A = imports.%import_ref.1
  953. // CHECK:STDOUT: .B = imports.%import_ref.2
  954. // CHECK:STDOUT: .C = imports.%import_ref.3
  955. // CHECK:STDOUT: .D = imports.%import_ref.4
  956. // CHECK:STDOUT: .NS = imports.%NS
  957. // CHECK:STDOUT: .Core = imports.%Core
  958. // CHECK:STDOUT: .a = %a
  959. // CHECK:STDOUT: .b = %b
  960. // CHECK:STDOUT: .c = %c
  961. // CHECK:STDOUT: .d = %d
  962. // CHECK:STDOUT: .e = %e
  963. // CHECK:STDOUT: }
  964. // CHECK:STDOUT: %Core.import = import Core
  965. // CHECK:STDOUT: %default.import = import <invalid>
  966. // CHECK:STDOUT: %.loc52_9.1: %empty_tuple.type = tuple_literal ()
  967. // CHECK:STDOUT: %.loc52_9.2: type = converted %.loc52_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  968. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  969. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  970. // CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  971. // CHECK:STDOUT: %int.make_type_signed.loc53: init type = call constants.%Int(%int_32.loc53) [template = constants.%i32]
  972. // CHECK:STDOUT: %.loc53_8.1: type = value_of_initializer %int.make_type_signed.loc53 [template = constants.%i32]
  973. // CHECK:STDOUT: %.loc53_8.2: type = converted %int.make_type_signed.loc53, %.loc53_8.1 [template = constants.%i32]
  974. // CHECK:STDOUT: %b.var: ref %i32 = var b
  975. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  976. // CHECK:STDOUT: %int_32.loc54: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  977. // CHECK:STDOUT: %int.make_type_signed.loc54: init type = call constants.%Int(%int_32.loc54) [template = constants.%i32]
  978. // CHECK:STDOUT: %.loc54_13.1: type = value_of_initializer %int.make_type_signed.loc54 [template = constants.%i32]
  979. // CHECK:STDOUT: %.loc54_13.2: type = converted %int.make_type_signed.loc54, %.loc54_13.1 [template = constants.%i32]
  980. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  981. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  982. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  983. // CHECK:STDOUT: %.loc55_9.1: %empty_tuple.type = tuple_literal ()
  984. // CHECK:STDOUT: %.loc55_9.2: type = converted %.loc55_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  985. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  986. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  987. // CHECK:STDOUT: %.loc56_9.1: %empty_tuple.type = tuple_literal ()
  988. // CHECK:STDOUT: %.loc56_9.2: type = converted %.loc56_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  989. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  990. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  991. // CHECK:STDOUT: }
  992. // CHECK:STDOUT:
  993. // CHECK:STDOUT: fn @A() [from "api.carbon"];
  994. // CHECK:STDOUT:
  995. // CHECK:STDOUT: fn @B(%b.param_patt: %i32) -> %i32 [from "api.carbon"];
  996. // CHECK:STDOUT:
  997. // CHECK:STDOUT: fn @C(%c.param_patt: %tuple.type.1) -> %struct_type.c [from "api.carbon"];
  998. // CHECK:STDOUT:
  999. // CHECK:STDOUT: extern fn @D() [from "api.carbon"];
  1000. // CHECK:STDOUT:
  1001. // CHECK:STDOUT: fn @E() [from "api.carbon"];
  1002. // CHECK:STDOUT:
  1003. // CHECK:STDOUT: fn @__global_init() {
  1004. // CHECK:STDOUT: !entry:
  1005. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1006. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  1007. // CHECK:STDOUT: assign file.%a.var, %A.call
  1008. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  1009. // CHECK:STDOUT: %int_1.loc53: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  1010. // CHECK:STDOUT: %impl.elem0.loc53: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  1011. // CHECK:STDOUT: %Convert.bound.loc53: <bound method> = bound_method %int_1.loc53, %impl.elem0.loc53 [template = constants.%Convert.bound]
  1012. // CHECK:STDOUT: %Convert.specific_fn.loc53: <specific function> = specific_function %Convert.bound.loc53, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1013. // CHECK:STDOUT: %int.convert_checked.loc53: init %i32 = call %Convert.specific_fn.loc53(%int_1.loc53) [template = constants.%int_1.2]
  1014. // CHECK:STDOUT: %.loc53_16.1: %i32 = value_of_initializer %int.convert_checked.loc53 [template = constants.%int_1.2]
  1015. // CHECK:STDOUT: %.loc53_16.2: %i32 = converted %int_1.loc53, %.loc53_16.1 [template = constants.%int_1.2]
  1016. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc53_16.2)
  1017. // CHECK:STDOUT: assign file.%b.var, %B.call
  1018. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  1019. // CHECK:STDOUT: %int_1.loc54: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  1020. // CHECK:STDOUT: %.loc54_25.1: %tuple.type.2 = tuple_literal (%int_1.loc54)
  1021. // CHECK:STDOUT: %impl.elem0.loc54: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  1022. // CHECK:STDOUT: %Convert.bound.loc54: <bound method> = bound_method %int_1.loc54, %impl.elem0.loc54 [template = constants.%Convert.bound]
  1023. // CHECK:STDOUT: %Convert.specific_fn.loc54: <specific function> = specific_function %Convert.bound.loc54, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1024. // CHECK:STDOUT: %int.convert_checked.loc54: init %i32 = call %Convert.specific_fn.loc54(%int_1.loc54) [template = constants.%int_1.2]
  1025. // CHECK:STDOUT: %.loc54_25.2: %i32 = value_of_initializer %int.convert_checked.loc54 [template = constants.%int_1.2]
  1026. // CHECK:STDOUT: %.loc54_25.3: %i32 = converted %int_1.loc54, %.loc54_25.2 [template = constants.%int_1.2]
  1027. // CHECK:STDOUT: %tuple: %tuple.type.1 = tuple_value (%.loc54_25.3) [template = constants.%tuple]
  1028. // CHECK:STDOUT: %.loc54_25.4: %tuple.type.1 = converted %.loc54_25.1, %tuple [template = constants.%tuple]
  1029. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc54_25.4)
  1030. // CHECK:STDOUT: assign file.%c.var, %C.call
  1031. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  1032. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  1033. // CHECK:STDOUT: assign file.%d.var, %D.call
  1034. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  1035. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  1036. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  1037. // CHECK:STDOUT: assign file.%e.var, %E.call
  1038. // CHECK:STDOUT: return
  1039. // CHECK:STDOUT: }
  1040. // CHECK:STDOUT:
  1041. // CHECK:STDOUT: --- fail_merge_reverse.carbon
  1042. // CHECK:STDOUT:
  1043. // CHECK:STDOUT: constants {
  1044. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  1045. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  1046. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  1047. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  1048. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  1049. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  1050. // CHECK:STDOUT: %i32: type = int_type signed, %int_32 [template]
  1051. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  1052. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  1053. // CHECK:STDOUT: %int_1.1: Core.IntLiteral = int_value 1 [template]
  1054. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  1055. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  1056. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  1057. // CHECK:STDOUT: %interface.9: <witness> = interface_witness (%Convert.14) [template]
  1058. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.1, %Convert.14 [template]
  1059. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  1060. // CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
  1061. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template]
  1062. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  1063. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  1064. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (%i32) [template]
  1065. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (Core.IntLiteral) [template]
  1066. // CHECK:STDOUT: %tuple: %tuple.type.1 = tuple_value (%int_1.2) [template]
  1067. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  1068. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  1069. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  1070. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  1071. // CHECK:STDOUT: }
  1072. // CHECK:STDOUT:
  1073. // CHECK:STDOUT: imports {
  1074. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, A, loaded [template = constants.%A]
  1075. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//extern_api, B, loaded [template = constants.%B]
  1076. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//extern_api, C, loaded [template = constants.%C]
  1077. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//extern_api, D, loaded [template = constants.%D]
  1078. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, NS, loaded
  1079. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1080. // CHECK:STDOUT: .E = %import_ref.6
  1081. // CHECK:STDOUT: }
  1082. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//extern_api, E, loaded [template = constants.%E]
  1083. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1084. // CHECK:STDOUT: .Int = %import_ref.12
  1085. // CHECK:STDOUT: .ImplicitAs = %import_ref.13
  1086. // CHECK:STDOUT: import Core//prelude
  1087. // CHECK:STDOUT: import Core//prelude/...
  1088. // CHECK:STDOUT: }
  1089. // CHECK:STDOUT: }
  1090. // CHECK:STDOUT:
  1091. // CHECK:STDOUT: file {
  1092. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1093. // CHECK:STDOUT: .A = imports.%import_ref.1
  1094. // CHECK:STDOUT: .B = imports.%import_ref.2
  1095. // CHECK:STDOUT: .C = imports.%import_ref.3
  1096. // CHECK:STDOUT: .D = imports.%import_ref.4
  1097. // CHECK:STDOUT: .NS = imports.%NS
  1098. // CHECK:STDOUT: .Core = imports.%Core
  1099. // CHECK:STDOUT: .a = %a
  1100. // CHECK:STDOUT: .b = %b
  1101. // CHECK:STDOUT: .c = %c
  1102. // CHECK:STDOUT: .d = %d
  1103. // CHECK:STDOUT: .e = %e
  1104. // CHECK:STDOUT: }
  1105. // CHECK:STDOUT: %Core.import = import Core
  1106. // CHECK:STDOUT: %default.import = import <invalid>
  1107. // CHECK:STDOUT: %.loc51_9.1: %empty_tuple.type = tuple_literal ()
  1108. // CHECK:STDOUT: %.loc51_9.2: type = converted %.loc51_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1109. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  1110. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  1111. // CHECK:STDOUT: %int_32.loc52: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1112. // CHECK:STDOUT: %int.make_type_signed.loc52: init type = call constants.%Int(%int_32.loc52) [template = constants.%i32]
  1113. // CHECK:STDOUT: %.loc52_8.1: type = value_of_initializer %int.make_type_signed.loc52 [template = constants.%i32]
  1114. // CHECK:STDOUT: %.loc52_8.2: type = converted %int.make_type_signed.loc52, %.loc52_8.1 [template = constants.%i32]
  1115. // CHECK:STDOUT: %b.var: ref %i32 = var b
  1116. // CHECK:STDOUT: %b: ref %i32 = bind_name b, %b.var
  1117. // CHECK:STDOUT: %int_32.loc53: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1118. // CHECK:STDOUT: %int.make_type_signed.loc53: init type = call constants.%Int(%int_32.loc53) [template = constants.%i32]
  1119. // CHECK:STDOUT: %.loc53_13.1: type = value_of_initializer %int.make_type_signed.loc53 [template = constants.%i32]
  1120. // CHECK:STDOUT: %.loc53_13.2: type = converted %int.make_type_signed.loc53, %.loc53_13.1 [template = constants.%i32]
  1121. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %i32} [template = constants.%struct_type.c]
  1122. // CHECK:STDOUT: %c.var: ref %struct_type.c = var c
  1123. // CHECK:STDOUT: %c: ref %struct_type.c = bind_name c, %c.var
  1124. // CHECK:STDOUT: %.loc54_9.1: %empty_tuple.type = tuple_literal ()
  1125. // CHECK:STDOUT: %.loc54_9.2: type = converted %.loc54_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1126. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  1127. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  1128. // CHECK:STDOUT: %.loc55_9.1: %empty_tuple.type = tuple_literal ()
  1129. // CHECK:STDOUT: %.loc55_9.2: type = converted %.loc55_9.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  1130. // CHECK:STDOUT: %e.var: ref %empty_tuple.type = var e
  1131. // CHECK:STDOUT: %e: ref %empty_tuple.type = bind_name e, %e.var
  1132. // CHECK:STDOUT: }
  1133. // CHECK:STDOUT:
  1134. // CHECK:STDOUT: extern fn @A();
  1135. // CHECK:STDOUT:
  1136. // CHECK:STDOUT: extern fn @B(%b.param_patt: %i32) -> %i32;
  1137. // CHECK:STDOUT:
  1138. // CHECK:STDOUT: extern fn @C(%c.param_patt: %tuple.type.1) -> %struct_type.c;
  1139. // CHECK:STDOUT:
  1140. // CHECK:STDOUT: extern fn @D();
  1141. // CHECK:STDOUT:
  1142. // CHECK:STDOUT: extern fn @E();
  1143. // CHECK:STDOUT:
  1144. // CHECK:STDOUT: fn @__global_init() {
  1145. // CHECK:STDOUT: !entry:
  1146. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1147. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %A.ref()
  1148. // CHECK:STDOUT: assign file.%a.var, %A.call
  1149. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  1150. // CHECK:STDOUT: %int_1.loc52: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  1151. // CHECK:STDOUT: %impl.elem0.loc52: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  1152. // CHECK:STDOUT: %Convert.bound.loc52: <bound method> = bound_method %int_1.loc52, %impl.elem0.loc52 [template = constants.%Convert.bound]
  1153. // CHECK:STDOUT: %Convert.specific_fn.loc52: <specific function> = specific_function %Convert.bound.loc52, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1154. // CHECK:STDOUT: %int.convert_checked.loc52: init %i32 = call %Convert.specific_fn.loc52(%int_1.loc52) [template = constants.%int_1.2]
  1155. // CHECK:STDOUT: %.loc52_16.1: %i32 = value_of_initializer %int.convert_checked.loc52 [template = constants.%int_1.2]
  1156. // CHECK:STDOUT: %.loc52_16.2: %i32 = converted %int_1.loc52, %.loc52_16.1 [template = constants.%int_1.2]
  1157. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref(%.loc52_16.2)
  1158. // CHECK:STDOUT: assign file.%b.var, %B.call
  1159. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  1160. // CHECK:STDOUT: %int_1.loc53: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  1161. // CHECK:STDOUT: %.loc53_25.1: %tuple.type.2 = tuple_literal (%int_1.loc53)
  1162. // CHECK:STDOUT: %impl.elem0.loc53: %Convert.type.2 = interface_witness_access constants.%interface.9, element0 [template = constants.%Convert.14]
  1163. // CHECK:STDOUT: %Convert.bound.loc53: <bound method> = bound_method %int_1.loc53, %impl.elem0.loc53 [template = constants.%Convert.bound]
  1164. // CHECK:STDOUT: %Convert.specific_fn.loc53: <specific function> = specific_function %Convert.bound.loc53, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  1165. // CHECK:STDOUT: %int.convert_checked.loc53: init %i32 = call %Convert.specific_fn.loc53(%int_1.loc53) [template = constants.%int_1.2]
  1166. // CHECK:STDOUT: %.loc53_25.2: %i32 = value_of_initializer %int.convert_checked.loc53 [template = constants.%int_1.2]
  1167. // CHECK:STDOUT: %.loc53_25.3: %i32 = converted %int_1.loc53, %.loc53_25.2 [template = constants.%int_1.2]
  1168. // CHECK:STDOUT: %tuple: %tuple.type.1 = tuple_value (%.loc53_25.3) [template = constants.%tuple]
  1169. // CHECK:STDOUT: %.loc53_25.4: %tuple.type.1 = converted %.loc53_25.1, %tuple [template = constants.%tuple]
  1170. // CHECK:STDOUT: %C.call: init %struct_type.c = call %C.ref(%.loc53_25.4)
  1171. // CHECK:STDOUT: assign file.%c.var, %C.call
  1172. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  1173. // CHECK:STDOUT: %D.call: init %empty_tuple.type = call %D.ref()
  1174. // CHECK:STDOUT: assign file.%d.var, %D.call
  1175. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  1176. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  1177. // CHECK:STDOUT: %E.call: init %empty_tuple.type = call %E.ref()
  1178. // CHECK:STDOUT: assign file.%e.var, %E.call
  1179. // CHECK:STDOUT: return
  1180. // CHECK:STDOUT: }
  1181. // CHECK:STDOUT:
  1182. // CHECK:STDOUT: --- unloaded.carbon
  1183. // CHECK:STDOUT:
  1184. // CHECK:STDOUT: imports {
  1185. // CHECK:STDOUT: %import_ref.1 = import_ref Main//api, A, unloaded
  1186. // CHECK:STDOUT: %import_ref.2 = import_ref Main//api, B, unloaded
  1187. // CHECK:STDOUT: %import_ref.3 = import_ref Main//api, C, unloaded
  1188. // CHECK:STDOUT: %import_ref.4 = import_ref Main//api, D, unloaded
  1189. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, NS, loaded
  1190. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1191. // CHECK:STDOUT: .E = %import_ref.6
  1192. // CHECK:STDOUT: }
  1193. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1194. // CHECK:STDOUT: import Core//prelude
  1195. // CHECK:STDOUT: import Core//prelude/...
  1196. // CHECK:STDOUT: }
  1197. // CHECK:STDOUT: }
  1198. // CHECK:STDOUT:
  1199. // CHECK:STDOUT: file {
  1200. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1201. // CHECK:STDOUT: .A = imports.%import_ref.1
  1202. // CHECK:STDOUT: .B = imports.%import_ref.2
  1203. // CHECK:STDOUT: .C = imports.%import_ref.3
  1204. // CHECK:STDOUT: .D = imports.%import_ref.4
  1205. // CHECK:STDOUT: .NS = imports.%NS
  1206. // CHECK:STDOUT: .Core = imports.%Core
  1207. // CHECK:STDOUT: }
  1208. // CHECK:STDOUT: %Core.import = import Core
  1209. // CHECK:STDOUT: %default.import = import <invalid>
  1210. // CHECK:STDOUT: }
  1211. // CHECK:STDOUT:
  1212. // CHECK:STDOUT: --- unloaded_extern.carbon
  1213. // CHECK:STDOUT:
  1214. // CHECK:STDOUT: imports {
  1215. // CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_api, A, unloaded
  1216. // CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, B, unloaded
  1217. // CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, C, unloaded
  1218. // CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, D, unloaded
  1219. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, NS, loaded
  1220. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1221. // CHECK:STDOUT: .E = %import_ref.6
  1222. // CHECK:STDOUT: }
  1223. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1224. // CHECK:STDOUT: import Core//prelude
  1225. // CHECK:STDOUT: import Core//prelude/...
  1226. // CHECK:STDOUT: }
  1227. // CHECK:STDOUT: }
  1228. // CHECK:STDOUT:
  1229. // CHECK:STDOUT: file {
  1230. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1231. // CHECK:STDOUT: .A = imports.%import_ref.1
  1232. // CHECK:STDOUT: .B = imports.%import_ref.2
  1233. // CHECK:STDOUT: .C = imports.%import_ref.3
  1234. // CHECK:STDOUT: .D = imports.%import_ref.4
  1235. // CHECK:STDOUT: .NS = imports.%NS
  1236. // CHECK:STDOUT: .Core = imports.%Core
  1237. // CHECK:STDOUT: }
  1238. // CHECK:STDOUT: %Core.import = import Core
  1239. // CHECK:STDOUT: %default.import = import <invalid>
  1240. // CHECK:STDOUT: }
  1241. // CHECK:STDOUT: