impl_assoc_const.carbon 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/impl_assoc_const.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/impl_assoc_const.carbon
  12. // --- success.carbon
  13. library "[[@TEST_NAME]]";
  14. interface I { let T:! type; }
  15. impl () as I where .T = {} {}
  16. // --- success_associated.carbon
  17. library "[[@TEST_NAME]]";
  18. interface I { let T:! type; let U:! type; }
  19. impl () as I where .T = .U and .U = {} {}
  20. // --- redecl.carbon
  21. library "[[@TEST_NAME]]";
  22. interface I2 { let T2:! type; }
  23. impl () as I2 where .T2 = {};
  24. impl () as I2 where .T2 = {} {}
  25. // --- fail_redecl_adds_rewrites.carbon
  26. library "[[@TEST_NAME]]";
  27. interface I3 { let T3:! type; }
  28. // CHECK:STDERR: fail_redecl_adds_rewrites.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  29. // CHECK:STDERR: impl () as I3;
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~
  31. // CHECK:STDERR:
  32. impl () as I3;
  33. impl () as I3 where .T3 = {} {}
  34. // --- fail_mismatch.carbon
  35. library "[[@TEST_NAME]]";
  36. interface J { let U:! type; }
  37. // CHECK:STDERR: fail_mismatch.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  38. // CHECK:STDERR: impl () as J where .U = {};
  39. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. // CHECK:STDERR:
  41. impl () as J where .U = {};
  42. impl () as J where .U = () {}
  43. // --- fail_mismatch_bad_value.carbon
  44. library "[[@TEST_NAME]]";
  45. interface I4 {
  46. let T4:! type;
  47. let T5:! type;
  48. let T6:! type;
  49. }
  50. // CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+8]]:27: error: name `BAD1` not found [NameNotFound]
  51. // CHECK:STDERR: impl () as I4 where .T4 = BAD1 and .T5 = {.a: {}} and .T6 = BAD2;
  52. // CHECK:STDERR: ^~~~
  53. // CHECK:STDERR:
  54. // CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+4]]:61: error: name `BAD2` not found [NameNotFound]
  55. // CHECK:STDERR: impl () as I4 where .T4 = BAD1 and .T5 = {.a: {}} and .T6 = BAD2;
  56. // CHECK:STDERR: ^~~~
  57. // CHECK:STDERR:
  58. impl () as I4 where .T4 = BAD1 and .T5 = {.a: {}} and .T6 = BAD2;
  59. // CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+8]]:46: error: name `BAD3` not found [NameNotFound]
  60. // CHECK:STDERR: impl () as I4 where .T4 = {.b: {}} and .T5 = BAD3 and .T6 = BAD4 {}
  61. // CHECK:STDERR: ^~~~
  62. // CHECK:STDERR:
  63. // CHECK:STDERR: fail_mismatch_bad_value.carbon:[[@LINE+4]]:61: error: name `BAD4` not found [NameNotFound]
  64. // CHECK:STDERR: impl () as I4 where .T4 = {.b: {}} and .T5 = BAD3 and .T6 = BAD4 {}
  65. // CHECK:STDERR: ^~~~
  66. // CHECK:STDERR:
  67. impl () as I4 where .T4 = {.b: {}} and .T5 = BAD3 and .T6 = BAD4 {}
  68. // --- fail_missing_on_definition.carbon
  69. library "[[@TEST_NAME]]";
  70. interface K { let V:! type; }
  71. impl () as K where .V = {};
  72. // CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE+11]]:1: error: associated constant V not given a value in impl of interface K [ImplAssociatedConstantNeedsValue]
  73. // CHECK:STDERR: impl () as K {}
  74. // CHECK:STDERR: ^~~~~~~~~~~~~~
  75. // CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE-6]]:19: note: associated constant declared here [AssociatedConstantHere]
  76. // CHECK:STDERR: interface K { let V:! type; }
  77. // CHECK:STDERR: ^~~~~~~~
  78. // CHECK:STDERR:
  79. // CHECK:STDERR: fail_missing_on_definition.carbon:[[@LINE-8]]:1: error: impl declared but not defined [ImplMissingDefinition]
  80. // CHECK:STDERR: impl () as K where .V = {};
  81. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. // CHECK:STDERR:
  83. impl () as K {}
  84. // --- fail_two_different.carbon
  85. library "[[@TEST_NAME]]";
  86. interface L { let W:! type; }
  87. // CHECK:STDERR: fail_two_different.carbon:[[@LINE+4]]:12: error: associated constant `.(L.W)` given two different values `{}` and `()` [AssociatedConstantWithDifferentValues]
  88. // CHECK:STDERR: impl () as L where .W = {} and .W = () {}
  89. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. // CHECK:STDERR:
  91. impl () as L where .W = {} and .W = () {}
  92. // --- fail_two_different_first_associated.carbon
  93. library "[[@TEST_NAME]]";
  94. interface L2 { let W2:! type; let X2:! type; }
  95. // CHECK:STDERR: fail_two_different_first_associated.carbon:[[@LINE+4]]:12: error: associated constant `.(L2.W2)` given two different values `.(L2.X2)` and `()` [AssociatedConstantWithDifferentValues]
  96. // CHECK:STDERR: impl () as L2 where .W2 = .X2 and .W2 = () {}
  97. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. // CHECK:STDERR:
  99. impl () as L2 where .W2 = .X2 and .W2 = () {}
  100. // --- fail_two_different_second_associated.carbon
  101. library "[[@TEST_NAME]]";
  102. interface L2 { let W2:! type; let X2:! type; }
  103. // CHECK:STDERR: fail_two_different_second_associated.carbon:[[@LINE+4]]:12: error: associated constant `.(L2.W2)` given two different values `()` and `.(L2.X2)` [AssociatedConstantWithDifferentValues]
  104. // CHECK:STDERR: impl () as L2 where .W2 = () and .W2 = .X2 {}
  105. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  106. // CHECK:STDERR:
  107. impl () as L2 where .W2 = () and .W2 = .X2 {}
  108. // --- fail_two_different_first_bad.carbon
  109. library "[[@TEST_NAME]]";
  110. interface L2 { let W2:! type; }
  111. // CHECK:STDERR: fail_two_different_first_bad.carbon:[[@LINE+4]]:27: error: name `BAD5` not found [NameNotFound]
  112. // CHECK:STDERR: impl () as L2 where .W2 = BAD5 and .W2 = () {}
  113. // CHECK:STDERR: ^~~~
  114. // CHECK:STDERR:
  115. impl () as L2 where .W2 = BAD5 and .W2 = () {}
  116. // --- fail_two_different_second_bad.carbon
  117. library "[[@TEST_NAME]]";
  118. interface L3 { let W3:! type; }
  119. // CHECK:STDERR: fail_two_different_second_bad.carbon:[[@LINE+4]]:40: error: name `BAD6` not found [NameNotFound]
  120. // CHECK:STDERR: impl () as L3 where .W3 = {} and .W3 = BAD6 {}
  121. // CHECK:STDERR: ^~~~
  122. // CHECK:STDERR:
  123. impl () as L3 where .W3 = {} and .W3 = BAD6 {}
  124. // --- fail_two_different_both_bad.carbon
  125. library "[[@TEST_NAME]]";
  126. interface L4 { let W4:! type; }
  127. // CHECK:STDERR: fail_two_different_both_bad.carbon:[[@LINE+8]]:27: error: name `BAD7` not found [NameNotFound]
  128. // CHECK:STDERR: impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {}
  129. // CHECK:STDERR: ^~~~
  130. // CHECK:STDERR:
  131. // CHECK:STDERR: fail_two_different_both_bad.carbon:[[@LINE+4]]:42: error: name `BAD8` not found [NameNotFound]
  132. // CHECK:STDERR: impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {}
  133. // CHECK:STDERR: ^~~~
  134. // CHECK:STDERR:
  135. impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {}
  136. // --- fail_many_different.carbon
  137. library "[[@TEST_NAME]]";
  138. interface L { let W:! type; }
  139. // The facet type should have a single rewrite with `<error>` in the RHS (they
  140. // are all errors, and they get deduped).
  141. //
  142. //@dump-sem-ir-begin
  143. // CHECK:STDERR: fail_many_different.carbon:[[@LINE+4]]:12: error: associated constant `.(L.W)` given two different values `((), (), ())` and `({}, (), ())` [AssociatedConstantWithDifferentValues]
  144. // CHECK:STDERR: impl () as L where .W = ((), (), ()) and .W = ({}, (), ()) and .W = ({}, {}, ()) and .W = ({}, (), {}) {}
  145. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146. // CHECK:STDERR:
  147. impl () as L where .W = ((), (), ()) and .W = ({}, (), ()) and .W = ({}, {}, ()) and .W = ({}, (), {}) {}
  148. //@dump-sem-ir-end
  149. // --- repeated.carbon
  150. library "[[@TEST_NAME]]";
  151. interface M { let X:! type; }
  152. impl () as M where .X = {} and .X = {} {}
  153. // --- repeated_associated.carbon
  154. library "[[@TEST_NAME]]";
  155. interface M { let X:! type; let Y:! type; }
  156. impl () as M where .X = .Y and .X = .Y and .Y = () {}
  157. // --- repeated_concrete_value_and_associated.carbon
  158. library "[[@TEST_NAME]]";
  159. interface M { let X:! type; let Y:! type; }
  160. impl () as M where .X = () and .Y = .X and .X = .Y {}
  161. impl {} as M where .X = () and .X = .X and .Y = () {}
  162. // --- fail_repeated_and_different.carbon
  163. library "[[@TEST_NAME]]";
  164. interface M { let X:! type; }
  165. // CHECK:STDERR: fail_repeated_and_different.carbon:[[@LINE+4]]:12: error: associated constant `.(M.X)` given two different values `{}` and `()` [AssociatedConstantWithDifferentValues]
  166. // CHECK:STDERR: impl () as M where .X = {} and .X = () and .X = {} {}
  167. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  168. // CHECK:STDERR:
  169. impl () as M where .X = {} and .X = () and .X = {} {}
  170. // --- fail_cycle_single.carbon
  171. library "[[@TEST_NAME]]";
  172. interface M { let X:! type; }
  173. // This fails because it resolves to `.X = .X` which is cyclical.
  174. //
  175. // CHECK:STDERR: fail_cycle_single.carbon:[[@LINE+4]]:12: error: found cycle in facet type constraint for `.(M.X)` [FacetTypeConstraintCycle]
  176. // CHECK:STDERR: impl () as M where .X = .X {}
  177. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  178. // CHECK:STDERR:
  179. impl () as M where .X = .X {}
  180. // Even though `.X = ()` is specified, the rewrites are resolved left to right
  181. // and a cycle `.X = .X` is found first.
  182. //
  183. // CHECK:STDERR: fail_cycle_single.carbon:[[@LINE+4]]:12: error: found cycle in facet type constraint for `.(M.X)` [FacetTypeConstraintCycle]
  184. // CHECK:STDERR: impl () as M where .X = .X and .X = () {}
  185. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  186. // CHECK:STDERR:
  187. impl () as M where .X = .X and .X = () {}
  188. // --- fail_cycle.carbon
  189. library "[[@TEST_NAME]]";
  190. interface M { let X:! type; let Y:! type; let Z:! type; }
  191. // This fails because it resolves to `.X = .X` which is cyclical.
  192. // The value of .X and .Y becomes <error> but .Z is still valid.
  193. //
  194. //@dump-sem-ir-begin
  195. // CHECK:STDERR: fail_cycle.carbon:[[@LINE+4]]:12: error: found cycle in facet type constraint for `.(M.Y)` [FacetTypeConstraintCycle]
  196. // CHECK:STDERR: impl () as M where .X = .Y and .Y = .X and .Z = () {}
  197. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  198. // CHECK:STDERR:
  199. impl () as M where .X = .Y and .Y = .X and .Z = () {}
  200. //@dump-sem-ir-end
  201. // --- fail_todo_cycle_between_interfaces.carbon
  202. library "[[@TEST_NAME]]";
  203. interface I {
  204. let X1:! type;
  205. let X2:! type;
  206. }
  207. interface J {
  208. let X3:! type;
  209. }
  210. // TODO: This should fail due to a cyclic definition of each value. But right
  211. // now it's failing due to compound member access in a rewrite constraint not
  212. // working.
  213. //
  214. // CHECK:STDERR: fail_todo_cycle_between_interfaces.carbon:[[@LINE+12]]:45: error: expected identifier or `Self` after `.` [ExpectedIdentifierOrSelfAfterPeriod]
  215. // CHECK:STDERR: impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  216. // CHECK:STDERR: ^
  217. // CHECK:STDERR:
  218. // CHECK:STDERR: fail_todo_cycle_between_interfaces.carbon:[[@LINE+8]]:45: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  219. // CHECK:STDERR: impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  220. // CHECK:STDERR: ^
  221. // CHECK:STDERR:
  222. // CHECK:STDERR: fail_todo_cycle_between_interfaces.carbon:[[@LINE+4]]:71: error: expected identifier or `Self` after `.` [ExpectedIdentifierOrSelfAfterPeriod]
  223. // CHECK:STDERR: impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  224. // CHECK:STDERR: ^
  225. // CHECK:STDERR:
  226. impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  227. // --- non-type.carbon
  228. library "[[@TEST_NAME]]";
  229. interface N {
  230. let Y:! {.a: {}};
  231. }
  232. impl () as N where .Y = {.a = {}} { }
  233. // --- non-type_repeated.carbon
  234. library "[[@TEST_NAME]]";
  235. interface N {
  236. let Y:! {.a: {}};
  237. }
  238. impl () as N where .Y = {.a = {}} and .Y = {.a = {}} { }
  239. // --- fail_non-type_different.carbon
  240. library "[[@TEST_NAME]]";
  241. interface N {
  242. let Y:! {.a: type};
  243. }
  244. // CHECK:STDERR: fail_non-type_different.carbon:[[@LINE+4]]:12: error: associated constant `.(N.Y)` given two different values `{.a = {}}` and `{.a = ()}` [AssociatedConstantWithDifferentValues]
  245. // CHECK:STDERR: impl () as N where .Y = {.a = {}} and .Y = {.a = ()} {}
  246. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  247. // CHECK:STDERR:
  248. impl () as N where .Y = {.a = {}} and .Y = {.a = ()} {}
  249. // --- fail_where_rewrite_function.carbon
  250. library "[[@TEST_NAME]]";
  251. interface IF { fn F(); }
  252. class CD { }
  253. // CHECK:STDERR: fail_where_rewrite_function.carbon:[[@LINE+4]]:12: error: rewrite specified for associated function F [RewriteForAssociatedFunction]
  254. // CHECK:STDERR: impl CD as IF where .F = 0 {
  255. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  256. // CHECK:STDERR:
  257. impl CD as IF where .F = 0 {
  258. fn F() {}
  259. }
  260. // --- facet_type_in_assoc_constant.carbon
  261. library "[[@TEST_NAME]]";
  262. interface M { let X:! type; }
  263. impl () as M where .X = (M where .X = (M where .X = {})) {}
  264. // --- fail_todo_period_self_impl_lookup.carbon
  265. library "[[@TEST_NAME]]";
  266. interface Y {}
  267. interface Z {
  268. let Z1:! Y;
  269. }
  270. class C;
  271. impl C as Y {}
  272. // Implied constraint: .Self impls Y. Should be verified when finishing the impl
  273. // decl (where we know .Self is C). See:
  274. // https://discord.com/channels/655572317891461132/941071822756143115/1400953094015160370
  275. //
  276. // CHECK:STDERR: fail_todo_period_self_impl_lookup.carbon:[[@LINE+4]]:25: error: cannot convert type `.Self` that implements `Z` into type implementing `Y` [ConversionFailureFacetToFacet]
  277. // CHECK:STDERR: impl C as Z where .Z1 = .Self {}
  278. // CHECK:STDERR: ^~~~~
  279. // CHECK:STDERR:
  280. impl C as Z where .Z1 = .Self {}
  281. // --- fail_todo_period_self_compared_with_concrete_self.carbon
  282. library "[[@TEST_NAME]]";
  283. interface Y {}
  284. interface Z {
  285. let Z1:! Y;
  286. }
  287. class C;
  288. impl C as Y {}
  289. impl C as Z where .Z1 = C {}
  290. // Implied constraint: .Self impls Y. Should be verified against the type of the
  291. // facet value replacing T when calling F.
  292. //
  293. // CHECK:STDERR: fail_todo_period_self_compared_with_concrete_self.carbon:[[@LINE+4]]:31: error: cannot convert type `.Self` that implements `Z` into type implementing `Y` [ConversionFailureFacetToFacet]
  294. // CHECK:STDERR: fn F(unused T:! Z where .Z1 = .Self) {}
  295. // CHECK:STDERR: ^~~~~
  296. // CHECK:STDERR:
  297. fn F(unused T:! Z where .Z1 = .Self) {}
  298. fn G() {
  299. F(C);
  300. // Implied constraint: .Self impls Y. Should be verified against the type of
  301. // the facet value of C when casting.
  302. //
  303. // CHECK:STDERR: fail_todo_period_self_compared_with_concrete_self.carbon:[[@LINE+4]]:23: error: cannot convert type `.Self` that implements `Z` into type implementing `Y` [ConversionFailureFacetToFacet]
  304. // CHECK:STDERR: C as (Z where .Z1 = .Self);
  305. // CHECK:STDERR: ^~~~~
  306. // CHECK:STDERR:
  307. C as (Z where .Z1 = .Self);
  308. }
  309. // CHECK:STDOUT: --- fail_many_different.carbon
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: constants {
  312. // CHECK:STDOUT: %L.type: type = facet_type <@L> [concrete]
  313. // CHECK:STDOUT: %L.assoc_type: type = assoc_entity_type @L [concrete]
  314. // CHECK:STDOUT: %assoc0: %L.assoc_type = assoc_entity element0, @L.WithSelf.%W [concrete]
  315. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  316. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  317. // CHECK:STDOUT: %.Self: %L.type = symbolic_binding .Self [symbolic_self]
  318. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self [symbolic_self]
  319. // CHECK:STDOUT: %L.lookup_impl_witness: <witness> = lookup_impl_witness %.Self, @L [symbolic_self]
  320. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %L.lookup_impl_witness, element0 [symbolic_self]
  321. // CHECK:STDOUT: %tuple.type.2d5: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
  322. // CHECK:STDOUT: %tuple.7e4: %tuple.type.2d5 = tuple_value (%empty_tuple, %empty_tuple, %empty_tuple) [concrete]
  323. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  324. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  325. // CHECK:STDOUT: %tuple.type.e5a: type = tuple_type (%empty_struct_type, %empty_tuple.type, %empty_tuple.type) [concrete]
  326. // CHECK:STDOUT: %tuple.b36: %tuple.type.e5a = tuple_value (%empty_struct, %empty_tuple, %empty_tuple) [concrete]
  327. // CHECK:STDOUT: %tuple.type.d7e: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_tuple.type) [concrete]
  328. // CHECK:STDOUT: %tuple.8ed: %tuple.type.d7e = tuple_value (%empty_struct, %empty_struct, %empty_tuple) [concrete]
  329. // CHECK:STDOUT: %tuple.type.bd8: type = tuple_type (%empty_struct_type, %empty_tuple.type, %empty_struct_type) [concrete]
  330. // CHECK:STDOUT: %tuple.d90: %tuple.type.bd8 = tuple_value (%empty_struct, %empty_tuple, %empty_struct) [concrete]
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: file {
  334. // CHECK:STDOUT: impl_decl @empty_tuple.type.as.<error>.impl [concrete] {} {
  335. // CHECK:STDOUT: %.loc13_7.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  336. // CHECK:STDOUT: %.loc13_7.2: type = converted %.loc13_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  337. // CHECK:STDOUT: %L.ref: type = name_ref L, file.%L.decl [concrete = constants.%L.type]
  338. // CHECK:STDOUT: <elided>
  339. // CHECK:STDOUT: %.Self.ref.loc13_20: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  340. // CHECK:STDOUT: %.Self.as_type.loc13_20: type = facet_access_type %.Self.ref.loc13_20 [symbolic_self = constants.%.Self.binding.as_type]
  341. // CHECK:STDOUT: %.loc13_20: type = converted %.Self.ref.loc13_20, %.Self.as_type.loc13_20 [symbolic_self = constants.%.Self.binding.as_type]
  342. // CHECK:STDOUT: %W.ref.loc13_20: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  343. // CHECK:STDOUT: %impl.elem0.loc13_20: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  344. // CHECK:STDOUT: %.loc13_27: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  345. // CHECK:STDOUT: %.loc13_31: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  346. // CHECK:STDOUT: %.loc13_35: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  347. // CHECK:STDOUT: %.loc13_36.1: %tuple.type.2d5 = tuple_literal (%.loc13_27, %.loc13_31, %.loc13_35) [concrete = constants.%tuple.7e4]
  348. // CHECK:STDOUT: %.loc13_36.2: type = converted constants.%empty_tuple, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  349. // CHECK:STDOUT: %.loc13_36.3: type = converted constants.%empty_tuple, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  350. // CHECK:STDOUT: %.loc13_36.4: type = converted constants.%empty_tuple, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  351. // CHECK:STDOUT: %.loc13_36.5: type = converted %.loc13_36.1, constants.%tuple.type.2d5 [concrete = constants.%tuple.type.2d5]
  352. // CHECK:STDOUT: %.Self.ref.loc13_42: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  353. // CHECK:STDOUT: %.Self.as_type.loc13_42: type = facet_access_type %.Self.ref.loc13_42 [symbolic_self = constants.%.Self.binding.as_type]
  354. // CHECK:STDOUT: %.loc13_42: type = converted %.Self.ref.loc13_42, %.Self.as_type.loc13_42 [symbolic_self = constants.%.Self.binding.as_type]
  355. // CHECK:STDOUT: %W.ref.loc13_42: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  356. // CHECK:STDOUT: %impl.elem0.loc13_42: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  357. // CHECK:STDOUT: %impl.elem0.subst.loc13_42: type = impl_witness_access_substituted %impl.elem0.loc13_42, %.loc13_36.5 [concrete = constants.%tuple.type.2d5]
  358. // CHECK:STDOUT: %.loc13_49: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  359. // CHECK:STDOUT: %.loc13_53: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  360. // CHECK:STDOUT: %.loc13_57: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  361. // CHECK:STDOUT: %.loc13_58.1: %tuple.type.e5a = tuple_literal (%.loc13_49, %.loc13_53, %.loc13_57) [concrete = constants.%tuple.b36]
  362. // CHECK:STDOUT: %.loc13_58.2: type = converted constants.%empty_struct, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  363. // CHECK:STDOUT: %.loc13_58.3: type = converted constants.%empty_tuple, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  364. // CHECK:STDOUT: %.loc13_58.4: type = converted constants.%empty_tuple, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  365. // CHECK:STDOUT: %.loc13_58.5: type = converted %.loc13_58.1, constants.%tuple.type.e5a [concrete = constants.%tuple.type.e5a]
  366. // CHECK:STDOUT: %.Self.ref.loc13_64: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  367. // CHECK:STDOUT: %.Self.as_type.loc13_64: type = facet_access_type %.Self.ref.loc13_64 [symbolic_self = constants.%.Self.binding.as_type]
  368. // CHECK:STDOUT: %.loc13_64: type = converted %.Self.ref.loc13_64, %.Self.as_type.loc13_64 [symbolic_self = constants.%.Self.binding.as_type]
  369. // CHECK:STDOUT: %W.ref.loc13_64: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  370. // CHECK:STDOUT: %impl.elem0.loc13_64: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  371. // CHECK:STDOUT: %impl.elem0.subst.loc13_64: type = impl_witness_access_substituted %impl.elem0.loc13_64, %.loc13_36.5 [concrete = constants.%tuple.type.2d5]
  372. // CHECK:STDOUT: %.loc13_71: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  373. // CHECK:STDOUT: %.loc13_75: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  374. // CHECK:STDOUT: %.loc13_79: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  375. // CHECK:STDOUT: %.loc13_80.1: %tuple.type.d7e = tuple_literal (%.loc13_71, %.loc13_75, %.loc13_79) [concrete = constants.%tuple.8ed]
  376. // CHECK:STDOUT: %.loc13_80.2: type = converted constants.%empty_struct, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  377. // CHECK:STDOUT: %.loc13_80.3: type = converted constants.%empty_struct, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  378. // CHECK:STDOUT: %.loc13_80.4: type = converted constants.%empty_tuple, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  379. // CHECK:STDOUT: %.loc13_80.5: type = converted %.loc13_80.1, constants.%tuple.type.d7e [concrete = constants.%tuple.type.d7e]
  380. // CHECK:STDOUT: %.Self.ref.loc13_86: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  381. // CHECK:STDOUT: %.Self.as_type.loc13_86: type = facet_access_type %.Self.ref.loc13_86 [symbolic_self = constants.%.Self.binding.as_type]
  382. // CHECK:STDOUT: %.loc13_86: type = converted %.Self.ref.loc13_86, %.Self.as_type.loc13_86 [symbolic_self = constants.%.Self.binding.as_type]
  383. // CHECK:STDOUT: %W.ref.loc13_86: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  384. // CHECK:STDOUT: %impl.elem0.loc13_86: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  385. // CHECK:STDOUT: %impl.elem0.subst.loc13_86: type = impl_witness_access_substituted %impl.elem0.loc13_86, %.loc13_36.5 [concrete = constants.%tuple.type.2d5]
  386. // CHECK:STDOUT: %.loc13_93: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  387. // CHECK:STDOUT: %.loc13_97: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  388. // CHECK:STDOUT: %.loc13_101: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  389. // CHECK:STDOUT: %.loc13_102.1: %tuple.type.bd8 = tuple_literal (%.loc13_93, %.loc13_97, %.loc13_101) [concrete = constants.%tuple.d90]
  390. // CHECK:STDOUT: %.loc13_102.2: type = converted constants.%empty_struct, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  391. // CHECK:STDOUT: %.loc13_102.3: type = converted constants.%empty_tuple, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  392. // CHECK:STDOUT: %.loc13_102.4: type = converted constants.%empty_struct, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  393. // CHECK:STDOUT: %.loc13_102.5: type = converted %.loc13_102.1, constants.%tuple.type.bd8 [concrete = constants.%tuple.type.bd8]
  394. // CHECK:STDOUT: %.loc13_14: type = where_expr %.Self [concrete = <error>] {
  395. // CHECK:STDOUT: requirement_base_facet_type constants.%L.type
  396. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_20, %.loc13_36.5
  397. // CHECK:STDOUT: requirement_rewrite %impl.elem0.subst.loc13_42, %.loc13_58.5
  398. // CHECK:STDOUT: requirement_rewrite %impl.elem0.subst.loc13_64, %.loc13_80.5
  399. // CHECK:STDOUT: requirement_rewrite %impl.elem0.subst.loc13_86, %.loc13_102.5
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: impl @empty_tuple.type.as.<error>.impl: %.loc13_7.2 as %.loc13_14 {
  405. // CHECK:STDOUT: !members:
  406. // CHECK:STDOUT: witness = <error>
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: --- fail_cycle.carbon
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: constants {
  412. // CHECK:STDOUT: %M.type: type = facet_type <@M> [concrete]
  413. // CHECK:STDOUT: %M.assoc_type: type = assoc_entity_type @M [concrete]
  414. // CHECK:STDOUT: %assoc0: %M.assoc_type = assoc_entity element0, @M.WithSelf.%X [concrete]
  415. // CHECK:STDOUT: %assoc1: %M.assoc_type = assoc_entity element1, @M.WithSelf.%Y [concrete]
  416. // CHECK:STDOUT: %assoc2: %M.assoc_type = assoc_entity element2, @M.WithSelf.%Z [concrete]
  417. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  418. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  419. // CHECK:STDOUT: %.Self: %M.type = symbolic_binding .Self [symbolic_self]
  420. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self [symbolic_self]
  421. // CHECK:STDOUT: %M.lookup_impl_witness: <witness> = lookup_impl_witness %.Self, @M [symbolic_self]
  422. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %M.lookup_impl_witness, element0 [symbolic_self]
  423. // CHECK:STDOUT: %impl.elem1: type = impl_witness_access %M.lookup_impl_witness, element1 [symbolic_self]
  424. // CHECK:STDOUT: %impl.elem2: type = impl_witness_access %M.lookup_impl_witness, element2 [symbolic_self]
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: file {
  428. // CHECK:STDOUT: impl_decl @empty_tuple.type.as.<error>.impl [concrete] {} {
  429. // CHECK:STDOUT: %.loc13_7.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  430. // CHECK:STDOUT: %.loc13_7.2: type = converted %.loc13_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  431. // CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [concrete = constants.%M.type]
  432. // CHECK:STDOUT: <elided>
  433. // CHECK:STDOUT: %.Self.ref.loc13_20: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  434. // CHECK:STDOUT: %.Self.as_type.loc13_20: type = facet_access_type %.Self.ref.loc13_20 [symbolic_self = constants.%.Self.binding.as_type]
  435. // CHECK:STDOUT: %.loc13_20: type = converted %.Self.ref.loc13_20, %.Self.as_type.loc13_20 [symbolic_self = constants.%.Self.binding.as_type]
  436. // CHECK:STDOUT: %X.ref.loc13_20: %M.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
  437. // CHECK:STDOUT: %impl.elem0.loc13_20: type = impl_witness_access constants.%M.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  438. // CHECK:STDOUT: %.Self.ref.loc13_25: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  439. // CHECK:STDOUT: %.Self.as_type.loc13_25: type = facet_access_type %.Self.ref.loc13_25 [symbolic_self = constants.%.Self.binding.as_type]
  440. // CHECK:STDOUT: %.loc13_25: type = converted %.Self.ref.loc13_25, %.Self.as_type.loc13_25 [symbolic_self = constants.%.Self.binding.as_type]
  441. // CHECK:STDOUT: %Y.ref.loc13_25: %M.assoc_type = name_ref Y, @Y.%assoc1 [concrete = constants.%assoc1]
  442. // CHECK:STDOUT: %impl.elem1.loc13_25: type = impl_witness_access constants.%M.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
  443. // CHECK:STDOUT: %.Self.ref.loc13_32: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  444. // CHECK:STDOUT: %.Self.as_type.loc13_32: type = facet_access_type %.Self.ref.loc13_32 [symbolic_self = constants.%.Self.binding.as_type]
  445. // CHECK:STDOUT: %.loc13_32: type = converted %.Self.ref.loc13_32, %.Self.as_type.loc13_32 [symbolic_self = constants.%.Self.binding.as_type]
  446. // CHECK:STDOUT: %Y.ref.loc13_32: %M.assoc_type = name_ref Y, @Y.%assoc1 [concrete = constants.%assoc1]
  447. // CHECK:STDOUT: %impl.elem1.loc13_32: type = impl_witness_access constants.%M.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
  448. // CHECK:STDOUT: %.Self.ref.loc13_37: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  449. // CHECK:STDOUT: %.Self.as_type.loc13_37: type = facet_access_type %.Self.ref.loc13_37 [symbolic_self = constants.%.Self.binding.as_type]
  450. // CHECK:STDOUT: %.loc13_37: type = converted %.Self.ref.loc13_37, %.Self.as_type.loc13_37 [symbolic_self = constants.%.Self.binding.as_type]
  451. // CHECK:STDOUT: %X.ref.loc13_37: %M.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
  452. // CHECK:STDOUT: %impl.elem0.loc13_37: type = impl_witness_access constants.%M.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  453. // CHECK:STDOUT: %impl.elem0.subst: type = impl_witness_access_substituted %impl.elem0.loc13_37, %impl.elem1.loc13_25 [symbolic_self = constants.%impl.elem1]
  454. // CHECK:STDOUT: %.Self.ref.loc13_44: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  455. // CHECK:STDOUT: %.Self.as_type.loc13_44: type = facet_access_type %.Self.ref.loc13_44 [symbolic_self = constants.%.Self.binding.as_type]
  456. // CHECK:STDOUT: %.loc13_44: type = converted %.Self.ref.loc13_44, %.Self.as_type.loc13_44 [symbolic_self = constants.%.Self.binding.as_type]
  457. // CHECK:STDOUT: %Z.ref: %M.assoc_type = name_ref Z, @Z.%assoc2 [concrete = constants.%assoc2]
  458. // CHECK:STDOUT: %impl.elem2: type = impl_witness_access constants.%M.lookup_impl_witness, element2 [symbolic_self = constants.%impl.elem2]
  459. // CHECK:STDOUT: %.loc13_50.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  460. // CHECK:STDOUT: %.loc13_50.2: type = converted %.loc13_50.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  461. // CHECK:STDOUT: %.loc13_14: type = where_expr %.Self [concrete = <error>] {
  462. // CHECK:STDOUT: requirement_base_facet_type constants.%M.type
  463. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_20, %impl.elem1.loc13_25
  464. // CHECK:STDOUT: requirement_rewrite %impl.elem1.loc13_32, %impl.elem0.subst
  465. // CHECK:STDOUT: requirement_rewrite %impl.elem2, %.loc13_50.2
  466. // CHECK:STDOUT: }
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT: }
  469. // CHECK:STDOUT:
  470. // CHECK:STDOUT: impl @empty_tuple.type.as.<error>.impl: %.loc13_7.2 as %.loc13_14 {
  471. // CHECK:STDOUT: !members:
  472. // CHECK:STDOUT: witness = <error>
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT: