eq.carbon 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/eq.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/eq.carbon
  10. // --- user.carbon
  11. package User;
  12. class C {};
  13. impl C as Core.Eq {
  14. fn Equal[self: C](other: C) -> bool;
  15. fn NotEqual[self: C](other: C) -> bool;
  16. }
  17. fn TestEqual(a: C, b: C) -> bool {
  18. return a == b;
  19. }
  20. fn TestNotEqual(a: C, b: C) -> bool {
  21. return a != b;
  22. }
  23. // --- fail_no_impl.carbon
  24. package FailNoImpl;
  25. class D {};
  26. fn TestEqual(a: D, b: D) -> bool {
  27. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+4]]:10: error: cannot access member of interface `Eq` in type `D` that does not implement that interface
  28. // CHECK:STDERR: return a == b;
  29. // CHECK:STDERR: ^~~~~~
  30. // CHECK:STDERR:
  31. return a == b;
  32. }
  33. fn TestNotEqual(a: D, b: D) -> bool {
  34. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+4]]:10: error: cannot access member of interface `Eq` in type `D` that does not implement that interface
  35. // CHECK:STDERR: return a != b;
  36. // CHECK:STDERR: ^~~~~~
  37. // CHECK:STDERR:
  38. return a != b;
  39. }
  40. // --- fail_no_impl_for_args.carbon
  41. package FailNoImplForArgs;
  42. class C {};
  43. class D {};
  44. impl C as Core.Eq {
  45. fn Equal[self: C](other: C) -> bool;
  46. fn NotEqual[self: C](other: C) -> bool;
  47. }
  48. fn TestRhsBad(a: C, b: D) -> bool {
  49. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE+10]]:15: error: cannot implicitly convert from `D` to `C`
  50. // CHECK:STDERR: return a == b;
  51. // CHECK:STDERR: ^
  52. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE+7]]:15: note: type `D` does not implement interface `ImplicitAs`
  53. // CHECK:STDERR: return a == b;
  54. // CHECK:STDERR: ^
  55. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE-11]]:3: note: initializing parameter 1 of function declared here
  56. // CHECK:STDERR: fn Equal[self: C](other: C) -> bool;
  57. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. // CHECK:STDERR:
  59. return a == b;
  60. }
  61. fn TestLhsBad(a: D, b: C) -> bool {
  62. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE+3]]:10: error: cannot access member of interface `Eq` in type `D` that does not implement that interface
  63. // CHECK:STDERR: return a != b;
  64. // CHECK:STDERR: ^~~~~~
  65. return a != b;
  66. }
  67. // CHECK:STDOUT: --- user.carbon
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: constants {
  70. // CHECK:STDOUT: %C: type = class_type @C [template]
  71. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  72. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  73. // CHECK:STDOUT: %Eq.type: type = interface_type @Eq [template]
  74. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic]
  75. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  76. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  77. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  78. // CHECK:STDOUT: %Equal.type.1: type = fn_type @Equal.1 [template]
  79. // CHECK:STDOUT: %Equal.1: %Equal.type.1 = struct_value () [template]
  80. // CHECK:STDOUT: %NotEqual.type.1: type = fn_type @NotEqual.1 [template]
  81. // CHECK:STDOUT: %NotEqual.1: %NotEqual.type.1 = struct_value () [template]
  82. // CHECK:STDOUT: %Equal.type.2: type = fn_type @Equal.2 [template]
  83. // CHECK:STDOUT: %Equal.2: %Equal.type.2 = struct_value () [template]
  84. // CHECK:STDOUT: %NotEqual.type.2: type = fn_type @NotEqual.2 [template]
  85. // CHECK:STDOUT: %NotEqual.2: %NotEqual.type.2 = struct_value () [template]
  86. // CHECK:STDOUT: %.4: <witness> = interface_witness (%Equal.1, %NotEqual.1) [template]
  87. // CHECK:STDOUT: %TestEqual.type: type = fn_type @TestEqual [template]
  88. // CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [template]
  89. // CHECK:STDOUT: %.5: type = ptr_type %.1 [template]
  90. // CHECK:STDOUT: %.6: type = assoc_entity_type %Eq.type, %Equal.type.2 [template]
  91. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template]
  92. // CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [template]
  93. // CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [template]
  94. // CHECK:STDOUT: %.8: type = assoc_entity_type %Eq.type, %NotEqual.type.2 [template]
  95. // CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.9 [template]
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: imports {
  99. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  100. // CHECK:STDOUT: .Eq = %import_ref.1
  101. // CHECK:STDOUT: .Bool = %import_ref.7
  102. // CHECK:STDOUT: import Core//prelude
  103. // CHECK:STDOUT: import Core//prelude/operators
  104. // CHECK:STDOUT: import Core//prelude/types
  105. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  106. // CHECK:STDOUT: import Core//prelude/operators/as
  107. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  108. // CHECK:STDOUT: import Core//prelude/operators/comparison
  109. // CHECK:STDOUT: import Core//prelude/types/bool
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%Eq.type]
  112. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
  113. // CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+35, loaded [template = constants.%.7]
  114. // CHECK:STDOUT: %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+60, loaded [template = constants.%.9]
  115. // CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+30, loaded [template = constants.%Equal.2]
  116. // CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+55, loaded [template = constants.%NotEqual.2]
  117. // CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  118. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+30, unloaded
  119. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+55, unloaded
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: file {
  123. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  124. // CHECK:STDOUT: .Core = imports.%Core
  125. // CHECK:STDOUT: .C = %C.decl
  126. // CHECK:STDOUT: .TestEqual = %TestEqual.decl
  127. // CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: %Core.import = import Core
  130. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  131. // CHECK:STDOUT: impl_decl @impl [template] {} {
  132. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  133. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  134. // CHECK:STDOUT: %Eq.ref: type = name_ref Eq, imports.%import_ref.1 [template = constants.%Eq.type]
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [template = constants.%TestEqual] {
  137. // CHECK:STDOUT: %a.patt: %C = binding_pattern a
  138. // CHECK:STDOUT: %a.param_patt: %C = param_pattern %a.patt, runtime_param0
  139. // CHECK:STDOUT: %b.patt: %C = binding_pattern b
  140. // CHECK:STDOUT: %b.param_patt: %C = param_pattern %b.patt, runtime_param1
  141. // CHECK:STDOUT: } {
  142. // CHECK:STDOUT: %C.ref.loc11_17: type = name_ref C, file.%C.decl [template = constants.%C]
  143. // CHECK:STDOUT: %C.ref.loc11_23: type = name_ref C, file.%C.decl [template = constants.%C]
  144. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  145. // CHECK:STDOUT: %.loc11_29.1: type = value_of_initializer %bool.make_type [template = bool]
  146. // CHECK:STDOUT: %.loc11_29.2: type = converted %bool.make_type, %.loc11_29.1 [template = bool]
  147. // CHECK:STDOUT: %return: ref bool = var <return slot>
  148. // CHECK:STDOUT: %param.loc11_14: %C = param runtime_param0
  149. // CHECK:STDOUT: %a: %C = bind_name a, %param.loc11_14
  150. // CHECK:STDOUT: %param.loc11_20: %C = param runtime_param1
  151. // CHECK:STDOUT: %b: %C = bind_name b, %param.loc11_20
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [template = constants.%TestNotEqual] {
  154. // CHECK:STDOUT: %a.patt: %C = binding_pattern a
  155. // CHECK:STDOUT: %a.param_patt: %C = param_pattern %a.patt, runtime_param0
  156. // CHECK:STDOUT: %b.patt: %C = binding_pattern b
  157. // CHECK:STDOUT: %b.param_patt: %C = param_pattern %b.patt, runtime_param1
  158. // CHECK:STDOUT: } {
  159. // CHECK:STDOUT: %C.ref.loc15_20: type = name_ref C, file.%C.decl [template = constants.%C]
  160. // CHECK:STDOUT: %C.ref.loc15_26: type = name_ref C, file.%C.decl [template = constants.%C]
  161. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  162. // CHECK:STDOUT: %.loc15_32.1: type = value_of_initializer %bool.make_type [template = bool]
  163. // CHECK:STDOUT: %.loc15_32.2: type = converted %bool.make_type, %.loc15_32.1 [template = bool]
  164. // CHECK:STDOUT: %return: ref bool = var <return slot>
  165. // CHECK:STDOUT: %param.loc15_17: %C = param runtime_param0
  166. // CHECK:STDOUT: %a: %C = bind_name a, %param.loc15_17
  167. // CHECK:STDOUT: %param.loc15_23: %C = param runtime_param1
  168. // CHECK:STDOUT: %b: %C = bind_name b, %param.loc15_23
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: interface @Eq {
  173. // CHECK:STDOUT: !members:
  174. // CHECK:STDOUT: .Self = imports.%import_ref.2
  175. // CHECK:STDOUT: .Equal = imports.%import_ref.3
  176. // CHECK:STDOUT: .NotEqual = imports.%import_ref.4
  177. // CHECK:STDOUT: witness = (imports.%import_ref.5, imports.%import_ref.6)
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: impl @impl: %C.ref as %Eq.ref {
  181. // CHECK:STDOUT: %Equal.decl: %Equal.type.1 = fn_decl @Equal.1 [template = constants.%Equal.1] {
  182. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  183. // CHECK:STDOUT: %self.param_patt: %C = param_pattern %self.patt, runtime_param0
  184. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  185. // CHECK:STDOUT: %other.param_patt: %C = param_pattern %other.patt, runtime_param1
  186. // CHECK:STDOUT: } {
  187. // CHECK:STDOUT: %C.ref.loc7_18: type = name_ref C, file.%C.decl [template = constants.%C]
  188. // CHECK:STDOUT: %C.ref.loc7_28: type = name_ref C, file.%C.decl [template = constants.%C]
  189. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  190. // CHECK:STDOUT: %.loc7_34.1: type = value_of_initializer %bool.make_type [template = bool]
  191. // CHECK:STDOUT: %.loc7_34.2: type = converted %bool.make_type, %.loc7_34.1 [template = bool]
  192. // CHECK:STDOUT: %return: ref bool = var <return slot>
  193. // CHECK:STDOUT: %param.loc7_12: %C = param runtime_param0
  194. // CHECK:STDOUT: %self: %C = bind_name self, %param.loc7_12
  195. // CHECK:STDOUT: %param.loc7_21: %C = param runtime_param1
  196. // CHECK:STDOUT: %other: %C = bind_name other, %param.loc7_21
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT: %NotEqual.decl: %NotEqual.type.1 = fn_decl @NotEqual.1 [template = constants.%NotEqual.1] {
  199. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  200. // CHECK:STDOUT: %self.param_patt: %C = param_pattern %self.patt, runtime_param0
  201. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  202. // CHECK:STDOUT: %other.param_patt: %C = param_pattern %other.patt, runtime_param1
  203. // CHECK:STDOUT: } {
  204. // CHECK:STDOUT: %C.ref.loc8_21: type = name_ref C, file.%C.decl [template = constants.%C]
  205. // CHECK:STDOUT: %C.ref.loc8_31: type = name_ref C, file.%C.decl [template = constants.%C]
  206. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  207. // CHECK:STDOUT: %.loc8_37.1: type = value_of_initializer %bool.make_type [template = bool]
  208. // CHECK:STDOUT: %.loc8_37.2: type = converted %bool.make_type, %.loc8_37.1 [template = bool]
  209. // CHECK:STDOUT: %return: ref bool = var <return slot>
  210. // CHECK:STDOUT: %param.loc8_15: %C = param runtime_param0
  211. // CHECK:STDOUT: %self: %C = bind_name self, %param.loc8_15
  212. // CHECK:STDOUT: %param.loc8_24: %C = param runtime_param1
  213. // CHECK:STDOUT: %other: %C = bind_name other, %param.loc8_24
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT: %.loc6: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: !members:
  218. // CHECK:STDOUT: .Equal = %Equal.decl
  219. // CHECK:STDOUT: .NotEqual = %NotEqual.decl
  220. // CHECK:STDOUT: witness = %.loc6
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: class @C {
  224. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: !members:
  227. // CHECK:STDOUT: .Self = constants.%C
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: fn @Equal.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: fn @NotEqual.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: generic fn @Equal.2(constants.%Self: %Eq.type) {
  237. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: fn[%self.param_patt: @Equal.2.%Self (%Self)](%other.param_patt: @Equal.2.%Self (%Self)) -> bool;
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self: %Eq.type) {
  243. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: fn[%self.param_patt: @NotEqual.2.%Self (%Self)](%other.param_patt: @NotEqual.2.%Self (%Self)) -> bool;
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: fn @TestEqual(%a.param_patt: %C, %b.param_patt: %C) -> bool {
  249. // CHECK:STDOUT: !entry:
  250. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  251. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  252. // CHECK:STDOUT: %Equal.ref: %.6 = name_ref Equal, imports.%import_ref.3 [template = constants.%.7]
  253. // CHECK:STDOUT: %.loc12_12.1: %Equal.type.2 = interface_witness_access constants.%.4, element0 [template = constants.%Equal.1]
  254. // CHECK:STDOUT: %.loc12_12.2: <bound method> = bound_method %a.ref, %.loc12_12.1
  255. // CHECK:STDOUT: %Equal.call: init bool = call %.loc12_12.2(%a.ref, %b.ref)
  256. // CHECK:STDOUT: %.loc12_16.1: bool = value_of_initializer %Equal.call
  257. // CHECK:STDOUT: %.loc12_16.2: bool = converted %Equal.call, %.loc12_16.1
  258. // CHECK:STDOUT: return %.loc12_16.2
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: fn @TestNotEqual(%a.param_patt: %C, %b.param_patt: %C) -> bool {
  262. // CHECK:STDOUT: !entry:
  263. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  264. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  265. // CHECK:STDOUT: %NotEqual.ref: %.8 = name_ref NotEqual, imports.%import_ref.4 [template = constants.%.9]
  266. // CHECK:STDOUT: %.loc16_12.1: %NotEqual.type.2 = interface_witness_access constants.%.4, element1 [template = constants.%NotEqual.1]
  267. // CHECK:STDOUT: %.loc16_12.2: <bound method> = bound_method %a.ref, %.loc16_12.1
  268. // CHECK:STDOUT: %NotEqual.call: init bool = call %.loc16_12.2(%a.ref, %b.ref)
  269. // CHECK:STDOUT: %.loc16_16.1: bool = value_of_initializer %NotEqual.call
  270. // CHECK:STDOUT: %.loc16_16.2: bool = converted %NotEqual.call, %.loc16_16.1
  271. // CHECK:STDOUT: return %.loc16_16.2
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: specific @Equal.2(constants.%Self) {
  275. // CHECK:STDOUT: %Self => constants.%Self
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: specific @Equal.2(constants.%C) {
  279. // CHECK:STDOUT: %Self => constants.%C
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: specific @NotEqual.2(constants.%Self) {
  283. // CHECK:STDOUT: %Self => constants.%Self
  284. // CHECK:STDOUT: }
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: specific @NotEqual.2(constants.%C) {
  287. // CHECK:STDOUT: %Self => constants.%C
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: --- fail_no_impl.carbon
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: constants {
  293. // CHECK:STDOUT: %D: type = class_type @D [template]
  294. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  295. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  296. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  297. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  298. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  299. // CHECK:STDOUT: %TestEqual.type: type = fn_type @TestEqual [template]
  300. // CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [template]
  301. // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
  302. // CHECK:STDOUT: %Eq.type: type = interface_type @Eq [template]
  303. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic]
  304. // CHECK:STDOUT: %Equal.type: type = fn_type @Equal [template]
  305. // CHECK:STDOUT: %Equal: %Equal.type = struct_value () [template]
  306. // CHECK:STDOUT: %.5: type = assoc_entity_type %Eq.type, %Equal.type [template]
  307. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.8 [template]
  308. // CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [template]
  309. // CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [template]
  310. // CHECK:STDOUT: %NotEqual.type: type = fn_type @NotEqual [template]
  311. // CHECK:STDOUT: %NotEqual: %NotEqual.type = struct_value () [template]
  312. // CHECK:STDOUT: %.7: type = assoc_entity_type %Eq.type, %NotEqual.type [template]
  313. // CHECK:STDOUT: %.8: %.7 = assoc_entity element1, imports.%import_ref.9 [template]
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: imports {
  317. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  318. // CHECK:STDOUT: .Bool = %import_ref.1
  319. // CHECK:STDOUT: .Eq = %import_ref.2
  320. // CHECK:STDOUT: import Core//prelude
  321. // CHECK:STDOUT: import Core//prelude/operators
  322. // CHECK:STDOUT: import Core//prelude/types
  323. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  324. // CHECK:STDOUT: import Core//prelude/operators/as
  325. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  326. // CHECK:STDOUT: import Core//prelude/operators/comparison
  327. // CHECK:STDOUT: import Core//prelude/types/bool
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  330. // CHECK:STDOUT: %import_ref.2: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%Eq.type]
  331. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
  332. // CHECK:STDOUT: %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+35, loaded [template = constants.%.6]
  333. // CHECK:STDOUT: %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+60, loaded [template = constants.%.8]
  334. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/comparison, inst+30, unloaded
  335. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/comparison, inst+55, unloaded
  336. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+30, unloaded
  337. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+55, unloaded
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: file {
  341. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  342. // CHECK:STDOUT: .Core = imports.%Core
  343. // CHECK:STDOUT: .D = %D.decl
  344. // CHECK:STDOUT: .TestEqual = %TestEqual.decl
  345. // CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: %Core.import = import Core
  348. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  349. // CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [template = constants.%TestEqual] {
  350. // CHECK:STDOUT: %a.patt: %D = binding_pattern a
  351. // CHECK:STDOUT: %a.param_patt: %D = param_pattern %a.patt, runtime_param0
  352. // CHECK:STDOUT: %b.patt: %D = binding_pattern b
  353. // CHECK:STDOUT: %b.param_patt: %D = param_pattern %b.patt, runtime_param1
  354. // CHECK:STDOUT: } {
  355. // CHECK:STDOUT: %D.ref.loc6_17: type = name_ref D, file.%D.decl [template = constants.%D]
  356. // CHECK:STDOUT: %D.ref.loc6_23: type = name_ref D, file.%D.decl [template = constants.%D]
  357. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  358. // CHECK:STDOUT: %.loc6_29.1: type = value_of_initializer %bool.make_type [template = bool]
  359. // CHECK:STDOUT: %.loc6_29.2: type = converted %bool.make_type, %.loc6_29.1 [template = bool]
  360. // CHECK:STDOUT: %return: ref bool = var <return slot>
  361. // CHECK:STDOUT: %param.loc6_14: %D = param runtime_param0
  362. // CHECK:STDOUT: %a: %D = bind_name a, %param.loc6_14
  363. // CHECK:STDOUT: %param.loc6_20: %D = param runtime_param1
  364. // CHECK:STDOUT: %b: %D = bind_name b, %param.loc6_20
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [template = constants.%TestNotEqual] {
  367. // CHECK:STDOUT: %a.patt: %D = binding_pattern a
  368. // CHECK:STDOUT: %a.param_patt: %D = param_pattern %a.patt, runtime_param0
  369. // CHECK:STDOUT: %b.patt: %D = binding_pattern b
  370. // CHECK:STDOUT: %b.param_patt: %D = param_pattern %b.patt, runtime_param1
  371. // CHECK:STDOUT: } {
  372. // CHECK:STDOUT: %D.ref.loc14_20: type = name_ref D, file.%D.decl [template = constants.%D]
  373. // CHECK:STDOUT: %D.ref.loc14_26: type = name_ref D, file.%D.decl [template = constants.%D]
  374. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  375. // CHECK:STDOUT: %.loc14_32.1: type = value_of_initializer %bool.make_type [template = bool]
  376. // CHECK:STDOUT: %.loc14_32.2: type = converted %bool.make_type, %.loc14_32.1 [template = bool]
  377. // CHECK:STDOUT: %return: ref bool = var <return slot>
  378. // CHECK:STDOUT: %param.loc14_17: %D = param runtime_param0
  379. // CHECK:STDOUT: %a: %D = bind_name a, %param.loc14_17
  380. // CHECK:STDOUT: %param.loc14_23: %D = param runtime_param1
  381. // CHECK:STDOUT: %b: %D = bind_name b, %param.loc14_23
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: interface @Eq {
  386. // CHECK:STDOUT: !members:
  387. // CHECK:STDOUT: .Self = imports.%import_ref.3
  388. // CHECK:STDOUT: .Equal = imports.%import_ref.4
  389. // CHECK:STDOUT: .NotEqual = imports.%import_ref.5
  390. // CHECK:STDOUT: witness = (imports.%import_ref.6, imports.%import_ref.7)
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: class @D {
  394. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: !members:
  397. // CHECK:STDOUT: .Self = constants.%D
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: fn @TestEqual(%a.param_patt: %D, %b.param_patt: %D) -> bool {
  403. // CHECK:STDOUT: !entry:
  404. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  405. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  406. // CHECK:STDOUT: %Equal.ref: %.5 = name_ref Equal, imports.%import_ref.4 [template = constants.%.6]
  407. // CHECK:STDOUT: return <error>
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: generic fn @Equal(constants.%Self: %Eq.type) {
  411. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: fn[%self.param_patt: @Equal.%Self (%Self)](%other.param_patt: @Equal.%Self (%Self)) -> bool;
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: fn @TestNotEqual(%a.param_patt: %D, %b.param_patt: %D) -> bool {
  417. // CHECK:STDOUT: !entry:
  418. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  419. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  420. // CHECK:STDOUT: %NotEqual.ref: %.7 = name_ref NotEqual, imports.%import_ref.5 [template = constants.%.8]
  421. // CHECK:STDOUT: return <error>
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: generic fn @NotEqual(constants.%Self: %Eq.type) {
  425. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: fn[%self.param_patt: @NotEqual.%Self (%Self)](%other.param_patt: @NotEqual.%Self (%Self)) -> bool;
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: specific @Equal(constants.%Self) {
  431. // CHECK:STDOUT: %Self => constants.%Self
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: specific @NotEqual(constants.%Self) {
  435. // CHECK:STDOUT: %Self => constants.%Self
  436. // CHECK:STDOUT: }
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: --- fail_no_impl_for_args.carbon
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: constants {
  441. // CHECK:STDOUT: %C: type = class_type @C [template]
  442. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  443. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  444. // CHECK:STDOUT: %D: type = class_type @D [template]
  445. // CHECK:STDOUT: %Eq.type: type = interface_type @Eq [template]
  446. // CHECK:STDOUT: %Self.1: %Eq.type = bind_symbolic_name Self, 0 [symbolic]
  447. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  448. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  449. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  450. // CHECK:STDOUT: %Equal.type.1: type = fn_type @Equal.1 [template]
  451. // CHECK:STDOUT: %Equal.1: %Equal.type.1 = struct_value () [template]
  452. // CHECK:STDOUT: %NotEqual.type.1: type = fn_type @NotEqual.1 [template]
  453. // CHECK:STDOUT: %NotEqual.1: %NotEqual.type.1 = struct_value () [template]
  454. // CHECK:STDOUT: %Equal.type.2: type = fn_type @Equal.2 [template]
  455. // CHECK:STDOUT: %Equal.2: %Equal.type.2 = struct_value () [template]
  456. // CHECK:STDOUT: %NotEqual.type.2: type = fn_type @NotEqual.2 [template]
  457. // CHECK:STDOUT: %NotEqual.2: %NotEqual.type.2 = struct_value () [template]
  458. // CHECK:STDOUT: %.4: <witness> = interface_witness (%Equal.1, %NotEqual.1) [template]
  459. // CHECK:STDOUT: %TestRhsBad.type: type = fn_type @TestRhsBad [template]
  460. // CHECK:STDOUT: %TestRhsBad: %TestRhsBad.type = struct_value () [template]
  461. // CHECK:STDOUT: %.5: type = ptr_type %.1 [template]
  462. // CHECK:STDOUT: %.6: type = assoc_entity_type %Eq.type, %Equal.type.2 [template]
  463. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template]
  464. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  465. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  466. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  467. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  468. // CHECK:STDOUT: %Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  469. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  470. // CHECK:STDOUT: %Self.3: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  471. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  472. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  473. // CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  474. // CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.13 [symbolic]
  475. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%C) [template]
  476. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%C) [template]
  477. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  478. // CHECK:STDOUT: %.10: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  479. // CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.13 [template]
  480. // CHECK:STDOUT: %.12: %.8 = assoc_entity element0, imports.%import_ref.14 [symbolic]
  481. // CHECK:STDOUT: %TestLhsBad.type: type = fn_type @TestLhsBad [template]
  482. // CHECK:STDOUT: %TestLhsBad: %TestLhsBad.type = struct_value () [template]
  483. // CHECK:STDOUT: %.13: type = assoc_entity_type %Eq.type, %NotEqual.type.2 [template]
  484. // CHECK:STDOUT: %.14: %.13 = assoc_entity element1, imports.%import_ref.15 [template]
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: imports {
  488. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  489. // CHECK:STDOUT: .Eq = %import_ref.1
  490. // CHECK:STDOUT: .Bool = %import_ref.7
  491. // CHECK:STDOUT: .ImplicitAs = %import_ref.9
  492. // CHECK:STDOUT: import Core//prelude
  493. // CHECK:STDOUT: import Core//prelude/operators
  494. // CHECK:STDOUT: import Core//prelude/types
  495. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  496. // CHECK:STDOUT: import Core//prelude/operators/as
  497. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  498. // CHECK:STDOUT: import Core//prelude/operators/comparison
  499. // CHECK:STDOUT: import Core//prelude/types/bool
  500. // CHECK:STDOUT: }
  501. // CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%Eq.type]
  502. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
  503. // CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+35, loaded [template = constants.%.7]
  504. // CHECK:STDOUT: %import_ref.4: %.13 = import_ref Core//prelude/operators/comparison, inst+60, loaded [template = constants.%.14]
  505. // CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+30, loaded [template = constants.%Equal.2]
  506. // CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+55, loaded [template = constants.%NotEqual.2]
  507. // CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  508. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+30, unloaded
  509. // CHECK:STDOUT: %import_ref.9: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+46, loaded [template = constants.%ImplicitAs]
  510. // CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/as, inst+52, unloaded
  511. // CHECK:STDOUT: %import_ref.11: @ImplicitAs.%.1 (%.8) = import_ref Core//prelude/operators/as, inst+71, loaded [symbolic = @ImplicitAs.%.2 (constants.%.12)]
  512. // CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/as, inst+64, unloaded
  513. // CHECK:STDOUT: %import_ref.13 = import_ref Core//prelude/operators/as, inst+64, unloaded
  514. // CHECK:STDOUT: %import_ref.14 = import_ref Core//prelude/operators/as, inst+64, unloaded
  515. // CHECK:STDOUT: %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+55, unloaded
  516. // CHECK:STDOUT: }
  517. // CHECK:STDOUT:
  518. // CHECK:STDOUT: file {
  519. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  520. // CHECK:STDOUT: .Core = imports.%Core
  521. // CHECK:STDOUT: .C = %C.decl
  522. // CHECK:STDOUT: .D = %D.decl
  523. // CHECK:STDOUT: .TestRhsBad = %TestRhsBad.decl
  524. // CHECK:STDOUT: .TestLhsBad = %TestLhsBad.decl
  525. // CHECK:STDOUT: }
  526. // CHECK:STDOUT: %Core.import = import Core
  527. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  528. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  529. // CHECK:STDOUT: impl_decl @impl [template] {} {
  530. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  531. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  532. // CHECK:STDOUT: %Eq.ref: type = name_ref Eq, imports.%import_ref.1 [template = constants.%Eq.type]
  533. // CHECK:STDOUT: }
  534. // CHECK:STDOUT: %TestRhsBad.decl: %TestRhsBad.type = fn_decl @TestRhsBad [template = constants.%TestRhsBad] {
  535. // CHECK:STDOUT: %a.patt: %C = binding_pattern a
  536. // CHECK:STDOUT: %a.param_patt: %C = param_pattern %a.patt, runtime_param0
  537. // CHECK:STDOUT: %b.patt: %D = binding_pattern b
  538. // CHECK:STDOUT: %b.param_patt: %D = param_pattern %b.patt, runtime_param1
  539. // CHECK:STDOUT: } {
  540. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  541. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  542. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  543. // CHECK:STDOUT: %.loc12_30.1: type = value_of_initializer %bool.make_type [template = bool]
  544. // CHECK:STDOUT: %.loc12_30.2: type = converted %bool.make_type, %.loc12_30.1 [template = bool]
  545. // CHECK:STDOUT: %return: ref bool = var <return slot>
  546. // CHECK:STDOUT: %param.loc12_15: %C = param runtime_param0
  547. // CHECK:STDOUT: %a: %C = bind_name a, %param.loc12_15
  548. // CHECK:STDOUT: %param.loc12_21: %D = param runtime_param1
  549. // CHECK:STDOUT: %b: %D = bind_name b, %param.loc12_21
  550. // CHECK:STDOUT: }
  551. // CHECK:STDOUT: %TestLhsBad.decl: %TestLhsBad.type = fn_decl @TestLhsBad [template = constants.%TestLhsBad] {
  552. // CHECK:STDOUT: %a.patt: %D = binding_pattern a
  553. // CHECK:STDOUT: %a.param_patt: %D = param_pattern %a.patt, runtime_param0
  554. // CHECK:STDOUT: %b.patt: %C = binding_pattern b
  555. // CHECK:STDOUT: %b.param_patt: %C = param_pattern %b.patt, runtime_param1
  556. // CHECK:STDOUT: } {
  557. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  558. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  559. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  560. // CHECK:STDOUT: %.loc26_30.1: type = value_of_initializer %bool.make_type [template = bool]
  561. // CHECK:STDOUT: %.loc26_30.2: type = converted %bool.make_type, %.loc26_30.1 [template = bool]
  562. // CHECK:STDOUT: %return: ref bool = var <return slot>
  563. // CHECK:STDOUT: %param.loc26_15: %D = param runtime_param0
  564. // CHECK:STDOUT: %a: %D = bind_name a, %param.loc26_15
  565. // CHECK:STDOUT: %param.loc26_21: %C = param runtime_param1
  566. // CHECK:STDOUT: %b: %C = bind_name b, %param.loc26_21
  567. // CHECK:STDOUT: }
  568. // CHECK:STDOUT: }
  569. // CHECK:STDOUT:
  570. // CHECK:STDOUT: interface @Eq {
  571. // CHECK:STDOUT: !members:
  572. // CHECK:STDOUT: .Self = imports.%import_ref.2
  573. // CHECK:STDOUT: .Equal = imports.%import_ref.3
  574. // CHECK:STDOUT: .NotEqual = imports.%import_ref.4
  575. // CHECK:STDOUT: witness = (imports.%import_ref.5, imports.%import_ref.6)
  576. // CHECK:STDOUT: }
  577. // CHECK:STDOUT:
  578. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  579. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  580. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  581. // CHECK:STDOUT:
  582. // CHECK:STDOUT: !definition:
  583. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  584. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)]
  585. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  586. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  587. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.8)]
  588. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.8) = assoc_entity element0, imports.%import_ref.13 [symbolic = %.2 (constants.%.9)]
  589. // CHECK:STDOUT:
  590. // CHECK:STDOUT: interface {
  591. // CHECK:STDOUT: !members:
  592. // CHECK:STDOUT: .Self = imports.%import_ref.10
  593. // CHECK:STDOUT: .Convert = imports.%import_ref.11
  594. // CHECK:STDOUT: witness = (imports.%import_ref.12)
  595. // CHECK:STDOUT: }
  596. // CHECK:STDOUT: }
  597. // CHECK:STDOUT:
  598. // CHECK:STDOUT: impl @impl: %C.ref as %Eq.ref {
  599. // CHECK:STDOUT: %Equal.decl: %Equal.type.1 = fn_decl @Equal.1 [template = constants.%Equal.1] {
  600. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  601. // CHECK:STDOUT: %self.param_patt: %C = param_pattern %self.patt, runtime_param0
  602. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  603. // CHECK:STDOUT: %other.param_patt: %C = param_pattern %other.patt, runtime_param1
  604. // CHECK:STDOUT: } {
  605. // CHECK:STDOUT: %C.ref.loc8_18: type = name_ref C, file.%C.decl [template = constants.%C]
  606. // CHECK:STDOUT: %C.ref.loc8_28: type = name_ref C, file.%C.decl [template = constants.%C]
  607. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  608. // CHECK:STDOUT: %.loc8_34.1: type = value_of_initializer %bool.make_type [template = bool]
  609. // CHECK:STDOUT: %.loc8_34.2: type = converted %bool.make_type, %.loc8_34.1 [template = bool]
  610. // CHECK:STDOUT: %return: ref bool = var <return slot>
  611. // CHECK:STDOUT: %param.loc8_12: %C = param runtime_param0
  612. // CHECK:STDOUT: %self: %C = bind_name self, %param.loc8_12
  613. // CHECK:STDOUT: %param.loc8_21: %C = param runtime_param1
  614. // CHECK:STDOUT: %other: %C = bind_name other, %param.loc8_21
  615. // CHECK:STDOUT: }
  616. // CHECK:STDOUT: %NotEqual.decl: %NotEqual.type.1 = fn_decl @NotEqual.1 [template = constants.%NotEqual.1] {
  617. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  618. // CHECK:STDOUT: %self.param_patt: %C = param_pattern %self.patt, runtime_param0
  619. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  620. // CHECK:STDOUT: %other.param_patt: %C = param_pattern %other.patt, runtime_param1
  621. // CHECK:STDOUT: } {
  622. // CHECK:STDOUT: %C.ref.loc9_21: type = name_ref C, file.%C.decl [template = constants.%C]
  623. // CHECK:STDOUT: %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
  624. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  625. // CHECK:STDOUT: %.loc9_37.1: type = value_of_initializer %bool.make_type [template = bool]
  626. // CHECK:STDOUT: %.loc9_37.2: type = converted %bool.make_type, %.loc9_37.1 [template = bool]
  627. // CHECK:STDOUT: %return: ref bool = var <return slot>
  628. // CHECK:STDOUT: %param.loc9_15: %C = param runtime_param0
  629. // CHECK:STDOUT: %self: %C = bind_name self, %param.loc9_15
  630. // CHECK:STDOUT: %param.loc9_24: %C = param runtime_param1
  631. // CHECK:STDOUT: %other: %C = bind_name other, %param.loc9_24
  632. // CHECK:STDOUT: }
  633. // CHECK:STDOUT: %.loc7: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
  634. // CHECK:STDOUT:
  635. // CHECK:STDOUT: !members:
  636. // CHECK:STDOUT: .Equal = %Equal.decl
  637. // CHECK:STDOUT: .NotEqual = %NotEqual.decl
  638. // CHECK:STDOUT: witness = %.loc7
  639. // CHECK:STDOUT: }
  640. // CHECK:STDOUT:
  641. // CHECK:STDOUT: class @C {
  642. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  643. // CHECK:STDOUT:
  644. // CHECK:STDOUT: !members:
  645. // CHECK:STDOUT: .Self = constants.%C
  646. // CHECK:STDOUT: }
  647. // CHECK:STDOUT:
  648. // CHECK:STDOUT: class @D {
  649. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  650. // CHECK:STDOUT:
  651. // CHECK:STDOUT: !members:
  652. // CHECK:STDOUT: .Self = constants.%D
  653. // CHECK:STDOUT: }
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  656. // CHECK:STDOUT:
  657. // CHECK:STDOUT: fn @Equal.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  658. // CHECK:STDOUT:
  659. // CHECK:STDOUT: fn @NotEqual.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: generic fn @Equal.2(constants.%Self.1: %Eq.type) {
  662. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.1)]
  663. // CHECK:STDOUT:
  664. // CHECK:STDOUT: fn[%self.param_patt: @Equal.2.%Self (%Self.1)](%other.param_patt: @Equal.2.%Self (%Self.1)) -> bool;
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT:
  667. // CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self.1: %Eq.type) {
  668. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.1)]
  669. // CHECK:STDOUT:
  670. // CHECK:STDOUT: fn[%self.param_patt: @NotEqual.2.%Self (%Self.1)](%other.param_patt: @NotEqual.2.%Self (%Self.1)) -> bool;
  671. // CHECK:STDOUT: }
  672. // CHECK:STDOUT:
  673. // CHECK:STDOUT: fn @TestRhsBad(%a.param_patt: %C, %b.param_patt: %D) -> bool {
  674. // CHECK:STDOUT: !entry:
  675. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  676. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  677. // CHECK:STDOUT: %Equal.ref: %.6 = name_ref Equal, imports.%import_ref.3 [template = constants.%.7]
  678. // CHECK:STDOUT: %.loc23_12.1: %Equal.type.2 = interface_witness_access constants.%.4, element0 [template = constants.%Equal.1]
  679. // CHECK:STDOUT: %.loc23_12.2: <bound method> = bound_method %a.ref, %.loc23_12.1
  680. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%C) [template = constants.%ImplicitAs.type.3]
  681. // CHECK:STDOUT: %.loc23_15.1: %.10 = specific_constant imports.%import_ref.11, @ImplicitAs(constants.%C) [template = constants.%.11]
  682. // CHECK:STDOUT: %Convert.ref: %.10 = name_ref Convert, %.loc23_15.1 [template = constants.%.11]
  683. // CHECK:STDOUT: %.loc23_15.2: %C = converted %b.ref, <error> [template = <error>]
  684. // CHECK:STDOUT: %Equal.call: init bool = call %.loc23_12.2(<invalid>) [template = <error>]
  685. // CHECK:STDOUT: %.loc23_16.1: bool = value_of_initializer %Equal.call [template = <error>]
  686. // CHECK:STDOUT: %.loc23_16.2: bool = converted %Equal.call, %.loc23_16.1 [template = <error>]
  687. // CHECK:STDOUT: return %.loc23_16.2
  688. // CHECK:STDOUT: }
  689. // CHECK:STDOUT:
  690. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  691. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  692. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  693. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)]
  694. // CHECK:STDOUT:
  695. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest);
  696. // CHECK:STDOUT: }
  697. // CHECK:STDOUT:
  698. // CHECK:STDOUT: fn @TestLhsBad(%a.param_patt: %D, %b.param_patt: %C) -> bool {
  699. // CHECK:STDOUT: !entry:
  700. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  701. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  702. // CHECK:STDOUT: %NotEqual.ref: %.13 = name_ref NotEqual, imports.%import_ref.4 [template = constants.%.14]
  703. // CHECK:STDOUT: return <error>
  704. // CHECK:STDOUT: }
  705. // CHECK:STDOUT:
  706. // CHECK:STDOUT: specific @Equal.2(constants.%Self.1) {
  707. // CHECK:STDOUT: %Self => constants.%Self.1
  708. // CHECK:STDOUT: }
  709. // CHECK:STDOUT:
  710. // CHECK:STDOUT: specific @Equal.2(constants.%C) {
  711. // CHECK:STDOUT: %Self => constants.%C
  712. // CHECK:STDOUT: }
  713. // CHECK:STDOUT:
  714. // CHECK:STDOUT: specific @NotEqual.2(constants.%Self.1) {
  715. // CHECK:STDOUT: %Self => constants.%Self.1
  716. // CHECK:STDOUT: }
  717. // CHECK:STDOUT:
  718. // CHECK:STDOUT: specific @NotEqual.2(constants.%C) {
  719. // CHECK:STDOUT: %Self => constants.%C
  720. // CHECK:STDOUT: }
  721. // CHECK:STDOUT:
  722. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  723. // CHECK:STDOUT: %Dest => constants.%Dest
  724. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  725. // CHECK:STDOUT: }
  726. // CHECK:STDOUT:
  727. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  728. // CHECK:STDOUT: %Dest => constants.%Dest
  729. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  730. // CHECK:STDOUT: }
  731. // CHECK:STDOUT:
  732. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  733. // CHECK:STDOUT: %Dest => constants.%Dest
  734. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  735. // CHECK:STDOUT: }
  736. // CHECK:STDOUT:
  737. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.2) {
  738. // CHECK:STDOUT: %Dest => constants.%Dest
  739. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  740. // CHECK:STDOUT: %Self => constants.%Self.2
  741. // CHECK:STDOUT: }
  742. // CHECK:STDOUT:
  743. // CHECK:STDOUT: specific @ImplicitAs(constants.%C) {
  744. // CHECK:STDOUT: %Dest => constants.%C
  745. // CHECK:STDOUT: %Dest.patt => constants.%C
  746. // CHECK:STDOUT:
  747. // CHECK:STDOUT: !definition:
  748. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  749. // CHECK:STDOUT: %Self => constants.%Self.3
  750. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  751. // CHECK:STDOUT: %Convert => constants.%Convert.2
  752. // CHECK:STDOUT: %.1 => constants.%.10
  753. // CHECK:STDOUT: %.2 => constants.%.11
  754. // CHECK:STDOUT: }
  755. // CHECK:STDOUT: