underscore.carbon 24 KB

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