underscore.carbon 22 KB

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