underscore.carbon 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. // This is mostly checking against crashes for compile time bindings in
  6. // difficult contexts.
  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/patterns/min_prelude/underscore.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/patterns/min_prelude/underscore.carbon
  13. // --- basic.carbon
  14. library "[[@TEST_NAME]]";
  15. let _: {} = {};
  16. var _: {} = {};
  17. fn F() {
  18. let _: {} = {};
  19. var _: {} = {};
  20. }
  21. // --- function.carbon
  22. library "[[@TEST_NAME]]";
  23. fn F(_: {});
  24. fn G(_: {}) {}
  25. fn H() {
  26. F({});
  27. }
  28. // --- function_generic.carbon
  29. library "[[@TEST_NAME]]";
  30. fn F(_:! type) {};
  31. fn G() {
  32. F({});
  33. }
  34. // --- fail_function_generic_undefined.carbon
  35. library "[[@TEST_NAME]]";
  36. fn F(_:! type);
  37. fn G() {
  38. // CHECK:STDERR: fail_function_generic_undefined.carbon:[[@LINE+7]]:3: error: use of undefined generic function [MissingGenericFunctionDefinition]
  39. // CHECK:STDERR: F({});
  40. // CHECK:STDERR: ^
  41. // CHECK:STDERR: fail_function_generic_undefined.carbon:[[@LINE-6]]:1: note: generic function declared here [MissingGenericFunctionDefinitionHere]
  42. // CHECK:STDERR: fn F(_:! type);
  43. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  44. // CHECK:STDERR:
  45. F({});
  46. }
  47. // --- function_implict.carbon
  48. library "[[@TEST_NAME]]";
  49. fn F[_:! type]();
  50. fn G[_:! type]() {}
  51. // --- fail_class.carbon
  52. library "[[@TEST_NAME]]";
  53. class C {
  54. // CHECK:STDERR: fail_class.carbon:[[@LINE+8]]:7: error: expected identifier in field declaration [ExpectedFieldIdentifier]
  55. // CHECK:STDERR: var _: ();
  56. // CHECK:STDERR: ^
  57. // CHECK:STDERR:
  58. // CHECK:STDERR: fail_class.carbon:[[@LINE+4]]:3: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  59. // CHECK:STDERR: var _: ();
  60. // CHECK:STDERR: ^~~~~~~~~~
  61. // CHECK:STDERR:
  62. var _: ();
  63. }
  64. // --- fail_interface.carbon
  65. library "[[@TEST_NAME]]";
  66. interface I {
  67. // CHECK:STDERR: fail_interface.carbon:[[@LINE+4]]:7: error: semantics TODO: `_ used as associated constant name` [SemanticsTodo]
  68. // CHECK:STDERR: let _:! {};
  69. // CHECK:STDERR: ^~~~~~
  70. // CHECK:STDERR:
  71. let _:! {};
  72. }
  73. // --- fail_use.carbon
  74. fn F() -> {} {
  75. let _: {} = {};
  76. // CHECK:STDERR: fail_use.carbon:[[@LINE+12]]:10: error: expected expression [ExpectedExpr]
  77. // CHECK:STDERR: return _;
  78. // CHECK:STDERR: ^
  79. // CHECK:STDERR:
  80. // CHECK:STDERR: fail_use.carbon:[[@LINE+8]]:10: error: `return` statements must end with a `;` [ExpectedStatementSemi]
  81. // CHECK:STDERR: return _;
  82. // CHECK:STDERR: ^
  83. // CHECK:STDERR:
  84. // CHECK:STDERR: fail_use.carbon:[[@LINE+4]]:10: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  85. // CHECK:STDERR: return _;
  86. // CHECK:STDERR: ^
  87. // CHECK:STDERR:
  88. return _;
  89. }
  90. // CHECK:STDOUT: --- basic.carbon
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: constants {
  93. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  94. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_struct_type [concrete]
  95. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  96. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  97. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: imports {
  101. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  102. // CHECK:STDOUT: import Core//prelude
  103. // CHECK:STDOUT: import Core//prelude/...
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: file {
  108. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  109. // CHECK:STDOUT: .Core = imports.%Core
  110. // CHECK:STDOUT: .F = %F.decl
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %Core.import = import Core
  113. // CHECK:STDOUT: name_binding_decl {
  114. // CHECK:STDOUT: %_.patt.loc4: %pattern_type = binding_pattern _ [concrete]
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: %.loc4_9.1: type = splice_block %.loc4_9.3 [concrete = constants.%empty_struct_type] {
  117. // CHECK:STDOUT: %.loc4_9.2: %empty_struct_type = struct_literal ()
  118. // CHECK:STDOUT: %.loc4_9.3: type = converted %.loc4_9.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  121. // CHECK:STDOUT: %.loc4_14: %empty_struct_type = converted @__global_init.%.loc4, %empty_struct [concrete = constants.%empty_struct]
  122. // CHECK:STDOUT: %_.loc4: %empty_struct_type = bind_name _, %.loc4_14
  123. // CHECK:STDOUT: name_binding_decl {
  124. // CHECK:STDOUT: %_.patt.loc5: %pattern_type = binding_pattern _ [concrete]
  125. // CHECK:STDOUT: %.loc5_1: %pattern_type = var_pattern %_.patt.loc5 [concrete]
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: %_.var: ref %empty_struct_type = var _
  128. // CHECK:STDOUT: %.loc5_9.1: type = splice_block %.loc5_9.3 [concrete = constants.%empty_struct_type] {
  129. // CHECK:STDOUT: %.loc5_9.2: %empty_struct_type = struct_literal ()
  130. // CHECK:STDOUT: %.loc5_9.3: type = converted %.loc5_9.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT: %_.loc5: ref %empty_struct_type = bind_name _, %_.var
  133. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: fn @F() {
  137. // CHECK:STDOUT: !entry:
  138. // CHECK:STDOUT: name_binding_decl {
  139. // CHECK:STDOUT: %_.patt.loc8: %pattern_type = binding_pattern _ [concrete]
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT: %.loc8_16.1: %empty_struct_type = struct_literal ()
  142. // CHECK:STDOUT: %.loc8_11.1: type = splice_block %.loc8_11.3 [concrete = constants.%empty_struct_type] {
  143. // CHECK:STDOUT: %.loc8_11.2: %empty_struct_type = struct_literal ()
  144. // CHECK:STDOUT: %.loc8_11.3: type = converted %.loc8_11.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  147. // CHECK:STDOUT: %.loc8_16.2: %empty_struct_type = converted %.loc8_16.1, %empty_struct [concrete = constants.%empty_struct]
  148. // CHECK:STDOUT: %_.loc8: %empty_struct_type = bind_name _, %.loc8_16.2
  149. // CHECK:STDOUT: name_binding_decl {
  150. // CHECK:STDOUT: %_.patt.loc9: %pattern_type = binding_pattern _ [concrete]
  151. // CHECK:STDOUT: %.loc9_3.1: %pattern_type = var_pattern %_.patt.loc9 [concrete]
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: %_.var: ref %empty_struct_type = var _
  154. // CHECK:STDOUT: %.loc9_16.1: %empty_struct_type = struct_literal ()
  155. // CHECK:STDOUT: %.loc9_16.2: init %empty_struct_type = struct_init () to %_.var [concrete = constants.%empty_struct]
  156. // CHECK:STDOUT: %.loc9_3.2: init %empty_struct_type = converted %.loc9_16.1, %.loc9_16.2 [concrete = constants.%empty_struct]
  157. // CHECK:STDOUT: assign %_.var, %.loc9_3.2
  158. // CHECK:STDOUT: %.loc9_11.1: type = splice_block %.loc9_11.3 [concrete = constants.%empty_struct_type] {
  159. // CHECK:STDOUT: %.loc9_11.2: %empty_struct_type = struct_literal ()
  160. // CHECK:STDOUT: %.loc9_11.3: type = converted %.loc9_11.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: %_.loc9: ref %empty_struct_type = bind_name _, %_.var
  163. // CHECK:STDOUT: return
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: fn @__global_init() {
  167. // CHECK:STDOUT: !entry:
  168. // CHECK:STDOUT: %.loc4: %empty_struct_type = struct_literal ()
  169. // CHECK:STDOUT: %.loc5_14.1: %empty_struct_type = struct_literal ()
  170. // CHECK:STDOUT: %.loc5_14.2: init %empty_struct_type = struct_init () to file.%_.var [concrete = constants.%empty_struct]
  171. // CHECK:STDOUT: %.loc5_1: init %empty_struct_type = converted %.loc5_14.1, %.loc5_14.2 [concrete = constants.%empty_struct]
  172. // CHECK:STDOUT: assign file.%_.var, %.loc5_1
  173. // CHECK:STDOUT: return
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: --- function.carbon
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: constants {
  179. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  180. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_struct_type [concrete]
  181. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  182. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  183. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  184. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  185. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  186. // CHECK:STDOUT: %H.type: type = fn_type @H [concrete]
  187. // CHECK:STDOUT: %H: %H.type = struct_value () [concrete]
  188. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: imports {
  192. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  193. // CHECK:STDOUT: import Core//prelude
  194. // CHECK:STDOUT: import Core//prelude/...
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: file {
  199. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  200. // CHECK:STDOUT: .Core = imports.%Core
  201. // CHECK:STDOUT: .F = %F.decl
  202. // CHECK:STDOUT: .G = %G.decl
  203. // CHECK:STDOUT: .H = %H.decl
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT: %Core.import = import Core
  206. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  207. // CHECK:STDOUT: %_.patt: %pattern_type = binding_pattern _ [concrete]
  208. // CHECK:STDOUT: %_.param_patt: %pattern_type = value_param_pattern %_.patt, call_param0 [concrete]
  209. // CHECK:STDOUT: } {
  210. // CHECK:STDOUT: %_.param: %empty_struct_type = value_param call_param0
  211. // CHECK:STDOUT: %.loc4_10.1: type = splice_block %.loc4_10.3 [concrete = constants.%empty_struct_type] {
  212. // CHECK:STDOUT: %.loc4_10.2: %empty_struct_type = struct_literal ()
  213. // CHECK:STDOUT: %.loc4_10.3: type = converted %.loc4_10.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT: %_: %empty_struct_type = bind_name _, %_.param
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  218. // CHECK:STDOUT: %_.patt: %pattern_type = binding_pattern _ [concrete]
  219. // CHECK:STDOUT: %_.param_patt: %pattern_type = value_param_pattern %_.patt, call_param0 [concrete]
  220. // CHECK:STDOUT: } {
  221. // CHECK:STDOUT: %_.param: %empty_struct_type = value_param call_param0
  222. // CHECK:STDOUT: %.loc6_10.1: type = splice_block %.loc6_10.3 [concrete = constants.%empty_struct_type] {
  223. // CHECK:STDOUT: %.loc6_10.2: %empty_struct_type = struct_literal ()
  224. // CHECK:STDOUT: %.loc6_10.3: type = converted %.loc6_10.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT: %_: %empty_struct_type = bind_name _, %_.param
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [concrete = constants.%H] {} {}
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: fn @F(%_.param: %empty_struct_type);
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: fn @G(%_.param: %empty_struct_type) {
  234. // CHECK:STDOUT: !entry:
  235. // CHECK:STDOUT: return
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: fn @H() {
  239. // CHECK:STDOUT: !entry:
  240. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  241. // CHECK:STDOUT: %.loc9_6.1: %empty_struct_type = struct_literal ()
  242. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  243. // CHECK:STDOUT: %.loc9_6.2: %empty_struct_type = converted %.loc9_6.1, %empty_struct [concrete = constants.%empty_struct]
  244. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref(%.loc9_6.2)
  245. // CHECK:STDOUT: return
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: --- function_generic.carbon
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: constants {
  251. // CHECK:STDOUT: %_: type = bind_symbolic_name _, 0 [symbolic]
  252. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  253. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  254. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  255. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  256. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  257. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  258. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  259. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%empty_struct_type) [concrete]
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: imports {
  263. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  264. // CHECK:STDOUT: import Core//prelude
  265. // CHECK:STDOUT: import Core//prelude/...
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: file {
  270. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  271. // CHECK:STDOUT: .Core = imports.%Core
  272. // CHECK:STDOUT: .F = %F.decl
  273. // CHECK:STDOUT: .G = %G.decl
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT: %Core.import = import Core
  276. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  277. // CHECK:STDOUT: %_.patt: %pattern_type = symbolic_binding_pattern _, 0 [concrete]
  278. // CHECK:STDOUT: } {
  279. // CHECK:STDOUT: %_.loc4_6.1: type = bind_symbolic_name _, 0 [symbolic = %_.loc4_6.2 (constants.%_)]
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: generic fn @F(%_.loc4_6.1: type) {
  285. // CHECK:STDOUT: %_.loc4_6.2: type = bind_symbolic_name _, 0 [symbolic = %_.loc4_6.2 (constants.%_)]
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: !definition:
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: fn() {
  290. // CHECK:STDOUT: !entry:
  291. // CHECK:STDOUT: return
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: fn @G() {
  296. // CHECK:STDOUT: !entry:
  297. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  298. // CHECK:STDOUT: %.loc7_6: %empty_struct_type = struct_literal ()
  299. // CHECK:STDOUT: %.loc7_7: type = converted %.loc7_6, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  300. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%empty_struct_type) [concrete = constants.%F.specific_fn]
  301. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn()
  302. // CHECK:STDOUT: return
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: specific @F(constants.%_) {
  306. // CHECK:STDOUT: %_.loc4_6.2 => constants.%_
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: specific @F(constants.%empty_struct_type) {
  310. // CHECK:STDOUT: %_.loc4_6.2 => constants.%empty_struct_type
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: !definition:
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: --- fail_function_generic_undefined.carbon
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: constants {
  318. // CHECK:STDOUT: %_: type = bind_symbolic_name _, 0 [symbolic]
  319. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  320. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  321. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  322. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  323. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  324. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  325. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  326. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%empty_struct_type) [concrete]
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: imports {
  330. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  331. // CHECK:STDOUT: import Core//prelude
  332. // CHECK:STDOUT: import Core//prelude/...
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: file {
  337. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  338. // CHECK:STDOUT: .Core = imports.%Core
  339. // CHECK:STDOUT: .F = %F.decl
  340. // CHECK:STDOUT: .G = %G.decl
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT: %Core.import = import Core
  343. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  344. // CHECK:STDOUT: %_.patt: %pattern_type = symbolic_binding_pattern _, 0 [concrete]
  345. // CHECK:STDOUT: } {
  346. // CHECK:STDOUT: %_.loc4_6.1: type = bind_symbolic_name _, 0 [symbolic = %_.loc4_6.2 (constants.%_)]
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: generic fn @F(%_.loc4_6.1: type) {
  352. // CHECK:STDOUT: %_.loc4_6.2: type = bind_symbolic_name _, 0 [symbolic = %_.loc4_6.2 (constants.%_)]
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: fn();
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: fn @G() {
  358. // CHECK:STDOUT: !entry:
  359. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  360. // CHECK:STDOUT: %.loc14_6: %empty_struct_type = struct_literal ()
  361. // CHECK:STDOUT: %.loc14_7: type = converted %.loc14_6, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  362. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%empty_struct_type) [concrete = constants.%F.specific_fn]
  363. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn()
  364. // CHECK:STDOUT: return
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: specific @F(constants.%_) {
  368. // CHECK:STDOUT: %_.loc4_6.2 => constants.%_
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: specific @F(constants.%empty_struct_type) {
  372. // CHECK:STDOUT: %_.loc4_6.2 => constants.%empty_struct_type
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: --- function_implict.carbon
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: constants {
  378. // CHECK:STDOUT: %_: type = bind_symbolic_name _, 0 [symbolic]
  379. // CHECK:STDOUT: %pattern_type: type = pattern_type type [concrete]
  380. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  381. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  382. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  383. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: imports {
  387. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  388. // CHECK:STDOUT: import Core//prelude
  389. // CHECK:STDOUT: import Core//prelude/...
  390. // CHECK:STDOUT: }
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: file {
  394. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  395. // CHECK:STDOUT: .Core = imports.%Core
  396. // CHECK:STDOUT: .F = %F.decl
  397. // CHECK:STDOUT: .G = %G.decl
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT: %Core.import = import Core
  400. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  401. // CHECK:STDOUT: %_.patt: %pattern_type = symbolic_binding_pattern _, 0 [concrete]
  402. // CHECK:STDOUT: } {
  403. // CHECK:STDOUT: %_.loc4_6.1: type = bind_symbolic_name _, 0 [symbolic = %_.loc4_6.2 (constants.%_)]
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  406. // CHECK:STDOUT: %_.patt: %pattern_type = symbolic_binding_pattern _, 0 [concrete]
  407. // CHECK:STDOUT: } {
  408. // CHECK:STDOUT: %_.loc6_6.1: type = bind_symbolic_name _, 0 [symbolic = %_.loc6_6.2 (constants.%_)]
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT: }
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: generic fn @F(%_.loc4_6.1: type) {
  413. // CHECK:STDOUT: %_.loc4_6.2: type = bind_symbolic_name _, 0 [symbolic = %_.loc4_6.2 (constants.%_)]
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: fn();
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: generic fn @G(%_.loc6_6.1: type) {
  419. // CHECK:STDOUT: %_.loc6_6.2: type = bind_symbolic_name _, 0 [symbolic = %_.loc6_6.2 (constants.%_)]
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: !definition:
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: fn() {
  424. // CHECK:STDOUT: !entry:
  425. // CHECK:STDOUT: return
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: specific @F(constants.%_) {
  430. // CHECK:STDOUT: %_.loc4_6.2 => constants.%_
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: specific @G(constants.%_) {
  434. // CHECK:STDOUT: %_.loc6_6.2 => constants.%_
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT:
  437. // CHECK:STDOUT: --- fail_class.carbon
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: constants {
  440. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: file {}
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: class @C {
  446. // CHECK:STDOUT: complete_type_witness = invalid
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: !members:
  449. // CHECK:STDOUT: .Self = constants.%C
  450. // CHECK:STDOUT: }
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: --- fail_interface.carbon
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: constants {
  455. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  456. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  457. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  458. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  459. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%_ [concrete]
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: imports {
  463. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  464. // CHECK:STDOUT: import Core//prelude
  465. // CHECK:STDOUT: import Core//prelude/...
  466. // CHECK:STDOUT: }
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: file {
  470. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  471. // CHECK:STDOUT: .Core = imports.%Core
  472. // CHECK:STDOUT: .I = %I.decl
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT: %Core.import = import Core
  475. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT:
  478. // CHECK:STDOUT: interface @I {
  479. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  480. // CHECK:STDOUT: %_: %empty_struct_type = assoc_const_decl @_ [concrete] {
  481. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%_ [concrete = constants.%assoc0]
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: !members:
  485. // CHECK:STDOUT: .Self = %Self
  486. // CHECK:STDOUT: ._ = @_.%assoc0
  487. // CHECK:STDOUT: witness = (%_)
  488. // CHECK:STDOUT: }
  489. // CHECK:STDOUT:
  490. // CHECK:STDOUT: generic assoc_const @_(@I.%Self: %I.type) {
  491. // CHECK:STDOUT: assoc_const _:! %empty_struct_type;
  492. // CHECK:STDOUT: }
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: specific @_(constants.%Self) {}
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: --- fail_use.carbon
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: constants {
  499. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  500. // CHECK:STDOUT: }
  501. // CHECK:STDOUT:
  502. // CHECK:STDOUT: file {}
  503. // CHECK:STDOUT:
  504. // CHECK:STDOUT: fn @F() -> %empty_struct_type;
  505. // CHECK:STDOUT: