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