designator.carbon 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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: --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/where_expr/designator.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/designator.carbon
  13. // --- success.carbon
  14. library "[[@TEST_NAME]]";
  15. interface I {
  16. let Member:! type;
  17. }
  18. fn PeriodSelf(T:! I where .Self == ());
  19. fn PeriodMember(U:! I where .Member == ());
  20. fn TypeSelfImpls(V:! type where .Self impls I);
  21. // --- fail_wrong_member.carbon
  22. library "[[@TEST_NAME]]";
  23. interface J {
  24. let Member:! type;
  25. }
  26. // CHECK:STDERR: fail_wrong_member.carbon:[[@LINE+4]]:31: error: member name `Mismatch` not found in `J` [MemberNameNotFoundInInstScope]
  27. // CHECK:STDERR: fn PeriodMismatch(W:! J where .Mismatch = {});
  28. // CHECK:STDERR: ^~~~~~~~~
  29. // CHECK:STDERR:
  30. fn PeriodMismatch(W:! J where .Mismatch = {});
  31. // --- fail_designator_matches_var.carbon
  32. library "[[@TEST_NAME]]";
  33. fn Foo() -> () {
  34. var x: ();
  35. // CHECK:STDERR: fail_designator_matches_var.carbon:[[@LINE+5]]:10: error: name `.Self` not found [NameNotFound]
  36. // CHECK:STDERR: return .x;
  37. // CHECK:STDERR: ^~
  38. // CHECK:STDERR: fail_designator_matches_var.carbon: note: designator may only be used when `.Self` is in scope [NoPeriodSelfForDesignator]
  39. // CHECK:STDERR:
  40. return .x;
  41. }
  42. // --- fail_unknown_designator.carbon
  43. library "[[@TEST_NAME]]";
  44. fn Bar() -> () {
  45. // CHECK:STDERR: fail_unknown_designator.carbon:[[@LINE+5]]:10: error: name `.Self` not found [NameNotFound]
  46. // CHECK:STDERR: return .undef;
  47. // CHECK:STDERR: ^~~~~~
  48. // CHECK:STDERR: fail_unknown_designator.carbon: note: designator may only be used when `.Self` is in scope [NoPeriodSelfForDesignator]
  49. // CHECK:STDERR:
  50. return .undef;
  51. }
  52. // --- fail_dot_self_method_return_value.carbon
  53. library "[[@TEST_NAME]]";
  54. class C {
  55. // CHECK:STDERR: fail_dot_self_method_return_value.carbon:[[@LINE+4]]:27: error: name `.Self` not found [NameNotFound]
  56. // CHECK:STDERR: fn F() -> Self { return .Self; }
  57. // CHECK:STDERR: ^~~~~
  58. // CHECK:STDERR:
  59. fn F() -> Self { return .Self; }
  60. }
  61. // --- fail_dot_self_method_return_type.carbon
  62. library "[[@TEST_NAME]]";
  63. class D {
  64. // CHECK:STDERR: fail_dot_self_method_return_type.carbon:[[@LINE+4]]:13: error: name `.Self` not found [NameNotFound]
  65. // CHECK:STDERR: fn G() -> .Self { return Self; }
  66. // CHECK:STDERR: ^~~~~
  67. // CHECK:STDERR:
  68. fn G() -> .Self { return Self; }
  69. }
  70. // CHECK:STDOUT: --- success.carbon
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: constants {
  73. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  74. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  75. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  76. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%Member [concrete]
  77. // CHECK:STDOUT: %.Self.258: %I.type = bind_symbolic_name .Self [symbolic_self]
  78. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  79. // CHECK:STDOUT: %I_where.type: type = facet_type <@I where TODO> [concrete]
  80. // CHECK:STDOUT: %T: %I_where.type = bind_symbolic_name T, 0 [symbolic]
  81. // CHECK:STDOUT: %pattern_type.f03: type = pattern_type %I_where.type [concrete]
  82. // CHECK:STDOUT: %PeriodSelf.type: type = fn_type @PeriodSelf [concrete]
  83. // CHECK:STDOUT: %PeriodSelf: %PeriodSelf.type = struct_value () [concrete]
  84. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.258 [symbolic_self]
  85. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %.Self.258, @I [symbolic_self]
  86. // CHECK:STDOUT: %I.facet: %I.type = facet_value %.Self.as_type, (%I.lookup_impl_witness) [symbolic_self]
  87. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %I.lookup_impl_witness, element0 [symbolic_self]
  88. // CHECK:STDOUT: %U: %I_where.type = bind_symbolic_name U, 0 [symbolic]
  89. // CHECK:STDOUT: %PeriodMember.type: type = fn_type @PeriodMember [concrete]
  90. // CHECK:STDOUT: %PeriodMember: %PeriodMember.type = struct_value () [concrete]
  91. // CHECK:STDOUT: %.Self.644: type = bind_symbolic_name .Self [symbolic_self]
  92. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls @I> [concrete]
  93. // CHECK:STDOUT: %V: %type_where = bind_symbolic_name V, 0 [symbolic]
  94. // CHECK:STDOUT: %pattern_type.2b5: type = pattern_type %type_where [concrete]
  95. // CHECK:STDOUT: %TypeSelfImpls.type: type = fn_type @TypeSelfImpls [concrete]
  96. // CHECK:STDOUT: %TypeSelfImpls: %TypeSelfImpls.type = struct_value () [concrete]
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: imports {
  100. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  101. // CHECK:STDOUT: import Core//prelude
  102. // CHECK:STDOUT: import Core//prelude/...
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT:
  106. // CHECK:STDOUT: file {
  107. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  108. // CHECK:STDOUT: .Core = imports.%Core
  109. // CHECK:STDOUT: .I = %I.decl
  110. // CHECK:STDOUT: .PeriodSelf = %PeriodSelf.decl
  111. // CHECK:STDOUT: .PeriodMember = %PeriodMember.decl
  112. // CHECK:STDOUT: .TypeSelfImpls = %TypeSelfImpls.decl
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %Core.import = import Core
  115. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  116. // CHECK:STDOUT: %PeriodSelf.decl: %PeriodSelf.type = fn_decl @PeriodSelf [concrete = constants.%PeriodSelf] {
  117. // CHECK:STDOUT: %T.patt: %pattern_type.f03 = symbolic_binding_pattern T, 0 [concrete]
  118. // CHECK:STDOUT: } {
  119. // CHECK:STDOUT: %.loc8_21.1: type = splice_block %.loc8_21.2 [concrete = constants.%I_where.type] {
  120. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  121. // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self.258]
  122. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self.258]
  123. // CHECK:STDOUT: %.loc8_37: %empty_tuple.type = tuple_literal ()
  124. // CHECK:STDOUT: %.loc8_21.2: type = where_expr %.Self [concrete = constants.%I_where.type] {
  125. // CHECK:STDOUT: requirement_equivalent %.Self.ref, %.loc8_37
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: }
  128. // CHECK:STDOUT: %T.loc8_15.1: %I_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_15.2 (constants.%T)]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %PeriodMember.decl: %PeriodMember.type = fn_decl @PeriodMember [concrete = constants.%PeriodMember] {
  131. // CHECK:STDOUT: %U.patt: %pattern_type.f03 = symbolic_binding_pattern U, 0 [concrete]
  132. // CHECK:STDOUT: } {
  133. // CHECK:STDOUT: %.loc10_23.1: type = splice_block %.loc10_23.2 [concrete = constants.%I_where.type] {
  134. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  135. // CHECK:STDOUT: %.Self: %I.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self.258]
  136. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self.258]
  137. // CHECK:STDOUT: %Member.ref: %I.assoc_type = name_ref Member, @Member.%assoc0 [concrete = constants.%assoc0]
  138. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
  139. // CHECK:STDOUT: %.loc10_29: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
  140. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  141. // CHECK:STDOUT: %.loc10_41: %empty_tuple.type = tuple_literal ()
  142. // CHECK:STDOUT: %.loc10_23.2: type = where_expr %.Self [concrete = constants.%I_where.type] {
  143. // CHECK:STDOUT: requirement_equivalent %impl.elem0, %.loc10_41
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: %U.loc10_17.1: %I_where.type = bind_symbolic_name U, 0 [symbolic = %U.loc10_17.2 (constants.%U)]
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: %TypeSelfImpls.decl: %TypeSelfImpls.type = fn_decl @TypeSelfImpls [concrete = constants.%TypeSelfImpls] {
  149. // CHECK:STDOUT: %V.patt: %pattern_type.2b5 = symbolic_binding_pattern V, 0 [concrete]
  150. // CHECK:STDOUT: } {
  151. // CHECK:STDOUT: %.loc12_27.1: type = splice_block %.loc12_27.2 [concrete = constants.%type_where] {
  152. // CHECK:STDOUT: %.Self: type = bind_symbolic_name .Self [symbolic_self = constants.%.Self.644]
  153. // CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self [symbolic_self = constants.%.Self.644]
  154. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  155. // CHECK:STDOUT: %.loc12_27.2: type = where_expr %.Self [concrete = constants.%type_where] {
  156. // CHECK:STDOUT: requirement_impls %.Self.ref, %I.ref
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: %V.loc12_18.1: %type_where = bind_symbolic_name V, 0 [symbolic = %V.loc12_18.2 (constants.%V)]
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: interface @I {
  164. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  165. // CHECK:STDOUT: %Member: type = assoc_const_decl @Member [concrete] {
  166. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%Member [concrete = constants.%assoc0]
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: !members:
  170. // CHECK:STDOUT: .Self = %Self
  171. // CHECK:STDOUT: .Member = @Member.%assoc0
  172. // CHECK:STDOUT: witness = (%Member)
  173. // CHECK:STDOUT: }
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: generic assoc_const @Member(@I.%Self: %I.type) {
  176. // CHECK:STDOUT: assoc_const Member:! type;
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: generic fn @PeriodSelf(%T.loc8_15.1: %I_where.type) {
  180. // CHECK:STDOUT: %T.loc8_15.2: %I_where.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_15.2 (constants.%T)]
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: fn();
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: generic fn @PeriodMember(%U.loc10_17.1: %I_where.type) {
  186. // CHECK:STDOUT: %U.loc10_17.2: %I_where.type = bind_symbolic_name U, 0 [symbolic = %U.loc10_17.2 (constants.%U)]
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: fn();
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: generic fn @TypeSelfImpls(%V.loc12_18.1: %type_where) {
  192. // CHECK:STDOUT: %V.loc12_18.2: %type_where = bind_symbolic_name V, 0 [symbolic = %V.loc12_18.2 (constants.%V)]
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: fn();
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: specific @Member(constants.%Self) {}
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: specific @PeriodSelf(constants.%T) {
  200. // CHECK:STDOUT: %T.loc8_15.2 => constants.%T
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: specific @Member(constants.%I.facet) {}
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: specific @PeriodMember(constants.%U) {
  206. // CHECK:STDOUT: %U.loc10_17.2 => constants.%U
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: specific @TypeSelfImpls(constants.%V) {
  210. // CHECK:STDOUT: %V.loc12_18.2 => constants.%V
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: --- fail_wrong_member.carbon
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: constants {
  216. // CHECK:STDOUT: %J.type: type = facet_type <@J> [concrete]
  217. // CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic]
  218. // CHECK:STDOUT: %J.assoc_type: type = assoc_entity_type @J [concrete]
  219. // CHECK:STDOUT: %assoc0: %J.assoc_type = assoc_entity element0, @J.%Member [concrete]
  220. // CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self [symbolic_self]
  221. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  222. // CHECK:STDOUT: %PeriodMismatch.type: type = fn_type @PeriodMismatch [concrete]
  223. // CHECK:STDOUT: %PeriodMismatch: %PeriodMismatch.type = struct_value () [concrete]
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: imports {
  227. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  228. // CHECK:STDOUT: import Core//prelude
  229. // CHECK:STDOUT: import Core//prelude/...
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: file {
  234. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  235. // CHECK:STDOUT: .Core = imports.%Core
  236. // CHECK:STDOUT: .J = %J.decl
  237. // CHECK:STDOUT: .PeriodMismatch = %PeriodMismatch.decl
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT: %Core.import = import Core
  240. // CHECK:STDOUT: %J.decl: type = interface_decl @J [concrete = constants.%J.type] {} {}
  241. // CHECK:STDOUT: %PeriodMismatch.decl: %PeriodMismatch.type = fn_decl @PeriodMismatch [concrete = constants.%PeriodMismatch] {
  242. // CHECK:STDOUT: %W.patt: <error> = symbolic_binding_pattern W, 0 [concrete]
  243. // CHECK:STDOUT: } {
  244. // CHECK:STDOUT: %.loc12_25.1: type = splice_block %.loc12_25.2 [concrete = <error>] {
  245. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  246. // CHECK:STDOUT: %.Self: %J.type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  247. // CHECK:STDOUT: %.Self.ref: %J.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  248. // CHECK:STDOUT: %Mismatch.ref: <error> = name_ref Mismatch, <error> [concrete = <error>]
  249. // CHECK:STDOUT: %.loc12_44: %empty_struct_type = struct_literal ()
  250. // CHECK:STDOUT: %.loc12_25.2: type = where_expr %.Self [concrete = <error>] {
  251. // CHECK:STDOUT: requirement_rewrite %Mismatch.ref, <error>
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT: %W: <error> = bind_symbolic_name W, 0 [concrete = <error>]
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: interface @J {
  259. // CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  260. // CHECK:STDOUT: %Member: type = assoc_const_decl @Member [concrete] {
  261. // CHECK:STDOUT: %assoc0: %J.assoc_type = assoc_entity element0, @J.%Member [concrete = constants.%assoc0]
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: !members:
  265. // CHECK:STDOUT: .Self = %Self
  266. // CHECK:STDOUT: .Member = @Member.%assoc0
  267. // CHECK:STDOUT: .Mismatch = <poisoned>
  268. // CHECK:STDOUT: witness = (%Member)
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: generic assoc_const @Member(@J.%Self: %J.type) {
  272. // CHECK:STDOUT: assoc_const Member:! type;
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: generic fn @PeriodMismatch(%W: <error>) {
  276. // CHECK:STDOUT: fn();
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: specific @Member(constants.%Self) {}
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: specific @PeriodMismatch(<error>) {}
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: --- fail_designator_matches_var.carbon
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: constants {
  286. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  287. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  288. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [concrete]
  289. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [concrete]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: imports {
  293. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  294. // CHECK:STDOUT: import Core//prelude
  295. // CHECK:STDOUT: import Core//prelude/...
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: file {
  300. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  301. // CHECK:STDOUT: .Core = imports.%Core
  302. // CHECK:STDOUT: .Foo = %Foo.decl
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT: %Core.import = import Core
  305. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [concrete = constants.%Foo] {
  306. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  307. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  308. // CHECK:STDOUT: } {
  309. // CHECK:STDOUT: %.loc4_14.1: %empty_tuple.type = tuple_literal ()
  310. // CHECK:STDOUT: %.loc4_14.2: type = converted %.loc4_14.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  311. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  312. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: fn @Foo() -> %empty_tuple.type {
  317. // CHECK:STDOUT: !entry:
  318. // CHECK:STDOUT: name_binding_decl {
  319. // CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
  320. // CHECK:STDOUT: %x.var_patt: %pattern_type = var_pattern %x.patt [concrete]
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var %x.var_patt
  323. // CHECK:STDOUT: %.loc5_11.1: type = splice_block %.loc5_11.3 [concrete = constants.%empty_tuple.type] {
  324. // CHECK:STDOUT: %.loc5_11.2: %empty_tuple.type = tuple_literal ()
  325. // CHECK:STDOUT: %.loc5_11.3: type = converted %.loc5_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  328. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, <error> [concrete = <error>]
  329. // CHECK:STDOUT: %x.ref: <error> = name_ref x, <error> [concrete = <error>]
  330. // CHECK:STDOUT: return <error>
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: --- fail_unknown_designator.carbon
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: constants {
  336. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  337. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  338. // CHECK:STDOUT: %Bar.type: type = fn_type @Bar [concrete]
  339. // CHECK:STDOUT: %Bar: %Bar.type = struct_value () [concrete]
  340. // CHECK:STDOUT: }
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: imports {
  343. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  344. // CHECK:STDOUT: import Core//prelude
  345. // CHECK:STDOUT: import Core//prelude/...
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: file {
  350. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  351. // CHECK:STDOUT: .Core = imports.%Core
  352. // CHECK:STDOUT: .Bar = %Bar.decl
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT: %Core.import = import Core
  355. // CHECK:STDOUT: %Bar.decl: %Bar.type = fn_decl @Bar [concrete = constants.%Bar] {
  356. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  357. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  358. // CHECK:STDOUT: } {
  359. // CHECK:STDOUT: %.loc4_14.1: %empty_tuple.type = tuple_literal ()
  360. // CHECK:STDOUT: %.loc4_14.2: type = converted %.loc4_14.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  361. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  362. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: fn @Bar() -> %empty_tuple.type {
  367. // CHECK:STDOUT: !entry:
  368. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, <error> [concrete = <error>]
  369. // CHECK:STDOUT: %undef.ref: <error> = name_ref undef, <error> [concrete = <error>]
  370. // CHECK:STDOUT: return <error>
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT:
  373. // CHECK:STDOUT: --- fail_dot_self_method_return_value.carbon
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: constants {
  376. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  377. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  378. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  379. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  380. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  381. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: imports {
  385. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  386. // CHECK:STDOUT: import Core//prelude
  387. // CHECK:STDOUT: import Core//prelude/...
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: file {
  392. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  393. // CHECK:STDOUT: .Core = imports.%Core
  394. // CHECK:STDOUT: .C = %C.decl
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT: %Core.import = import Core
  397. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: class @C {
  401. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  402. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  403. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  404. // CHECK:STDOUT: } {
  405. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  406. // CHECK:STDOUT: %return.param: ref %C = out_param call_param0
  407. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  410. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  411. // CHECK:STDOUT: complete_type_witness = %complete_type
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: !members:
  414. // CHECK:STDOUT: .Self = constants.%C
  415. // CHECK:STDOUT: .F = %F.decl
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: fn @F() -> %return.param: %C {
  419. // CHECK:STDOUT: !entry:
  420. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, <error> [concrete = <error>]
  421. // CHECK:STDOUT: return <error> to %return
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: --- fail_dot_self_method_return_type.carbon
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: constants {
  427. // CHECK:STDOUT: %D: type = class_type @D [concrete]
  428. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  429. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  430. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  431. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: imports {
  435. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  436. // CHECK:STDOUT: import Core//prelude
  437. // CHECK:STDOUT: import Core//prelude/...
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: file {
  442. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  443. // CHECK:STDOUT: .Core = imports.%Core
  444. // CHECK:STDOUT: .D = %D.decl
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT: %Core.import = import Core
  447. // CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {}
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: class @D {
  451. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  452. // CHECK:STDOUT: %return.patt: <error> = return_slot_pattern [concrete]
  453. // CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, call_param0 [concrete]
  454. // CHECK:STDOUT: } {
  455. // CHECK:STDOUT: %.Self.ref: <error> = name_ref .Self, <error> [concrete = <error>]
  456. // CHECK:STDOUT: %return.param: ref <error> = out_param call_param0
  457. // CHECK:STDOUT: %return: ref <error> = return_slot %return.param
  458. // CHECK:STDOUT: }
  459. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  460. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  461. // CHECK:STDOUT: complete_type_witness = %complete_type
  462. // CHECK:STDOUT:
  463. // CHECK:STDOUT: !members:
  464. // CHECK:STDOUT: .Self = constants.%D
  465. // CHECK:STDOUT: .G = %G.decl
  466. // CHECK:STDOUT: }
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: fn @G() -> <error> {
  469. // CHECK:STDOUT: !entry:
  470. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%D [concrete = constants.%D]
  471. // CHECK:STDOUT: return <error>
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT: