constraints.carbon 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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/int.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/where_expr/constraints.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/where_expr/constraints.carbon
  12. // --- self_impls_type.carbon
  13. library "[[@TEST_NAME]]";
  14. interface I {}
  15. //@dump-sem-ir-begin
  16. fn F(T:! I where .Self impls type);
  17. //@dump-sem-ir-end
  18. alias Type = type;
  19. //@dump-sem-ir-begin
  20. fn G(T:! I where .Self impls Type);
  21. //@dump-sem-ir-end
  22. // --- fail_self_impls_error.carbon
  23. library "[[@TEST_NAME]]";
  24. interface I {}
  25. //@dump-sem-ir-begin
  26. // Because there's an error inside the `where`, the constant value of the
  27. // `where` should be an error also.
  28. //
  29. // CHECK:STDERR: fail_self_impls_error.carbon:[[@LINE+4]]:30: error: name `J` not found [NameNotFound]
  30. // CHECK:STDERR: fn F(T:! I where .Self impls J);
  31. // CHECK:STDERR: ^
  32. // CHECK:STDERR:
  33. fn F(T:! I where .Self impls J);
  34. //@dump-sem-ir-end
  35. // --- state_constraints.carbon
  36. library "[[@TEST_NAME]]";
  37. interface J {}
  38. interface I {
  39. let Member:! type;
  40. let Second:! J;
  41. }
  42. //@dump-sem-ir-begin
  43. fn EqualEqual(U:! I where .Self == ());
  44. fn Impls(V:! J where .Self impls I);
  45. fn And(W:! I where .Self impls J and .Member == ());
  46. //@dump-sem-ir-end
  47. // --- associated_type_impls.carbon
  48. library "[[@TEST_NAME]]";
  49. interface L {}
  50. interface M {}
  51. interface K {
  52. let Associated:! L;
  53. }
  54. //@dump-sem-ir-begin
  55. fn AssociatedTypeImpls(W:! K where .Associated impls M);
  56. //@dump-sem-ir-end
  57. // --- fail_left_of_impls_non_type.carbon
  58. library "[[@TEST_NAME]]";
  59. // CHECK:STDERR: fail_left_of_impls_non_type.carbon:[[@LINE+7]]:32: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
  60. // CHECK:STDERR: fn NonTypeImpls(U:! type where 7 impls type);
  61. // CHECK:STDERR: ^
  62. // CHECK:STDERR: fail_left_of_impls_non_type.carbon:[[@LINE+4]]:32: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  63. // CHECK:STDERR: fn NonTypeImpls(U:! type where 7 impls type);
  64. // CHECK:STDERR: ^
  65. // CHECK:STDERR:
  66. fn NonTypeImpls(U:! type where 7 impls type);
  67. // --- fail_right_of_impls_non_type.carbon
  68. library "[[@TEST_NAME]]";
  69. // CHECK:STDERR: fail_right_of_impls_non_type.carbon:[[@LINE+7]]:44: error: cannot implicitly convert non-type value of type `Core.IntLiteral` to `type` [ConversionFailureNonTypeToFacet]
  70. // CHECK:STDERR: fn ImplsNonType(U:! type where .Self impls 7);
  71. // CHECK:STDERR: ^
  72. // CHECK:STDERR: fail_right_of_impls_non_type.carbon:[[@LINE+4]]:44: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  73. // CHECK:STDERR: fn ImplsNonType(U:! type where .Self impls 7);
  74. // CHECK:STDERR: ^
  75. // CHECK:STDERR:
  76. fn ImplsNonType(U:! type where .Self impls 7);
  77. // --- fail_right_of_impls_non_facet_type.carbon
  78. library "[[@TEST_NAME]]";
  79. // CHECK:STDERR: fail_right_of_impls_non_facet_type.carbon:[[@LINE+4]]:51: error: right argument of `impls` requirement must be a facet type [ImplsOnNonFacetType]
  80. // CHECK:STDERR: fn ImplsOfNonFacetType(U:! type where .Self impls i32);
  81. // CHECK:STDERR: ^~~
  82. // CHECK:STDERR:
  83. fn ImplsOfNonFacetType(U:! type where .Self impls i32);
  84. // --- fail_enforce_impls_constraint.carbon
  85. library "[[@TEST_NAME]]";
  86. import library "state_constraints";
  87. // C implements J but not I.
  88. class C {}
  89. impl C as J {}
  90. fn DoesNotImplI() {
  91. // CHECK:STDERR: fail_enforce_impls_constraint.carbon:[[@LINE+8]]:3: error: cannot convert type `C` into type implementing `J where .Self impls I` [ConversionFailureTypeToFacet]
  92. // CHECK:STDERR: Impls(C);
  93. // CHECK:STDERR: ^~~~~~~~
  94. // CHECK:STDERR: fail_enforce_impls_constraint.carbon:[[@LINE-10]]:1: in import [InImport]
  95. // CHECK:STDERR: state_constraints.carbon:14:10: note: initializing generic parameter `V` declared here [InitializingGenericParam]
  96. // CHECK:STDERR: fn Impls(V:! J where .Self impls I);
  97. // CHECK:STDERR: ^
  98. // CHECK:STDERR:
  99. Impls(C);
  100. }
  101. // --- fail_todo_enforce_equality_constraint.carbon
  102. library "[[@TEST_NAME]]";
  103. import library "state_constraints";
  104. class C {}
  105. impl C as J {}
  106. fn EmptyStruct(Y:! J where .Self == {});
  107. // TODO: Should report that `C` does not meeet the `==` constraint. Right
  108. // now there is no support for `==` constraints so it rejects it as an
  109. // "other currently unsupported constraint."
  110. fn NotEmptyStruct() {
  111. // CHECK:STDERR: fail_todo_enforce_equality_constraint.carbon:[[@LINE+7]]:3: error: cannot convert type `C` into type implementing `J where...` [ConversionFailureTypeToFacet]
  112. // CHECK:STDERR: EmptyStruct(C);
  113. // CHECK:STDERR: ^~~~~~~~~~~~~~
  114. // CHECK:STDERR: fail_todo_enforce_equality_constraint.carbon:[[@LINE-9]]:16: note: initializing generic parameter `Y` declared here [InitializingGenericParam]
  115. // CHECK:STDERR: fn EmptyStruct(Y:! J where .Self == {});
  116. // CHECK:STDERR: ^
  117. // CHECK:STDERR:
  118. EmptyStruct(C);
  119. }
  120. // --- fail_error_in_constraint.carbon
  121. library "[[@TEST_NAME]]";
  122. //@dump-sem-ir-begin
  123. // CHECK:STDERR: fail_error_in_constraint.carbon:[[@LINE+4]]:41: error: name `I` not found [NameNotFound]
  124. // CHECK:STDERR: fn WithError(U:! type where .Self impls I);
  125. // CHECK:STDERR: ^
  126. // CHECK:STDERR:
  127. fn WithError(U:! type where .Self impls I);
  128. //@dump-sem-ir-end
  129. // --- import_error_in_constraint.carbon
  130. library "[[@TEST_NAME]]";
  131. import library "error_in_constraint";
  132. fn F() {
  133. //@dump-sem-ir-begin
  134. let x: () = WithError(());
  135. //@dump-sem-ir-end
  136. }
  137. // CHECK:STDOUT: --- self_impls_type.carbon
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: constants {
  140. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  141. // CHECK:STDOUT: %.Self.420: %I.type = symbolic_binding .Self [symbolic_self]
  142. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self.420 [symbolic_self]
  143. // CHECK:STDOUT: %T: %I.type = symbolic_binding T, 0 [symbolic]
  144. // CHECK:STDOUT: %pattern_type: type = pattern_type %I.type [concrete]
  145. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  146. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  147. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  148. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: imports {
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: file {
  155. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  156. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  157. // CHECK:STDOUT: } {
  158. // CHECK:STDOUT: %.loc7_12.1: type = splice_block %.loc7_12.2 [concrete = constants.%I.type] {
  159. // CHECK:STDOUT: <elided>
  160. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  161. // CHECK:STDOUT: <elided>
  162. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.420]
  163. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.binding.as_type]
  164. // CHECK:STDOUT: %.loc7_18: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.binding.as_type]
  165. // CHECK:STDOUT: %.loc7_12.2: type = where_expr %.Self.2 [concrete = constants.%I.type] {
  166. // CHECK:STDOUT: requirement_base_facet_type constants.%I.type
  167. // CHECK:STDOUT: requirement_impls %.loc7_18, type
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT: %T.loc7_6.2: %I.type = symbolic_binding T, 0 [symbolic = %T.loc7_6.1 (constants.%T)]
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  173. // CHECK:STDOUT: %T.patt: %pattern_type = symbolic_binding_pattern T, 0 [concrete]
  174. // CHECK:STDOUT: } {
  175. // CHECK:STDOUT: %.loc13_12.1: type = splice_block %.loc13_12.2 [concrete = constants.%I.type] {
  176. // CHECK:STDOUT: <elided>
  177. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  178. // CHECK:STDOUT: <elided>
  179. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.420]
  180. // CHECK:STDOUT: %Type.ref: type = name_ref Type, file.%Type [concrete = type]
  181. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.binding.as_type]
  182. // CHECK:STDOUT: %.loc13_18: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.binding.as_type]
  183. // CHECK:STDOUT: %.loc13_12.2: type = where_expr %.Self.2 [concrete = constants.%I.type] {
  184. // CHECK:STDOUT: requirement_base_facet_type constants.%I.type
  185. // CHECK:STDOUT: requirement_impls %.loc13_18, %Type.ref
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT: %T.loc13_6.2: %I.type = symbolic_binding T, 0 [symbolic = %T.loc13_6.1 (constants.%T)]
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: generic fn @F(%T.loc7_6.2: %I.type) {
  193. // CHECK:STDOUT: %T.loc7_6.1: %I.type = symbolic_binding T, 0 [symbolic = %T.loc7_6.1 (constants.%T)]
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: fn();
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: generic fn @G(%T.loc13_6.2: %I.type) {
  199. // CHECK:STDOUT: %T.loc13_6.1: %I.type = symbolic_binding T, 0 [symbolic = %T.loc13_6.1 (constants.%T)]
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: fn();
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: specific @F(constants.%T) {
  205. // CHECK:STDOUT: %T.loc7_6.1 => constants.%T
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: specific @G(constants.%T) {
  209. // CHECK:STDOUT: %T.loc13_6.1 => constants.%T
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: --- fail_self_impls_error.carbon
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: constants {
  215. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  216. // CHECK:STDOUT: %.Self.420: %I.type = symbolic_binding .Self [symbolic_self]
  217. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self.420 [symbolic_self]
  218. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  219. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: imports {
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: file {
  226. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  227. // CHECK:STDOUT: %T.patt: <error> = symbolic_binding_pattern T, 0 [concrete]
  228. // CHECK:STDOUT: } {
  229. // CHECK:STDOUT: %.loc14_12.1: type = splice_block %.loc14_12.2 [concrete = <error>] {
  230. // CHECK:STDOUT: <elided>
  231. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  232. // CHECK:STDOUT: <elided>
  233. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.420]
  234. // CHECK:STDOUT: %J.ref: <error> = name_ref J, <error> [concrete = <error>]
  235. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.binding.as_type]
  236. // CHECK:STDOUT: %.loc14_18: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.binding.as_type]
  237. // CHECK:STDOUT: %.loc14_12.2: type = where_expr %.Self.2 [concrete = <error>] {
  238. // CHECK:STDOUT: requirement_base_facet_type constants.%I.type
  239. // CHECK:STDOUT: requirement_impls %.loc14_18, <error>
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT: %T: <error> = symbolic_binding T, 0 [concrete = <error>]
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: generic fn @F(%T: <error>) {
  247. // CHECK:STDOUT: fn();
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: specific @F(<error>) {}
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: --- state_constraints.carbon
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: constants {
  255. // CHECK:STDOUT: %J.type: type = facet_type <@J> [concrete]
  256. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  257. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  258. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%Member [concrete]
  259. // CHECK:STDOUT: %.Self.420: %I.type = symbolic_binding .Self [symbolic_self]
  260. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  261. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  262. // CHECK:STDOUT: %I_where.type.a09: type = facet_type <@I where TODO> [concrete]
  263. // CHECK:STDOUT: %U: %I_where.type.a09 = symbolic_binding U, 0 [symbolic]
  264. // CHECK:STDOUT: %pattern_type.917: type = pattern_type %I_where.type.a09 [concrete]
  265. // CHECK:STDOUT: %EqualEqual.type: type = fn_type @EqualEqual [concrete]
  266. // CHECK:STDOUT: %EqualEqual: %EqualEqual.type = struct_value () [concrete]
  267. // CHECK:STDOUT: %.Self.c58: %J.type = symbolic_binding .Self [symbolic_self]
  268. // CHECK:STDOUT: %.Self.binding.as_type.338: type = symbolic_binding_type .Self, %.Self.c58 [symbolic_self]
  269. // CHECK:STDOUT: %J_where.type: type = facet_type <@J where .Self impls @I> [concrete]
  270. // CHECK:STDOUT: %V: %J_where.type = symbolic_binding V, 0 [symbolic]
  271. // CHECK:STDOUT: %pattern_type.74f: type = pattern_type %J_where.type [concrete]
  272. // CHECK:STDOUT: %Impls.type: type = fn_type @Impls [concrete]
  273. // CHECK:STDOUT: %Impls: %Impls.type = struct_value () [concrete]
  274. // CHECK:STDOUT: %.Self.binding.as_type.765: type = symbolic_binding_type .Self, %.Self.420 [symbolic_self]
  275. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %.Self.420, @I [symbolic_self]
  276. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %I.lookup_impl_witness, element0 [symbolic_self]
  277. // CHECK:STDOUT: %I_where.type.e04: type = facet_type <@I where .Self impls @J and TODO> [concrete]
  278. // CHECK:STDOUT: %W: %I_where.type.e04 = symbolic_binding W, 0 [symbolic]
  279. // CHECK:STDOUT: %pattern_type.194: type = pattern_type %I_where.type.e04 [concrete]
  280. // CHECK:STDOUT: %And.type: type = fn_type @And [concrete]
  281. // CHECK:STDOUT: %And: %And.type = struct_value () [concrete]
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: imports {
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: file {
  288. // CHECK:STDOUT: %EqualEqual.decl: %EqualEqual.type = fn_decl @EqualEqual [concrete = constants.%EqualEqual] {
  289. // CHECK:STDOUT: %U.patt: %pattern_type.917 = symbolic_binding_pattern U, 0 [concrete]
  290. // CHECK:STDOUT: } {
  291. // CHECK:STDOUT: %.loc12_21.1: type = splice_block %.loc12_21.2 [concrete = constants.%I_where.type.a09] {
  292. // CHECK:STDOUT: <elided>
  293. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  294. // CHECK:STDOUT: <elided>
  295. // CHECK:STDOUT: %.Self.ref: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.420]
  296. // CHECK:STDOUT: %.loc12_37: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  297. // CHECK:STDOUT: %.loc12_21.2: type = where_expr %.Self.2 [concrete = constants.%I_where.type.a09] {
  298. // CHECK:STDOUT: requirement_base_facet_type constants.%I.type
  299. // CHECK:STDOUT: requirement_equivalent %.Self.ref, %.loc12_37
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT: %U.loc12_15.2: %I_where.type.a09 = symbolic_binding U, 0 [symbolic = %U.loc12_15.1 (constants.%U)]
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT: %Impls.decl: %Impls.type = fn_decl @Impls [concrete = constants.%Impls] {
  305. // CHECK:STDOUT: %V.patt: %pattern_type.74f = symbolic_binding_pattern V, 0 [concrete]
  306. // CHECK:STDOUT: } {
  307. // CHECK:STDOUT: %.loc14_16.1: type = splice_block %.loc14_16.2 [concrete = constants.%J_where.type] {
  308. // CHECK:STDOUT: <elided>
  309. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  310. // CHECK:STDOUT: <elided>
  311. // CHECK:STDOUT: %.Self.ref: %J.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.c58]
  312. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  313. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.binding.as_type.338]
  314. // CHECK:STDOUT: %.loc14_22: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.binding.as_type.338]
  315. // CHECK:STDOUT: %.loc14_16.2: type = where_expr %.Self.2 [concrete = constants.%J_where.type] {
  316. // CHECK:STDOUT: requirement_base_facet_type constants.%J.type
  317. // CHECK:STDOUT: requirement_impls %.loc14_22, %I.ref
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT: }
  320. // CHECK:STDOUT: %V.loc14_10.2: %J_where.type = symbolic_binding V, 0 [symbolic = %V.loc14_10.1 (constants.%V)]
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: %And.decl: %And.type = fn_decl @And [concrete = constants.%And] {
  323. // CHECK:STDOUT: %W.patt: %pattern_type.194 = symbolic_binding_pattern W, 0 [concrete]
  324. // CHECK:STDOUT: } {
  325. // CHECK:STDOUT: %.loc16_14.1: type = splice_block %.loc16_14.2 [concrete = constants.%I_where.type.e04] {
  326. // CHECK:STDOUT: <elided>
  327. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  328. // CHECK:STDOUT: <elided>
  329. // CHECK:STDOUT: %.Self.ref.loc16_20: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.420]
  330. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [concrete = constants.%J.type]
  331. // CHECK:STDOUT: %.Self.as_type.loc16_20: type = facet_access_type %.Self.ref.loc16_20 [symbolic_self = constants.%.Self.binding.as_type.765]
  332. // CHECK:STDOUT: %.loc16_20: type = converted %.Self.ref.loc16_20, %.Self.as_type.loc16_20 [symbolic_self = constants.%.Self.binding.as_type.765]
  333. // CHECK:STDOUT: %.Self.ref.loc16_38: %I.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.420]
  334. // CHECK:STDOUT: %Member.ref: %I.assoc_type = name_ref Member, @Member.%assoc0 [concrete = constants.%assoc0]
  335. // CHECK:STDOUT: %.Self.as_type.loc16_38: type = facet_access_type %.Self.ref.loc16_38 [symbolic_self = constants.%.Self.binding.as_type.765]
  336. // CHECK:STDOUT: %.loc16_38: type = converted %.Self.ref.loc16_38, %.Self.as_type.loc16_38 [symbolic_self = constants.%.Self.binding.as_type.765]
  337. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  338. // CHECK:STDOUT: %.loc16_50: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  339. // CHECK:STDOUT: %.loc16_14.2: type = where_expr %.Self.2 [concrete = constants.%I_where.type.e04] {
  340. // CHECK:STDOUT: requirement_base_facet_type constants.%I.type
  341. // CHECK:STDOUT: requirement_impls %.loc16_20, %J.ref
  342. // CHECK:STDOUT: requirement_equivalent %impl.elem0, %.loc16_50
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %W.loc16_8.2: %I_where.type.e04 = symbolic_binding W, 0 [symbolic = %W.loc16_8.1 (constants.%W)]
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: generic fn @EqualEqual(%U.loc12_15.2: %I_where.type.a09) {
  350. // CHECK:STDOUT: %U.loc12_15.1: %I_where.type.a09 = symbolic_binding U, 0 [symbolic = %U.loc12_15.1 (constants.%U)]
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: fn();
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: generic fn @Impls(%V.loc14_10.2: %J_where.type) {
  356. // CHECK:STDOUT: %V.loc14_10.1: %J_where.type = symbolic_binding V, 0 [symbolic = %V.loc14_10.1 (constants.%V)]
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: fn();
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: generic fn @And(%W.loc16_8.2: %I_where.type.e04) {
  362. // CHECK:STDOUT: %W.loc16_8.1: %I_where.type.e04 = symbolic_binding W, 0 [symbolic = %W.loc16_8.1 (constants.%W)]
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: fn();
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: specific @EqualEqual(constants.%U) {
  368. // CHECK:STDOUT: %U.loc12_15.1 => constants.%U
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: specific @Impls(constants.%V) {
  372. // CHECK:STDOUT: %V.loc14_10.1 => constants.%V
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: specific @And(constants.%W) {
  376. // CHECK:STDOUT: %W.loc16_8.1 => constants.%W
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: --- associated_type_impls.carbon
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: constants {
  382. // CHECK:STDOUT: %L.type: type = facet_type <@L> [concrete]
  383. // CHECK:STDOUT: %M.type: type = facet_type <@M> [concrete]
  384. // CHECK:STDOUT: %K.type: type = facet_type <@K> [concrete]
  385. // CHECK:STDOUT: %K.assoc_type: type = assoc_entity_type @K [concrete]
  386. // CHECK:STDOUT: %assoc0: %K.assoc_type = assoc_entity element0, @K.%Associated [concrete]
  387. // CHECK:STDOUT: %.Self.a80: %K.type = symbolic_binding .Self [symbolic_self]
  388. // CHECK:STDOUT: %.Self.binding.as_type: type = symbolic_binding_type .Self, %.Self.a80 [symbolic_self]
  389. // CHECK:STDOUT: %K.lookup_impl_witness: <witness> = lookup_impl_witness %.Self.a80, @K [symbolic_self]
  390. // CHECK:STDOUT: %impl.elem0: %L.type = impl_witness_access %K.lookup_impl_witness, element0 [symbolic_self]
  391. // CHECK:STDOUT: %as_type: type = facet_access_type %impl.elem0 [symbolic_self]
  392. // CHECK:STDOUT: %K_where.type: type = facet_type <@K where TODO> [concrete]
  393. // CHECK:STDOUT: %W: %K_where.type = symbolic_binding W, 0 [symbolic]
  394. // CHECK:STDOUT: %pattern_type: type = pattern_type %K_where.type [concrete]
  395. // CHECK:STDOUT: %AssociatedTypeImpls.type: type = fn_type @AssociatedTypeImpls [concrete]
  396. // CHECK:STDOUT: %AssociatedTypeImpls: %AssociatedTypeImpls.type = struct_value () [concrete]
  397. // CHECK:STDOUT: }
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: imports {
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: file {
  403. // CHECK:STDOUT: %AssociatedTypeImpls.decl: %AssociatedTypeImpls.type = fn_decl @AssociatedTypeImpls [concrete = constants.%AssociatedTypeImpls] {
  404. // CHECK:STDOUT: %W.patt: %pattern_type = symbolic_binding_pattern W, 0 [concrete]
  405. // CHECK:STDOUT: } {
  406. // CHECK:STDOUT: %.loc12_30.1: type = splice_block %.loc12_30.2 [concrete = constants.%K_where.type] {
  407. // CHECK:STDOUT: <elided>
  408. // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [concrete = constants.%K.type]
  409. // CHECK:STDOUT: <elided>
  410. // CHECK:STDOUT: %.Self.ref: %K.type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.a80]
  411. // CHECK:STDOUT: %Associated.ref: %K.assoc_type = name_ref Associated, @Associated.%assoc0 [concrete = constants.%assoc0]
  412. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.binding.as_type]
  413. // CHECK:STDOUT: %.loc12_36.1: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.binding.as_type]
  414. // CHECK:STDOUT: %impl.elem0: %L.type = impl_witness_access constants.%K.lookup_impl_witness, element0 [symbolic_self = constants.%impl.elem0]
  415. // CHECK:STDOUT: %M.ref: type = name_ref M, file.%M.decl [concrete = constants.%M.type]
  416. // CHECK:STDOUT: %as_type: type = facet_access_type %impl.elem0 [symbolic_self = constants.%as_type]
  417. // CHECK:STDOUT: %.loc12_36.2: type = converted %impl.elem0, %as_type [symbolic_self = constants.%as_type]
  418. // CHECK:STDOUT: %.loc12_30.2: type = where_expr %.Self.2 [concrete = constants.%K_where.type] {
  419. // CHECK:STDOUT: requirement_base_facet_type constants.%K.type
  420. // CHECK:STDOUT: requirement_impls %.loc12_36.2, %M.ref
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT: %W.loc12_24.2: %K_where.type = symbolic_binding W, 0 [symbolic = %W.loc12_24.1 (constants.%W)]
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: generic fn @AssociatedTypeImpls(%W.loc12_24.2: %K_where.type) {
  428. // CHECK:STDOUT: %W.loc12_24.1: %K_where.type = symbolic_binding W, 0 [symbolic = %W.loc12_24.1 (constants.%W)]
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: fn();
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: specific @AssociatedTypeImpls(constants.%W) {
  434. // CHECK:STDOUT: %W.loc12_24.1 => constants.%W
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT:
  437. // CHECK:STDOUT: --- fail_error_in_constraint.carbon
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: constants {
  440. // CHECK:STDOUT: %.Self.bcc: type = symbolic_binding .Self [symbolic_self]
  441. // CHECK:STDOUT: %WithError.type: type = fn_type @WithError [concrete]
  442. // CHECK:STDOUT: %WithError: %WithError.type = struct_value () [concrete]
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: imports {
  446. // CHECK:STDOUT: }
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: file {
  449. // CHECK:STDOUT: %WithError.decl: %WithError.type = fn_decl @WithError [concrete = constants.%WithError] {
  450. // CHECK:STDOUT: %U.patt: <error> = symbolic_binding_pattern U, 0 [concrete]
  451. // CHECK:STDOUT: } {
  452. // CHECK:STDOUT: %.loc9_23.1: type = splice_block %.loc9_23.2 [concrete = <error>] {
  453. // CHECK:STDOUT: <elided>
  454. // CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.bcc]
  455. // CHECK:STDOUT: %I.ref: <error> = name_ref I, <error> [concrete = <error>]
  456. // CHECK:STDOUT: %.loc9_23.2: type = where_expr %.Self.2 [concrete = <error>] {
  457. // CHECK:STDOUT: requirement_base_facet_type type
  458. // CHECK:STDOUT: requirement_impls %.Self.ref, <error>
  459. // CHECK:STDOUT: }
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT: %U: <error> = symbolic_binding U, 0 [concrete = <error>]
  462. // CHECK:STDOUT: }
  463. // CHECK:STDOUT: }
  464. // CHECK:STDOUT:
  465. // CHECK:STDOUT: generic fn @WithError(%U: <error>) {
  466. // CHECK:STDOUT: fn();
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: specific @WithError(<error>) {}
  470. // CHECK:STDOUT:
  471. // CHECK:STDOUT: --- import_error_in_constraint.carbon
  472. // CHECK:STDOUT:
  473. // CHECK:STDOUT: constants {
  474. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  475. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  476. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  477. // CHECK:STDOUT: %WithError.type: type = fn_type @WithError [concrete]
  478. // CHECK:STDOUT: %WithError: %WithError.type = struct_value () [concrete]
  479. // CHECK:STDOUT: }
  480. // CHECK:STDOUT:
  481. // CHECK:STDOUT: imports {
  482. // CHECK:STDOUT: %Main.WithError: %WithError.type = import_ref Main//error_in_constraint, WithError, loaded [concrete = constants.%WithError]
  483. // CHECK:STDOUT: }
  484. // CHECK:STDOUT:
  485. // CHECK:STDOUT: fn @F() {
  486. // CHECK:STDOUT: !entry:
  487. // CHECK:STDOUT: name_binding_decl {
  488. // CHECK:STDOUT: %x.patt: %pattern_type = value_binding_pattern x [concrete]
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT: %WithError.ref: %WithError.type = name_ref WithError, imports.%Main.WithError [concrete = constants.%WithError]
  491. // CHECK:STDOUT: %.loc8_26: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  492. // CHECK:STDOUT: %.loc8_11.1: type = splice_block %.loc8_11.3 [concrete = constants.%empty_tuple.type] {
  493. // CHECK:STDOUT: %.loc8_11.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  494. // CHECK:STDOUT: %.loc8_11.3: type = converted %.loc8_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  495. // CHECK:STDOUT: }
  496. // CHECK:STDOUT: %x: %empty_tuple.type = value_binding x, <error> [concrete = <error>]
  497. // CHECK:STDOUT: <elided>
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT: