cross_package_import.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --no-prelude-import --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/packages/cross_package_import.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/packages/cross_package_import.carbon
  13. // ============================================================================
  14. // Setup files
  15. // ============================================================================
  16. // --- other_fn.carbon
  17. package Other library "[[@TEST_NAME]]";
  18. fn F() {}
  19. // --- other_fn_extern.carbon
  20. package Other library "[[@TEST_NAME]]";
  21. extern fn F();
  22. // --- other_fn_conflict.carbon
  23. package Other library "[[@TEST_NAME]]";
  24. fn F(x: ()) {}
  25. // --- other_fn2.carbon
  26. package Other library "[[@TEST_NAME]]";
  27. fn F2() {}
  28. // --- other_fn_use.carbon
  29. package Other library "[[@TEST_NAME]]";
  30. import library "other_fn";
  31. fn G() { F(); }
  32. // --- main_other_ns.carbon
  33. library "[[@TEST_NAME]]";
  34. namespace Other;
  35. // ============================================================================
  36. // Test files
  37. // ============================================================================
  38. // --- main_use_other.carbon
  39. library "[[@TEST_NAME]]";
  40. import Other library "other_fn";
  41. import Other library "other_fn2";
  42. fn Run() {
  43. Other.F();
  44. Other.F2();
  45. }
  46. // --- fail_todo_main_use_other_extern.carbon
  47. library "[[@TEST_NAME]]";
  48. // CHECK:STDERR: fail_todo_main_use_other_extern.carbon:[[@LINE+8]]:1: in import [InImport]
  49. // CHECK:STDERR: other_fn_extern.carbon:4:1: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
  50. // CHECK:STDERR: extern fn F();
  51. // CHECK:STDERR: ^~~~~~~~~~~~~~
  52. // CHECK:STDERR: fail_todo_main_use_other_extern.carbon:[[@LINE+4]]:1: in import [InImport]
  53. // CHECK:STDERR: other_fn.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  54. // CHECK:STDERR: fn F() {}
  55. // CHECK:STDERR: ^~~~~~~~
  56. import Other library "other_fn";
  57. import Other library "other_fn_extern";
  58. fn Run() {
  59. // CHECK:STDERR: fail_todo_main_use_other_extern.carbon:[[@LINE+4]]:3: note: in name lookup for `F` [InNameLookup]
  60. // CHECK:STDERR: Other.F();
  61. // CHECK:STDERR: ^~~~~~~
  62. // CHECK:STDERR:
  63. Other.F();
  64. }
  65. // --- main_unused_other_ambiguous.carbon
  66. library "[[@TEST_NAME]]";
  67. import Other library "other_fn";
  68. import Other library "other_fn_conflict";
  69. // --- fail_main_use_other_ambiguous.carbon
  70. library "[[@TEST_NAME]]";
  71. // CHECK:STDERR: fail_main_use_other_ambiguous.carbon:[[@LINE+8]]:1: in import [InImport]
  72. // CHECK:STDERR: other_fn_conflict.carbon:4:1: error: duplicate name `F` being declared in the same scope [NameDeclDuplicate]
  73. // CHECK:STDERR: fn F(x: ()) {}
  74. // CHECK:STDERR: ^~~~~~~~~~~~~
  75. // CHECK:STDERR: fail_main_use_other_ambiguous.carbon:[[@LINE+4]]:1: in import [InImport]
  76. // CHECK:STDERR: other_fn.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  77. // CHECK:STDERR: fn F() {}
  78. // CHECK:STDERR: ^~~~~~~~
  79. import Other library "other_fn";
  80. import Other library "other_fn_conflict";
  81. fn Run() {
  82. // CHECK:STDERR: fail_main_use_other_ambiguous.carbon:[[@LINE+4]]:3: note: in name lookup for `F` [InNameLookup]
  83. // CHECK:STDERR: Other.F();
  84. // CHECK:STDERR: ^~~~~~~
  85. // CHECK:STDERR:
  86. Other.F();
  87. }
  88. // --- fail_main_namespace_conflict.carbon
  89. library "[[@TEST_NAME]]";
  90. import library "main_other_ns";
  91. // CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+8]]:1: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate]
  92. // CHECK:STDERR: import Other library "other_fn";
  93. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94. // CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE-4]]:1: in import [InImport]
  95. // CHECK:STDERR: main_other_ns.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  96. // CHECK:STDERR: namespace Other;
  97. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  98. // CHECK:STDERR:
  99. import Other library "other_fn";
  100. // CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE+8]]:1: error: redeclaration of `fn F` is redundant [RedeclRedundant]
  101. // CHECK:STDERR: fn Other.F() {}
  102. // CHECK:STDERR: ^~~~~~~~~~~~~~
  103. // CHECK:STDERR: fail_main_namespace_conflict.carbon:[[@LINE-5]]:1: in import [InImport]
  104. // CHECK:STDERR: other_fn.carbon:4:1: note: previously declared here [RedeclPrevDecl]
  105. // CHECK:STDERR: fn F() {}
  106. // CHECK:STDERR: ^~~~~~~~
  107. // CHECK:STDERR:
  108. fn Other.F() {}
  109. // --- fail_main_reopen_other.carbon
  110. library "[[@TEST_NAME]]";
  111. import Other library "other_fn";
  112. // CHECK:STDERR: fail_main_reopen_other.carbon:[[@LINE+7]]:11: error: duplicate name `Other` being declared in the same scope [NameDeclDuplicate]
  113. // CHECK:STDERR: namespace Other;
  114. // CHECK:STDERR: ^~~~~
  115. // CHECK:STDERR: fail_main_reopen_other.carbon:[[@LINE-5]]:1: note: name is previously declared here [NameDeclPrevious]
  116. // CHECK:STDERR: import Other library "other_fn";
  117. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118. // CHECK:STDERR:
  119. namespace Other;
  120. // This is not diagnosed after the diagnostic on `namespace Other;`.
  121. fn Other.G() {}
  122. // --- fail_main_reopen_other_nested.carbon
  123. library "[[@TEST_NAME]]";
  124. import Other library "other_fn";
  125. // CHECK:STDERR: fail_main_reopen_other_nested.carbon:[[@LINE+7]]:11: error: imported packages cannot be used for declarations [QualifiedDeclOutsidePackage]
  126. // CHECK:STDERR: namespace Other.Nested;
  127. // CHECK:STDERR: ^~~~~
  128. // CHECK:STDERR: fail_main_reopen_other_nested.carbon:[[@LINE-5]]:1: note: package imported here [QualifiedDeclOutsidePackageSource]
  129. // CHECK:STDERR: import Other library "other_fn";
  130. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  131. // CHECK:STDERR:
  132. namespace Other.Nested;
  133. // This is not diagnosed after the diagnostic on `namespace Other;`.
  134. fn Other.Nested.F() {}
  135. // --- fail_main_add_to_other.carbon
  136. library "[[@TEST_NAME]]";
  137. import Other library "other_fn";
  138. // CHECK:STDERR: fail_main_add_to_other.carbon:[[@LINE+7]]:4: error: imported packages cannot be used for declarations [QualifiedDeclOutsidePackage]
  139. // CHECK:STDERR: fn Other.G() {}
  140. // CHECK:STDERR: ^~~~~
  141. // CHECK:STDERR: fail_main_add_to_other.carbon:[[@LINE-5]]:1: note: package imported here [QualifiedDeclOutsidePackageSource]
  142. // CHECK:STDERR: import Other library "other_fn";
  143. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144. // CHECK:STDERR:
  145. fn Other.G() {}
  146. // --- fail_use_other_fn_use.carbon
  147. library "[[@TEST_NAME]]";
  148. import Other library "other_fn_use";
  149. // CHECK:STDERR: fail_use_other_fn_use.carbon:[[@LINE+4]]:13: error: member name `F` not found in `Other` [MemberNameNotFoundInInstScope]
  150. // CHECK:STDERR: fn UseF() { Other.F(); }
  151. // CHECK:STDERR: ^~~~~~~
  152. // CHECK:STDERR:
  153. fn UseF() { Other.F(); }
  154. // CHECK:STDOUT: --- other_fn.carbon
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: constants {
  157. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  158. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: file {
  162. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  163. // CHECK:STDOUT: .F = %F.decl
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: fn @F() {
  169. // CHECK:STDOUT: !entry:
  170. // CHECK:STDOUT: return
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: --- other_fn_extern.carbon
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: constants {
  176. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  177. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: file {
  181. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  182. // CHECK:STDOUT: .F = %F.decl
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: extern fn @F();
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: --- other_fn_conflict.carbon
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: constants {
  192. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  193. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  194. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  195. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: file {
  199. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  200. // CHECK:STDOUT: .F = %F.decl
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  203. // CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
  204. // CHECK:STDOUT: %x.param_patt: %pattern_type = value_param_pattern %x.patt, call_param0 [concrete]
  205. // CHECK:STDOUT: } {
  206. // CHECK:STDOUT: %x.param: %empty_tuple.type = value_param call_param0
  207. // CHECK:STDOUT: %.loc4_10.1: type = splice_block %.loc4_10.3 [concrete = constants.%empty_tuple.type] {
  208. // CHECK:STDOUT: %.loc4_10.2: %empty_tuple.type = tuple_literal ()
  209. // CHECK:STDOUT: %.loc4_10.3: type = converted %.loc4_10.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %x.param
  212. // CHECK:STDOUT: }
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: fn @F(%x.param: %empty_tuple.type) {
  216. // CHECK:STDOUT: !entry:
  217. // CHECK:STDOUT: return
  218. // CHECK:STDOUT: }
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: --- other_fn2.carbon
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: constants {
  223. // CHECK:STDOUT: %F2.type: type = fn_type @F2 [concrete]
  224. // CHECK:STDOUT: %F2: %F2.type = struct_value () [concrete]
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: file {
  228. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  229. // CHECK:STDOUT: .F2 = %F2.decl
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: %F2.decl: %F2.type = fn_decl @F2 [concrete = constants.%F2] {} {}
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: fn @F2() {
  235. // CHECK:STDOUT: !entry:
  236. // CHECK:STDOUT: return
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: --- other_fn_use.carbon
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: constants {
  242. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  243. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  244. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  245. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  246. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  247. // CHECK:STDOUT: }
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: imports {
  250. // CHECK:STDOUT: %Other.F: %F.type = import_ref Other//other_fn, F, loaded [concrete = constants.%F]
  251. // CHECK:STDOUT: }
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: file {
  254. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  255. // CHECK:STDOUT: .F = imports.%Other.F
  256. // CHECK:STDOUT: .G = %G.decl
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT: %default.import = import <none>
  259. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: fn @G() {
  263. // CHECK:STDOUT: !entry:
  264. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Other.F [concrete = constants.%F]
  265. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  266. // CHECK:STDOUT: return
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: fn @F [from "other_fn.carbon"];
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: --- main_other_ns.carbon
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: file {
  274. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  275. // CHECK:STDOUT: .Other = %Other
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT: %Other: <namespace> = namespace [concrete] {}
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: --- main_use_other.carbon
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: constants {
  283. // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
  284. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  285. // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
  286. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  287. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  288. // CHECK:STDOUT: %F2.type: type = fn_type @F2 [concrete]
  289. // CHECK:STDOUT: %F2: %F2.type = struct_value () [concrete]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: imports {
  293. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  294. // CHECK:STDOUT: .F = %Other.F
  295. // CHECK:STDOUT: .F2 = %Other.F2
  296. // CHECK:STDOUT: import Other//other_fn
  297. // CHECK:STDOUT: import Other//other_fn2
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT: %Other.F: %F.type = import_ref Other//other_fn, F, loaded [concrete = constants.%F]
  300. // CHECK:STDOUT: %Other.F2: %F2.type = import_ref Other//other_fn2, F2, loaded [concrete = constants.%F2]
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: file {
  304. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  305. // CHECK:STDOUT: .Other = imports.%Other
  306. // CHECK:STDOUT: .Run = %Run.decl
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT: %Other.import = import Other
  309. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: fn @Run() {
  313. // CHECK:STDOUT: !entry:
  314. // CHECK:STDOUT: %Other.ref.loc8: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  315. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Other.F [concrete = constants.%F]
  316. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  317. // CHECK:STDOUT: %Other.ref.loc9: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  318. // CHECK:STDOUT: %F2.ref: %F2.type = name_ref F2, imports.%Other.F2 [concrete = constants.%F2]
  319. // CHECK:STDOUT: %F2.call: init %empty_tuple.type = call %F2.ref()
  320. // CHECK:STDOUT: return
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: fn @F [from "other_fn.carbon"];
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: fn @F2 [from "other_fn2.carbon"];
  326. // CHECK:STDOUT:
  327. // CHECK:STDOUT: --- fail_todo_main_use_other_extern.carbon
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: constants {
  330. // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
  331. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  332. // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
  333. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  334. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: imports {
  338. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  339. // CHECK:STDOUT: .F = %Other.F
  340. // CHECK:STDOUT: import Other//other_fn
  341. // CHECK:STDOUT: import Other//other_fn_extern
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT: %Other.F: %F.type = import_ref Other//other_fn, F, loaded [concrete = constants.%F]
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: file {
  347. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  348. // CHECK:STDOUT: .Other = imports.%Other
  349. // CHECK:STDOUT: .Run = %Run.decl
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT: %Other.import = import Other
  352. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: fn @Run() {
  356. // CHECK:STDOUT: !entry:
  357. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  358. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Other.F [concrete = constants.%F]
  359. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  360. // CHECK:STDOUT: return
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: fn @F [from "other_fn.carbon"];
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: --- main_unused_other_ambiguous.carbon
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: imports {
  368. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  369. // CHECK:STDOUT: import Other//other_fn
  370. // CHECK:STDOUT: import Other//other_fn_conflict
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: file {
  375. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  376. // CHECK:STDOUT: .Other = imports.%Other
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT: %Other.import = import Other
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: --- fail_main_use_other_ambiguous.carbon
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: constants {
  384. // CHECK:STDOUT: %Run.type: type = fn_type @Run [concrete]
  385. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  386. // CHECK:STDOUT: %Run: %Run.type = struct_value () [concrete]
  387. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  388. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: imports {
  392. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  393. // CHECK:STDOUT: .F = %Other.F
  394. // CHECK:STDOUT: import Other//other_fn
  395. // CHECK:STDOUT: import Other//other_fn_conflict
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT: %Other.F: %F.type = import_ref Other//other_fn, F, loaded [concrete = constants.%F]
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: file {
  401. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  402. // CHECK:STDOUT: .Other = imports.%Other
  403. // CHECK:STDOUT: .Run = %Run.decl
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT: %Other.import = import Other
  406. // CHECK:STDOUT: %Run.decl: %Run.type = fn_decl @Run [concrete = constants.%Run] {} {}
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: fn @Run() {
  410. // CHECK:STDOUT: !entry:
  411. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  412. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Other.F [concrete = constants.%F]
  413. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref()
  414. // CHECK:STDOUT: return
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: fn @F [from "other_fn.carbon"];
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: --- fail_main_namespace_conflict.carbon
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: constants {
  422. // CHECK:STDOUT: %F.type.700976.1: type = fn_type @F.1 [concrete]
  423. // CHECK:STDOUT: %F.7e9a3e.1: %F.type.700976.1 = struct_value () [concrete]
  424. // CHECK:STDOUT: %F.type.700976.2: type = fn_type @F.2 [concrete]
  425. // CHECK:STDOUT: %F.7e9a3e.2: %F.type.700976.2 = struct_value () [concrete]
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT:
  428. // CHECK:STDOUT: imports {
  429. // CHECK:STDOUT: %Main.Other: <namespace> = import_ref Main//main_other_ns, Other, loaded
  430. // CHECK:STDOUT: %Other: <namespace> = namespace %Main.Other, [concrete] {
  431. // CHECK:STDOUT: .F = %Other.F
  432. // CHECK:STDOUT: import Other//other_fn
  433. // CHECK:STDOUT: }
  434. // CHECK:STDOUT: %Other.F: %F.type.700976.1 = import_ref Other//other_fn, F, loaded [concrete = constants.%F.7e9a3e.1]
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT:
  437. // CHECK:STDOUT: file {
  438. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  439. // CHECK:STDOUT: .Other = imports.%Other
  440. // CHECK:STDOUT: }
  441. // CHECK:STDOUT: %default.import = import <none>
  442. // CHECK:STDOUT: %Other.import = import Other
  443. // CHECK:STDOUT: %F.decl: %F.type.700976.2 = fn_decl @F.2 [concrete = constants.%F.7e9a3e.2] {} {}
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: fn @F.1 [from "other_fn.carbon"];
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: fn @F.2() {
  449. // CHECK:STDOUT: !entry:
  450. // CHECK:STDOUT: return
  451. // CHECK:STDOUT: }
  452. // CHECK:STDOUT:
  453. // CHECK:STDOUT: --- fail_main_reopen_other.carbon
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: constants {
  456. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  457. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT:
  460. // CHECK:STDOUT: imports {
  461. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  462. // CHECK:STDOUT: .G = file.%G.decl
  463. // CHECK:STDOUT: import Other//other_fn
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: file {
  468. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  469. // CHECK:STDOUT: .Other = imports.%Other
  470. // CHECK:STDOUT: }
  471. // CHECK:STDOUT: %Other.import = import Other
  472. // CHECK:STDOUT: %Other: <namespace> = namespace [concrete] {
  473. // CHECK:STDOUT: .G = %G.decl
  474. // CHECK:STDOUT: import Other//other_fn
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  477. // CHECK:STDOUT: }
  478. // CHECK:STDOUT:
  479. // CHECK:STDOUT: fn @G() {
  480. // CHECK:STDOUT: !entry:
  481. // CHECK:STDOUT: return
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: --- fail_main_reopen_other_nested.carbon
  485. // CHECK:STDOUT:
  486. // CHECK:STDOUT: constants {
  487. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  488. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT:
  491. // CHECK:STDOUT: imports {
  492. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  493. // CHECK:STDOUT: .Nested = file.%Nested
  494. // CHECK:STDOUT: import Other//other_fn
  495. // CHECK:STDOUT: }
  496. // CHECK:STDOUT: }
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: file {
  499. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  500. // CHECK:STDOUT: .Other = imports.%Other
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT: %Other.import = import Other
  503. // CHECK:STDOUT: %Nested: <namespace> = namespace [concrete] {
  504. // CHECK:STDOUT: .F = %F.decl
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: fn @F() {
  510. // CHECK:STDOUT: !entry:
  511. // CHECK:STDOUT: return
  512. // CHECK:STDOUT: }
  513. // CHECK:STDOUT:
  514. // CHECK:STDOUT: --- fail_main_add_to_other.carbon
  515. // CHECK:STDOUT:
  516. // CHECK:STDOUT: constants {
  517. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  518. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  519. // CHECK:STDOUT: }
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: imports {
  522. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  523. // CHECK:STDOUT: .G = file.%G.decl
  524. // CHECK:STDOUT: import Other//other_fn
  525. // CHECK:STDOUT: }
  526. // CHECK:STDOUT: }
  527. // CHECK:STDOUT:
  528. // CHECK:STDOUT: file {
  529. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  530. // CHECK:STDOUT: .Other = imports.%Other
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT: %Other.import = import Other
  533. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  534. // CHECK:STDOUT: }
  535. // CHECK:STDOUT:
  536. // CHECK:STDOUT: fn @G() {
  537. // CHECK:STDOUT: !entry:
  538. // CHECK:STDOUT: return
  539. // CHECK:STDOUT: }
  540. // CHECK:STDOUT:
  541. // CHECK:STDOUT: --- fail_use_other_fn_use.carbon
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: constants {
  544. // CHECK:STDOUT: %UseF.type: type = fn_type @UseF [concrete]
  545. // CHECK:STDOUT: %UseF: %UseF.type = struct_value () [concrete]
  546. // CHECK:STDOUT: }
  547. // CHECK:STDOUT:
  548. // CHECK:STDOUT: imports {
  549. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  550. // CHECK:STDOUT: .F = <poisoned>
  551. // CHECK:STDOUT: import Other//other_fn_use
  552. // CHECK:STDOUT: }
  553. // CHECK:STDOUT: }
  554. // CHECK:STDOUT:
  555. // CHECK:STDOUT: file {
  556. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  557. // CHECK:STDOUT: .Other = imports.%Other
  558. // CHECK:STDOUT: .UseF = %UseF.decl
  559. // CHECK:STDOUT: }
  560. // CHECK:STDOUT: %Other.import = import Other
  561. // CHECK:STDOUT: %UseF.decl: %UseF.type = fn_decl @UseF [concrete = constants.%UseF] {} {}
  562. // CHECK:STDOUT: }
  563. // CHECK:STDOUT:
  564. // CHECK:STDOUT: fn @UseF() {
  565. // CHECK:STDOUT: !entry:
  566. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  567. // CHECK:STDOUT: %F.ref: <error> = name_ref F, <error> [concrete = <error>]
  568. // CHECK:STDOUT: return
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT: