impl_assoc_const.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. // EXTRA-ARGS: --no-prelude-import
  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+11]]:12: error: associated constant `.(L2.W2)` given two different values `()` and `.(L2.X2)` [AssociatedConstantWithDifferentValues]
  96. // CHECK:STDERR: impl () as L2 where .W2 = .X2 and .W2 = () {}
  97. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. // CHECK:STDERR:
  99. // CHECK:STDERR: fail_two_different_first_associated.carbon:[[@LINE+7]]:1: error: associated constant X2 not given a value in impl of interface L2 [ImplAssociatedConstantNeedsValue]
  100. // CHECK:STDERR: impl () as L2 where .W2 = .X2 and .W2 = () {}
  101. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. // CHECK:STDERR: fail_two_different_first_associated.carbon:[[@LINE-9]]:35: note: associated constant declared here [AssociatedConstantHere]
  103. // CHECK:STDERR: interface L2 { let W2:! type; let X2:! type; }
  104. // CHECK:STDERR: ^~~~~~~~~
  105. // CHECK:STDERR:
  106. impl () as L2 where .W2 = .X2 and .W2 = () {}
  107. // --- fail_two_different_second_associated.carbon
  108. library "[[@TEST_NAME]]";
  109. interface L2 { let W2:! type; let X2:! type; }
  110. // CHECK:STDERR: fail_two_different_second_associated.carbon:[[@LINE+11]]:12: error: associated constant `.(L2.W2)` given two different values `()` and `.(L2.X2)` [AssociatedConstantWithDifferentValues]
  111. // CHECK:STDERR: impl () as L2 where .W2 = () and .W2 = .X2 {}
  112. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113. // CHECK:STDERR:
  114. // CHECK:STDERR: fail_two_different_second_associated.carbon:[[@LINE+7]]:1: error: associated constant X2 not given a value in impl of interface L2 [ImplAssociatedConstantNeedsValue]
  115. // CHECK:STDERR: impl () as L2 where .W2 = () and .W2 = .X2 {}
  116. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  117. // CHECK:STDERR: fail_two_different_second_associated.carbon:[[@LINE-9]]:35: note: associated constant declared here [AssociatedConstantHere]
  118. // CHECK:STDERR: interface L2 { let W2:! type; let X2:! type; }
  119. // CHECK:STDERR: ^~~~~~~~~
  120. // CHECK:STDERR:
  121. impl () as L2 where .W2 = () and .W2 = .X2 {}
  122. // --- fail_two_different_first_bad.carbon
  123. library "[[@TEST_NAME]]";
  124. interface L2 { let W2:! type; }
  125. // CHECK:STDERR: fail_two_different_first_bad.carbon:[[@LINE+4]]:27: error: name `BAD5` not found [NameNotFound]
  126. // CHECK:STDERR: impl () as L2 where .W2 = BAD5 and .W2 = () {}
  127. // CHECK:STDERR: ^~~~
  128. // CHECK:STDERR:
  129. impl () as L2 where .W2 = BAD5 and .W2 = () {}
  130. // --- fail_two_different_second_bad.carbon
  131. library "[[@TEST_NAME]]";
  132. interface L3 { let W3:! type; }
  133. // CHECK:STDERR: fail_two_different_second_bad.carbon:[[@LINE+4]]:40: error: name `BAD6` not found [NameNotFound]
  134. // CHECK:STDERR: impl () as L3 where .W3 = {} and .W3 = BAD6 {}
  135. // CHECK:STDERR: ^~~~
  136. // CHECK:STDERR:
  137. impl () as L3 where .W3 = {} and .W3 = BAD6 {}
  138. // --- fail_two_different_both_bad.carbon
  139. library "[[@TEST_NAME]]";
  140. interface L4 { let W4:! type; }
  141. // CHECK:STDERR: fail_two_different_both_bad.carbon:[[@LINE+8]]:27: error: name `BAD7` not found [NameNotFound]
  142. // CHECK:STDERR: impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {}
  143. // CHECK:STDERR: ^~~~
  144. // CHECK:STDERR:
  145. // CHECK:STDERR: fail_two_different_both_bad.carbon:[[@LINE+4]]:42: error: name `BAD8` not found [NameNotFound]
  146. // CHECK:STDERR: impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {}
  147. // CHECK:STDERR: ^~~~
  148. // CHECK:STDERR:
  149. impl () as L4 where .W4 = BAD7 and .W4 = BAD8 {}
  150. // --- fail_many_different.carbon
  151. library "[[@TEST_NAME]]";
  152. interface L { let W:! type; }
  153. // The facet type should have a single rewrite with `<error>` in the RHS (they
  154. // are all errors, and they get deduped).
  155. //
  156. //@dump-sem-ir-begin
  157. // CHECK:STDERR: fail_many_different.carbon:[[@LINE+4]]:12: error: associated constant `.(L.W)` given two different values `((), (), ())` and `({}, (), ())` [AssociatedConstantWithDifferentValues]
  158. // CHECK:STDERR: impl () as L where .W = ((), (), ()) and .W = ({}, (), ()) and .W = ({}, {}, ()) and .W = ({}, (), {}) {}
  159. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  160. // CHECK:STDERR:
  161. impl () as L where .W = ((), (), ()) and .W = ({}, (), ()) and .W = ({}, {}, ()) and .W = ({}, (), {}) {}
  162. //@dump-sem-ir-end
  163. // --- repeated.carbon
  164. library "[[@TEST_NAME]]";
  165. interface M { let X:! type; }
  166. impl () as M where .X = {} and .X = {} {}
  167. // --- repeated_associated.carbon
  168. library "[[@TEST_NAME]]";
  169. interface M { let X:! type; let Y:! type; }
  170. impl () as M where .X = .Y and .X = .Y and .Y = () {}
  171. // --- fail_repeated_and_different.carbon
  172. library "[[@TEST_NAME]]";
  173. interface M { let X:! type; }
  174. // CHECK:STDERR: fail_repeated_and_different.carbon:[[@LINE+4]]:12: error: associated constant `.(M.X)` given two different values `()` and `{}` [AssociatedConstantWithDifferentValues]
  175. // CHECK:STDERR: impl () as M where .X = {} and .X = () and .X = {} {}
  176. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  177. // CHECK:STDERR:
  178. impl () as M where .X = {} and .X = () and .X = {} {}
  179. // --- fail_cycle_single.carbon
  180. library "[[@TEST_NAME]]";
  181. interface M { let X:! type; }
  182. // This fails because it resolves to `.X = .X` which is cyclical.
  183. //
  184. // CHECK:STDERR: fail_cycle_single.carbon:[[@LINE+4]]:12: error: found cycle in facet type constraint for `.(M.X)` [FacetTypeConstraintCycle]
  185. // CHECK:STDERR: impl () as M where .X = .X {}
  186. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  187. // CHECK:STDERR:
  188. impl () as M where .X = .X {}
  189. // --- fail_cycle.carbon
  190. library "[[@TEST_NAME]]";
  191. interface M { let X:! type; let Y:! type; let Z:! type; }
  192. // This fails because it resolves to `.X = .X` which is cyclical.
  193. // The value of .X and .Y becomes <error> but .Z is still valid.
  194. //
  195. //@dump-sem-ir-begin
  196. // CHECK:STDERR: fail_cycle.carbon:[[@LINE+4]]:12: error: found cycle in facet type constraint for `.(M.X)` [FacetTypeConstraintCycle]
  197. // CHECK:STDERR: impl () as M where .X = .Y and .Y = .X and .Z = () {}
  198. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  199. // CHECK:STDERR:
  200. impl () as M where .X = .Y and .Y = .X and .Z = () {}
  201. //@dump-sem-ir-end
  202. // --- fail_todo_cycle_between_interfaces.carbon
  203. library "[[@TEST_NAME]]";
  204. interface I {
  205. let X1:! type;
  206. let X2:! type;
  207. }
  208. interface J {
  209. let X3:! type;
  210. }
  211. // TODO: This should fail due to a cyclic definition of each value. But right
  212. // now it's failing due to compound member access in a rewrite constraint not
  213. // working.
  214. //
  215. // CHECK:STDERR: fail_todo_cycle_between_interfaces.carbon:[[@LINE+12]]:45: error: expected identifier or `Self` after `.` [ExpectedIdentifierOrSelfAfterPeriod]
  216. // CHECK:STDERR: impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  217. // CHECK:STDERR: ^
  218. // CHECK:STDERR:
  219. // CHECK:STDERR: fail_todo_cycle_between_interfaces.carbon:[[@LINE+8]]:45: error: semantics TODO: `handle invalid parse trees in `check`` [SemanticsTodo]
  220. // CHECK:STDERR: impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  221. // CHECK:STDERR: ^
  222. // CHECK:STDERR:
  223. // CHECK:STDERR: fail_todo_cycle_between_interfaces.carbon:[[@LINE+4]]:71: error: expected identifier or `Self` after `.` [ExpectedIdentifierOrSelfAfterPeriod]
  224. // CHECK:STDERR: impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  225. // CHECK:STDERR: ^
  226. // CHECK:STDERR:
  227. impl () as I where .Self impls J and .X1 = .(J.X3) and .X2 = .X1 and .(J.X3) = .X2 {}
  228. // --- non-type.carbon
  229. library "[[@TEST_NAME]]";
  230. interface N {
  231. let Y:! {.a: {}};
  232. }
  233. impl () as N where .Y = {.a = {}} { }
  234. // --- non-type_repeated.carbon
  235. library "[[@TEST_NAME]]";
  236. interface N {
  237. let Y:! {.a: {}};
  238. }
  239. impl () as N where .Y = {.a = {}} and .Y = {.a = {}} { }
  240. // --- fail_non-type_different.carbon
  241. library "[[@TEST_NAME]]";
  242. interface N {
  243. let Y:! {.a: type};
  244. }
  245. // CHECK:STDERR: fail_non-type_different.carbon:[[@LINE+4]]:12: error: associated constant `.(N.Y)` given two different values `{.a = {}}` and `{.a = ()}` [AssociatedConstantWithDifferentValues]
  246. // CHECK:STDERR: impl () as N where .Y = {.a = {}} and .Y = {.a = ()} {}
  247. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248. // CHECK:STDERR:
  249. impl () as N where .Y = {.a = {}} and .Y = {.a = ()} {}
  250. // --- fail_where_rewrite_function.carbon
  251. library "[[@TEST_NAME]]";
  252. interface IF { fn F(); }
  253. class CD { }
  254. // CHECK:STDERR: fail_where_rewrite_function.carbon:[[@LINE+4]]:12: error: rewrite specified for associated function F [RewriteForAssociatedFunction]
  255. // CHECK:STDERR: impl CD as IF where .F = 0 {
  256. // CHECK:STDERR: ^~~~~~~~~~~~~~~
  257. // CHECK:STDERR:
  258. impl CD as IF where .F = 0 {
  259. fn F() {}
  260. }
  261. // CHECK:STDOUT: --- fail_many_different.carbon
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: constants {
  264. // CHECK:STDOUT: %L.type: type = facet_type <@L> [concrete]
  265. // CHECK:STDOUT: %L.assoc_type: type = assoc_entity_type @L [concrete]
  266. // CHECK:STDOUT: %assoc0: %L.assoc_type = assoc_entity element0, @L.%W [concrete]
  267. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  268. // CHECK:STDOUT: %.Self: %L.type = bind_symbolic_name .Self [symbolic_self]
  269. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
  270. // CHECK:STDOUT: %L.lookup_impl_witness: <witness> = lookup_impl_witness %.Self, @L [symbolic_self]
  271. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %L.lookup_impl_witness, element0 [symbolic_self]
  272. // CHECK:STDOUT: %tuple.type.2d5: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [concrete]
  273. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  274. // CHECK:STDOUT: %tuple.type.e5a: type = tuple_type (%empty_struct_type, %empty_tuple.type, %empty_tuple.type) [concrete]
  275. // CHECK:STDOUT: %tuple.type.d7e: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_tuple.type) [concrete]
  276. // CHECK:STDOUT: %tuple.type.bd8: type = tuple_type (%empty_struct_type, %empty_tuple.type, %empty_struct_type) [concrete]
  277. // CHECK:STDOUT: %L_where.type: type = facet_type <@L where %impl.elem0 = <error>> [concrete]
  278. // CHECK:STDOUT: %L.impl_witness: <witness> = impl_witness file.%L.impl_witness_table [concrete]
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: file {
  282. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  283. // CHECK:STDOUT: %.loc13_7.1: %empty_tuple.type = tuple_literal ()
  284. // CHECK:STDOUT: %.loc13_7.2: type = converted %.loc13_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  285. // CHECK:STDOUT: %L.ref: type = name_ref L, file.%L.decl [concrete = constants.%L.type]
  286. // CHECK:STDOUT: <elided>
  287. // CHECK:STDOUT: %.Self.ref.loc13_20: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  288. // CHECK:STDOUT: %W.ref.loc13_20: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  289. // CHECK:STDOUT: %.Self.as_type.loc13_20: type = facet_access_type %.Self.ref.loc13_20 [symbolic_self = constants.%.Self.as_type]
  290. // CHECK:STDOUT: %.loc13_20: type = converted %.Self.ref.loc13_20, %.Self.as_type.loc13_20 [symbolic_self = constants.%.Self.as_type]
  291. // CHECK:STDOUT: %impl.elem0.loc13_20: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  292. // CHECK:STDOUT: %.loc13_27: %empty_tuple.type = tuple_literal ()
  293. // CHECK:STDOUT: %.loc13_31: %empty_tuple.type = tuple_literal ()
  294. // CHECK:STDOUT: %.loc13_35: %empty_tuple.type = tuple_literal ()
  295. // CHECK:STDOUT: %.loc13_36.1: %tuple.type.2d5 = tuple_literal (%.loc13_27, %.loc13_31, %.loc13_35)
  296. // CHECK:STDOUT: %.loc13_36.2: type = converted %.loc13_27, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  297. // CHECK:STDOUT: %.loc13_36.3: type = converted %.loc13_31, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  298. // CHECK:STDOUT: %.loc13_36.4: type = converted %.loc13_35, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  299. // CHECK:STDOUT: %.loc13_36.5: type = converted %.loc13_36.1, constants.%tuple.type.2d5 [concrete = constants.%tuple.type.2d5]
  300. // CHECK:STDOUT: %.Self.ref.loc13_42: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  301. // CHECK:STDOUT: %W.ref.loc13_42: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  302. // CHECK:STDOUT: %.Self.as_type.loc13_42: type = facet_access_type %.Self.ref.loc13_42 [symbolic_self = constants.%.Self.as_type]
  303. // CHECK:STDOUT: %.loc13_42: type = converted %.Self.ref.loc13_42, %.Self.as_type.loc13_42 [symbolic_self = constants.%.Self.as_type]
  304. // CHECK:STDOUT: %impl.elem0.loc13_42: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  305. // CHECK:STDOUT: %.loc13_49: %empty_struct_type = struct_literal ()
  306. // CHECK:STDOUT: %.loc13_53: %empty_tuple.type = tuple_literal ()
  307. // CHECK:STDOUT: %.loc13_57: %empty_tuple.type = tuple_literal ()
  308. // CHECK:STDOUT: %.loc13_58.1: %tuple.type.e5a = tuple_literal (%.loc13_49, %.loc13_53, %.loc13_57)
  309. // CHECK:STDOUT: %.loc13_58.2: type = converted %.loc13_49, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  310. // CHECK:STDOUT: %.loc13_58.3: type = converted %.loc13_53, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  311. // CHECK:STDOUT: %.loc13_58.4: type = converted %.loc13_57, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  312. // CHECK:STDOUT: %.loc13_58.5: type = converted %.loc13_58.1, constants.%tuple.type.e5a [concrete = constants.%tuple.type.e5a]
  313. // CHECK:STDOUT: %.Self.ref.loc13_64: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  314. // CHECK:STDOUT: %W.ref.loc13_64: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  315. // CHECK:STDOUT: %.Self.as_type.loc13_64: type = facet_access_type %.Self.ref.loc13_64 [symbolic_self = constants.%.Self.as_type]
  316. // CHECK:STDOUT: %.loc13_64: type = converted %.Self.ref.loc13_64, %.Self.as_type.loc13_64 [symbolic_self = constants.%.Self.as_type]
  317. // CHECK:STDOUT: %impl.elem0.loc13_64: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  318. // CHECK:STDOUT: %.loc13_71: %empty_struct_type = struct_literal ()
  319. // CHECK:STDOUT: %.loc13_75: %empty_struct_type = struct_literal ()
  320. // CHECK:STDOUT: %.loc13_79: %empty_tuple.type = tuple_literal ()
  321. // CHECK:STDOUT: %.loc13_80.1: %tuple.type.d7e = tuple_literal (%.loc13_71, %.loc13_75, %.loc13_79)
  322. // CHECK:STDOUT: %.loc13_80.2: type = converted %.loc13_71, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  323. // CHECK:STDOUT: %.loc13_80.3: type = converted %.loc13_75, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  324. // CHECK:STDOUT: %.loc13_80.4: type = converted %.loc13_79, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  325. // CHECK:STDOUT: %.loc13_80.5: type = converted %.loc13_80.1, constants.%tuple.type.d7e [concrete = constants.%tuple.type.d7e]
  326. // CHECK:STDOUT: %.Self.ref.loc13_86: %L.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  327. // CHECK:STDOUT: %W.ref.loc13_86: %L.assoc_type = name_ref W, @W.%assoc0 [concrete = constants.%assoc0]
  328. // CHECK:STDOUT: %.Self.as_type.loc13_86: type = facet_access_type %.Self.ref.loc13_86 [symbolic_self = constants.%.Self.as_type]
  329. // CHECK:STDOUT: %.loc13_86: type = converted %.Self.ref.loc13_86, %.Self.as_type.loc13_86 [symbolic_self = constants.%.Self.as_type]
  330. // CHECK:STDOUT: %impl.elem0.loc13_86: type = impl_witness_access constants.%L.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  331. // CHECK:STDOUT: %.loc13_93: %empty_struct_type = struct_literal ()
  332. // CHECK:STDOUT: %.loc13_97: %empty_tuple.type = tuple_literal ()
  333. // CHECK:STDOUT: %.loc13_101: %empty_struct_type = struct_literal ()
  334. // CHECK:STDOUT: %.loc13_102.1: %tuple.type.bd8 = tuple_literal (%.loc13_93, %.loc13_97, %.loc13_101)
  335. // CHECK:STDOUT: %.loc13_102.2: type = converted %.loc13_93, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  336. // CHECK:STDOUT: %.loc13_102.3: type = converted %.loc13_97, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  337. // CHECK:STDOUT: %.loc13_102.4: type = converted %.loc13_101, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  338. // CHECK:STDOUT: %.loc13_102.5: type = converted %.loc13_102.1, constants.%tuple.type.bd8 [concrete = constants.%tuple.type.bd8]
  339. // CHECK:STDOUT: %.loc13_14: type = where_expr %.Self [concrete = constants.%L_where.type] {
  340. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_20, %.loc13_36.5
  341. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_42, %.loc13_58.5
  342. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_64, %.loc13_80.5
  343. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_86, %.loc13_102.5
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT: %L.impl_witness_table = impl_witness_table (<error>), @impl [concrete]
  347. // CHECK:STDOUT: %L.impl_witness: <witness> = impl_witness %L.impl_witness_table [concrete = constants.%L.impl_witness]
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: impl @impl: %.loc13_7.2 as %.loc13_14 {
  351. // CHECK:STDOUT: !members:
  352. // CHECK:STDOUT: witness = file.%L.impl_witness
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: --- fail_cycle.carbon
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: constants {
  358. // CHECK:STDOUT: %M.type: type = facet_type <@M> [concrete]
  359. // CHECK:STDOUT: %M.assoc_type: type = assoc_entity_type @M [concrete]
  360. // CHECK:STDOUT: %assoc0: %M.assoc_type = assoc_entity element0, @M.%X [concrete]
  361. // CHECK:STDOUT: %assoc1: %M.assoc_type = assoc_entity element1, @M.%Y [concrete]
  362. // CHECK:STDOUT: %assoc2: %M.assoc_type = assoc_entity element2, @M.%Z [concrete]
  363. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  364. // CHECK:STDOUT: %.Self: %M.type = bind_symbolic_name .Self [symbolic_self]
  365. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
  366. // CHECK:STDOUT: %M.lookup_impl_witness: <witness> = lookup_impl_witness %.Self, @M [symbolic_self]
  367. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %M.lookup_impl_witness, element0 [symbolic_self]
  368. // CHECK:STDOUT: %impl.elem1: type = impl_witness_access %M.lookup_impl_witness, element1 [symbolic_self]
  369. // CHECK:STDOUT: %impl.elem2: type = impl_witness_access %M.lookup_impl_witness, element2 [symbolic_self]
  370. // CHECK:STDOUT: %M_where.type: type = facet_type <@M where %impl.elem0 = <error> and %impl.elem1 = <error> and %impl.elem2 = %empty_tuple.type> [concrete]
  371. // CHECK:STDOUT: %M.impl_witness: <witness> = impl_witness file.%M.impl_witness_table [concrete]
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: file {
  375. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  376. // CHECK:STDOUT: %.loc13_7.1: %empty_tuple.type = tuple_literal ()
  377. // CHECK:STDOUT: %.loc13_7.2: type = converted %.loc13_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  378. // CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [concrete = constants.%M.type]
  379. // CHECK:STDOUT: <elided>
  380. // CHECK:STDOUT: %.Self.ref.loc13_20: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  381. // CHECK:STDOUT: %X.ref.loc13_20: %M.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
  382. // CHECK:STDOUT: %.Self.as_type.loc13_20: type = facet_access_type %.Self.ref.loc13_20 [symbolic_self = constants.%.Self.as_type]
  383. // CHECK:STDOUT: %.loc13_20: type = converted %.Self.ref.loc13_20, %.Self.as_type.loc13_20 [symbolic_self = constants.%.Self.as_type]
  384. // CHECK:STDOUT: %impl.elem0.loc13_20: type = impl_witness_access constants.%M.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  385. // CHECK:STDOUT: %.Self.ref.loc13_25: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  386. // CHECK:STDOUT: %Y.ref.loc13_25: %M.assoc_type = name_ref Y, @Y.%assoc1 [concrete = constants.%assoc1]
  387. // CHECK:STDOUT: %.Self.as_type.loc13_25: type = facet_access_type %.Self.ref.loc13_25 [symbolic_self = constants.%.Self.as_type]
  388. // CHECK:STDOUT: %.loc13_25: type = converted %.Self.ref.loc13_25, %.Self.as_type.loc13_25 [symbolic_self = constants.%.Self.as_type]
  389. // CHECK:STDOUT: %impl.elem1.loc13_25: type = impl_witness_access constants.%M.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
  390. // CHECK:STDOUT: %.Self.ref.loc13_32: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  391. // CHECK:STDOUT: %Y.ref.loc13_32: %M.assoc_type = name_ref Y, @Y.%assoc1 [concrete = constants.%assoc1]
  392. // CHECK:STDOUT: %.Self.as_type.loc13_32: type = facet_access_type %.Self.ref.loc13_32 [symbolic_self = constants.%.Self.as_type]
  393. // CHECK:STDOUT: %.loc13_32: type = converted %.Self.ref.loc13_32, %.Self.as_type.loc13_32 [symbolic_self = constants.%.Self.as_type]
  394. // CHECK:STDOUT: %impl.elem1.loc13_32: type = impl_witness_access constants.%M.lookup_impl_witness, element1 [symbolic_self = constants.%impl.elem1]
  395. // CHECK:STDOUT: %.Self.ref.loc13_37: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  396. // CHECK:STDOUT: %X.ref.loc13_37: %M.assoc_type = name_ref X, @X.%assoc0 [concrete = constants.%assoc0]
  397. // CHECK:STDOUT: %.Self.as_type.loc13_37: type = facet_access_type %.Self.ref.loc13_37 [symbolic_self = constants.%.Self.as_type]
  398. // CHECK:STDOUT: %.loc13_37: type = converted %.Self.ref.loc13_37, %.Self.as_type.loc13_37 [symbolic_self = constants.%.Self.as_type]
  399. // CHECK:STDOUT: %impl.elem0.loc13_37: type = impl_witness_access constants.%M.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  400. // CHECK:STDOUT: %.Self.ref.loc13_44: %M.type = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  401. // CHECK:STDOUT: %Z.ref: %M.assoc_type = name_ref Z, @Z.%assoc2 [concrete = constants.%assoc2]
  402. // CHECK:STDOUT: %.Self.as_type.loc13_44: type = facet_access_type %.Self.ref.loc13_44 [symbolic_self = constants.%.Self.as_type]
  403. // CHECK:STDOUT: %.loc13_44: type = converted %.Self.ref.loc13_44, %.Self.as_type.loc13_44 [symbolic_self = constants.%.Self.as_type]
  404. // CHECK:STDOUT: %impl.elem2: type = impl_witness_access constants.%M.lookup_impl_witness, element2 [symbolic_self = constants.%impl.elem2]
  405. // CHECK:STDOUT: %.loc13_50.1: %empty_tuple.type = tuple_literal ()
  406. // CHECK:STDOUT: %.loc13_50.2: type = converted %.loc13_50.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  407. // CHECK:STDOUT: %.loc13_14: type = where_expr %.Self [concrete = constants.%M_where.type] {
  408. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc13_20, %impl.elem1.loc13_25
  409. // CHECK:STDOUT: requirement_rewrite %impl.elem1.loc13_32, %impl.elem0.loc13_37
  410. // CHECK:STDOUT: requirement_rewrite %impl.elem2, %.loc13_50.2
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT: %M.impl_witness_table = impl_witness_table (<error>, <error>, %impl_witness_assoc_constant), @impl [concrete]
  414. // CHECK:STDOUT: %M.impl_witness: <witness> = impl_witness %M.impl_witness_table [concrete = constants.%M.impl_witness]
  415. // CHECK:STDOUT: %impl_witness_assoc_constant: type = impl_witness_assoc_constant constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: impl @impl: %.loc13_7.2 as %.loc13_14 {
  419. // CHECK:STDOUT: !members:
  420. // CHECK:STDOUT: witness = file.%M.impl_witness
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT: