eq.carbon 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  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 [MissingImplInMemberAccess]
  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 [MissingImplInMemberAccess]
  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` [ImplicitAsConversionFailure]
  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` [MissingImplInMemberAccessNote]
  53. // CHECK:STDERR: return a == b;
  54. // CHECK:STDERR: ^
  55. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE-11]]:21: note: initializing function parameter [InCallToFunctionParam]
  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 [MissingImplInMemberAccess]
  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/...
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%Eq.type]
  106. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
  107. // CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+40, loaded [template = constants.%.7]
  108. // CHECK:STDOUT: %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%.9]
  109. // CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+35, loaded [template = constants.%Equal.2]
  110. // CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+63, loaded [template = constants.%NotEqual.2]
  111. // CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
  112. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
  113. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+63, unloaded
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: file {
  117. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  118. // CHECK:STDOUT: .Core = imports.%Core
  119. // CHECK:STDOUT: .C = %C.decl
  120. // CHECK:STDOUT: .TestEqual = %TestEqual.decl
  121. // CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT: %Core.import = import Core
  124. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  125. // CHECK:STDOUT: impl_decl @impl [template] {} {
  126. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  127. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  128. // CHECK:STDOUT: %Eq.ref: type = name_ref Eq, imports.%import_ref.1 [template = constants.%Eq.type]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [template = constants.%TestEqual] {
  131. // CHECK:STDOUT: %a.patt: %C = binding_pattern a
  132. // CHECK:STDOUT: %a.param_patt: %C = value_param_pattern %a.patt, runtime_param0
  133. // CHECK:STDOUT: %b.patt: %C = binding_pattern b
  134. // CHECK:STDOUT: %b.param_patt: %C = value_param_pattern %b.patt, runtime_param1
  135. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  136. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  137. // CHECK:STDOUT: } {
  138. // CHECK:STDOUT: %C.ref.loc11_17: type = name_ref C, file.%C.decl [template = constants.%C]
  139. // CHECK:STDOUT: %C.ref.loc11_23: type = name_ref C, file.%C.decl [template = constants.%C]
  140. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  141. // CHECK:STDOUT: %.loc11_29.1: type = value_of_initializer %bool.make_type [template = bool]
  142. // CHECK:STDOUT: %.loc11_29.2: type = converted %bool.make_type, %.loc11_29.1 [template = bool]
  143. // CHECK:STDOUT: %a.param: %C = value_param runtime_param0
  144. // CHECK:STDOUT: %a: %C = bind_name a, %a.param
  145. // CHECK:STDOUT: %b.param: %C = value_param runtime_param1
  146. // CHECK:STDOUT: %b: %C = bind_name b, %b.param
  147. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  148. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [template = constants.%TestNotEqual] {
  151. // CHECK:STDOUT: %a.patt: %C = binding_pattern a
  152. // CHECK:STDOUT: %a.param_patt: %C = value_param_pattern %a.patt, runtime_param0
  153. // CHECK:STDOUT: %b.patt: %C = binding_pattern b
  154. // CHECK:STDOUT: %b.param_patt: %C = value_param_pattern %b.patt, runtime_param1
  155. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  156. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  157. // CHECK:STDOUT: } {
  158. // CHECK:STDOUT: %C.ref.loc15_20: type = name_ref C, file.%C.decl [template = constants.%C]
  159. // CHECK:STDOUT: %C.ref.loc15_26: type = name_ref C, file.%C.decl [template = constants.%C]
  160. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  161. // CHECK:STDOUT: %.loc15_32.1: type = value_of_initializer %bool.make_type [template = bool]
  162. // CHECK:STDOUT: %.loc15_32.2: type = converted %bool.make_type, %.loc15_32.1 [template = bool]
  163. // CHECK:STDOUT: %a.param: %C = value_param runtime_param0
  164. // CHECK:STDOUT: %a: %C = bind_name a, %a.param
  165. // CHECK:STDOUT: %b.param: %C = value_param runtime_param1
  166. // CHECK:STDOUT: %b: %C = bind_name b, %b.param
  167. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  168. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  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 = value_param_pattern %self.patt, runtime_param0
  184. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  185. // CHECK:STDOUT: %other.param_patt: %C = value_param_pattern %other.patt, runtime_param1
  186. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  187. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  188. // CHECK:STDOUT: } {
  189. // CHECK:STDOUT: %C.ref.loc7_18: type = name_ref C, file.%C.decl [template = constants.%C]
  190. // CHECK:STDOUT: %C.ref.loc7_28: type = name_ref C, file.%C.decl [template = constants.%C]
  191. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  192. // CHECK:STDOUT: %.loc7_34.1: type = value_of_initializer %bool.make_type [template = bool]
  193. // CHECK:STDOUT: %.loc7_34.2: type = converted %bool.make_type, %.loc7_34.1 [template = bool]
  194. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  195. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  196. // CHECK:STDOUT: %other.param: %C = value_param runtime_param1
  197. // CHECK:STDOUT: %other: %C = bind_name other, %other.param
  198. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  199. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT: %NotEqual.decl: %NotEqual.type.1 = fn_decl @NotEqual.1 [template = constants.%NotEqual.1] {
  202. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  203. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  204. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  205. // CHECK:STDOUT: %other.param_patt: %C = value_param_pattern %other.patt, runtime_param1
  206. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  207. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  208. // CHECK:STDOUT: } {
  209. // CHECK:STDOUT: %C.ref.loc8_21: type = name_ref C, file.%C.decl [template = constants.%C]
  210. // CHECK:STDOUT: %C.ref.loc8_31: type = name_ref C, file.%C.decl [template = constants.%C]
  211. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  212. // CHECK:STDOUT: %.loc8_37.1: type = value_of_initializer %bool.make_type [template = bool]
  213. // CHECK:STDOUT: %.loc8_37.2: type = converted %bool.make_type, %.loc8_37.1 [template = bool]
  214. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  215. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  216. // CHECK:STDOUT: %other.param: %C = value_param runtime_param1
  217. // CHECK:STDOUT: %other: %C = bind_name other, %other.param
  218. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  219. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT: %.loc6: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: !members:
  224. // CHECK:STDOUT: .Equal = %Equal.decl
  225. // CHECK:STDOUT: .NotEqual = %NotEqual.decl
  226. // CHECK:STDOUT: witness = %.loc6
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: class @C {
  230. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: !members:
  233. // CHECK:STDOUT: .Self = constants.%C
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: fn @Equal.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: fn @NotEqual.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: generic fn @Equal.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: @Equal.2.%Self (%Self)](%other.param_patt: @Equal.2.%Self (%Self)) -> bool;
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self: %Eq.type) {
  249. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: fn[%self.param_patt: @NotEqual.2.%Self (%Self)](%other.param_patt: @NotEqual.2.%Self (%Self)) -> bool;
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: fn @TestEqual(%a.param_patt: %C, %b.param_patt: %C) -> bool {
  255. // CHECK:STDOUT: !entry:
  256. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  257. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  258. // CHECK:STDOUT: %Equal.ref: %.6 = name_ref Equal, imports.%import_ref.3 [template = constants.%.7]
  259. // CHECK:STDOUT: %.loc12_12.1: %Equal.type.2 = interface_witness_access constants.%.4, element0 [template = constants.%Equal.1]
  260. // CHECK:STDOUT: %.loc12_12.2: <bound method> = bound_method %a.ref, %.loc12_12.1
  261. // CHECK:STDOUT: %Equal.call: init bool = call %.loc12_12.2(%a.ref, %b.ref)
  262. // CHECK:STDOUT: %.loc12_16.1: bool = value_of_initializer %Equal.call
  263. // CHECK:STDOUT: %.loc12_16.2: bool = converted %Equal.call, %.loc12_16.1
  264. // CHECK:STDOUT: return %.loc12_16.2
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: fn @TestNotEqual(%a.param_patt: %C, %b.param_patt: %C) -> bool {
  268. // CHECK:STDOUT: !entry:
  269. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  270. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  271. // CHECK:STDOUT: %NotEqual.ref: %.8 = name_ref NotEqual, imports.%import_ref.4 [template = constants.%.9]
  272. // CHECK:STDOUT: %.loc16_12.1: %NotEqual.type.2 = interface_witness_access constants.%.4, element1 [template = constants.%NotEqual.1]
  273. // CHECK:STDOUT: %.loc16_12.2: <bound method> = bound_method %a.ref, %.loc16_12.1
  274. // CHECK:STDOUT: %NotEqual.call: init bool = call %.loc16_12.2(%a.ref, %b.ref)
  275. // CHECK:STDOUT: %.loc16_16.1: bool = value_of_initializer %NotEqual.call
  276. // CHECK:STDOUT: %.loc16_16.2: bool = converted %NotEqual.call, %.loc16_16.1
  277. // CHECK:STDOUT: return %.loc16_16.2
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: specific @Equal.2(constants.%Self) {
  281. // CHECK:STDOUT: %Self => constants.%Self
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: specific @Equal.2(constants.%C) {
  285. // CHECK:STDOUT: %Self => constants.%C
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: specific @NotEqual.2(constants.%Self) {
  289. // CHECK:STDOUT: %Self => constants.%Self
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: specific @NotEqual.2(constants.%C) {
  293. // CHECK:STDOUT: %Self => constants.%C
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: --- fail_no_impl.carbon
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: constants {
  299. // CHECK:STDOUT: %D: type = class_type @D [template]
  300. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  301. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  302. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  303. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  304. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  305. // CHECK:STDOUT: %TestEqual.type: type = fn_type @TestEqual [template]
  306. // CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [template]
  307. // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
  308. // CHECK:STDOUT: %Eq.type: type = interface_type @Eq [template]
  309. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic]
  310. // CHECK:STDOUT: %Equal.type: type = fn_type @Equal [template]
  311. // CHECK:STDOUT: %Equal: %Equal.type = struct_value () [template]
  312. // CHECK:STDOUT: %.5: type = assoc_entity_type %Eq.type, %Equal.type [template]
  313. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.8 [template]
  314. // CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [template]
  315. // CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [template]
  316. // CHECK:STDOUT: %NotEqual.type: type = fn_type @NotEqual [template]
  317. // CHECK:STDOUT: %NotEqual: %NotEqual.type = struct_value () [template]
  318. // CHECK:STDOUT: %.7: type = assoc_entity_type %Eq.type, %NotEqual.type [template]
  319. // CHECK:STDOUT: %.8: %.7 = assoc_entity element1, imports.%import_ref.9 [template]
  320. // CHECK:STDOUT: }
  321. // CHECK:STDOUT:
  322. // CHECK:STDOUT: imports {
  323. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  324. // CHECK:STDOUT: .Bool = %import_ref.1
  325. // CHECK:STDOUT: .Eq = %import_ref.2
  326. // CHECK:STDOUT: import Core//prelude
  327. // CHECK:STDOUT: import Core//prelude/...
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+5, 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+40, loaded [template = constants.%.6]
  333. // CHECK:STDOUT: %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%.8]
  334. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
  335. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/comparison, inst+63, unloaded
  336. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
  337. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+63, 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 = value_param_pattern %a.patt, runtime_param0
  352. // CHECK:STDOUT: %b.patt: %D = binding_pattern b
  353. // CHECK:STDOUT: %b.param_patt: %D = value_param_pattern %b.patt, runtime_param1
  354. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  355. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  356. // CHECK:STDOUT: } {
  357. // CHECK:STDOUT: %D.ref.loc6_17: type = name_ref D, file.%D.decl [template = constants.%D]
  358. // CHECK:STDOUT: %D.ref.loc6_23: type = name_ref D, file.%D.decl [template = constants.%D]
  359. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  360. // CHECK:STDOUT: %.loc6_29.1: type = value_of_initializer %bool.make_type [template = bool]
  361. // CHECK:STDOUT: %.loc6_29.2: type = converted %bool.make_type, %.loc6_29.1 [template = bool]
  362. // CHECK:STDOUT: %a.param: %D = value_param runtime_param0
  363. // CHECK:STDOUT: %a: %D = bind_name a, %a.param
  364. // CHECK:STDOUT: %b.param: %D = value_param runtime_param1
  365. // CHECK:STDOUT: %b: %D = bind_name b, %b.param
  366. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  367. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [template = constants.%TestNotEqual] {
  370. // CHECK:STDOUT: %a.patt: %D = binding_pattern a
  371. // CHECK:STDOUT: %a.param_patt: %D = value_param_pattern %a.patt, runtime_param0
  372. // CHECK:STDOUT: %b.patt: %D = binding_pattern b
  373. // CHECK:STDOUT: %b.param_patt: %D = value_param_pattern %b.patt, runtime_param1
  374. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  375. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  376. // CHECK:STDOUT: } {
  377. // CHECK:STDOUT: %D.ref.loc14_20: type = name_ref D, file.%D.decl [template = constants.%D]
  378. // CHECK:STDOUT: %D.ref.loc14_26: type = name_ref D, file.%D.decl [template = constants.%D]
  379. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  380. // CHECK:STDOUT: %.loc14_32.1: type = value_of_initializer %bool.make_type [template = bool]
  381. // CHECK:STDOUT: %.loc14_32.2: type = converted %bool.make_type, %.loc14_32.1 [template = bool]
  382. // CHECK:STDOUT: %a.param: %D = value_param runtime_param0
  383. // CHECK:STDOUT: %a: %D = bind_name a, %a.param
  384. // CHECK:STDOUT: %b.param: %D = value_param runtime_param1
  385. // CHECK:STDOUT: %b: %D = bind_name b, %b.param
  386. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  387. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: interface @Eq {
  392. // CHECK:STDOUT: !members:
  393. // CHECK:STDOUT: .Self = imports.%import_ref.3
  394. // CHECK:STDOUT: .Equal = imports.%import_ref.4
  395. // CHECK:STDOUT: .NotEqual = imports.%import_ref.5
  396. // CHECK:STDOUT: witness = (imports.%import_ref.6, imports.%import_ref.7)
  397. // CHECK:STDOUT: }
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: class @D {
  400. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: !members:
  403. // CHECK:STDOUT: .Self = constants.%D
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: fn @TestEqual(%a.param_patt: %D, %b.param_patt: %D) -> bool {
  409. // CHECK:STDOUT: !entry:
  410. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  411. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  412. // CHECK:STDOUT: %Equal.ref: %.5 = name_ref Equal, imports.%import_ref.4 [template = constants.%.6]
  413. // CHECK:STDOUT: return <error>
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: generic fn @Equal(constants.%Self: %Eq.type) {
  417. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: fn[%self.param_patt: @Equal.%Self (%Self)](%other.param_patt: @Equal.%Self (%Self)) -> bool;
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: fn @TestNotEqual(%a.param_patt: %D, %b.param_patt: %D) -> bool {
  423. // CHECK:STDOUT: !entry:
  424. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  425. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  426. // CHECK:STDOUT: %NotEqual.ref: %.7 = name_ref NotEqual, imports.%import_ref.5 [template = constants.%.8]
  427. // CHECK:STDOUT: return <error>
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: generic fn @NotEqual(constants.%Self: %Eq.type) {
  431. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: fn[%self.param_patt: @NotEqual.%Self (%Self)](%other.param_patt: @NotEqual.%Self (%Self)) -> bool;
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: specific @Equal(constants.%Self) {
  437. // CHECK:STDOUT: %Self => constants.%Self
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: specific @NotEqual(constants.%Self) {
  441. // CHECK:STDOUT: %Self => constants.%Self
  442. // CHECK:STDOUT: }
  443. // CHECK:STDOUT:
  444. // CHECK:STDOUT: --- fail_no_impl_for_args.carbon
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: constants {
  447. // CHECK:STDOUT: %C: type = class_type @C [template]
  448. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  449. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  450. // CHECK:STDOUT: %D: type = class_type @D [template]
  451. // CHECK:STDOUT: %Eq.type: type = interface_type @Eq [template]
  452. // CHECK:STDOUT: %Self.1: %Eq.type = bind_symbolic_name Self, 0 [symbolic]
  453. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  454. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  455. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  456. // CHECK:STDOUT: %Equal.type.1: type = fn_type @Equal.1 [template]
  457. // CHECK:STDOUT: %Equal.1: %Equal.type.1 = struct_value () [template]
  458. // CHECK:STDOUT: %NotEqual.type.1: type = fn_type @NotEqual.1 [template]
  459. // CHECK:STDOUT: %NotEqual.1: %NotEqual.type.1 = struct_value () [template]
  460. // CHECK:STDOUT: %Equal.type.2: type = fn_type @Equal.2 [template]
  461. // CHECK:STDOUT: %Equal.2: %Equal.type.2 = struct_value () [template]
  462. // CHECK:STDOUT: %NotEqual.type.2: type = fn_type @NotEqual.2 [template]
  463. // CHECK:STDOUT: %NotEqual.2: %NotEqual.type.2 = struct_value () [template]
  464. // CHECK:STDOUT: %.4: <witness> = interface_witness (%Equal.1, %NotEqual.1) [template]
  465. // CHECK:STDOUT: %TestRhsBad.type: type = fn_type @TestRhsBad [template]
  466. // CHECK:STDOUT: %TestRhsBad: %TestRhsBad.type = struct_value () [template]
  467. // CHECK:STDOUT: %.5: type = ptr_type %.1 [template]
  468. // CHECK:STDOUT: %.6: type = assoc_entity_type %Eq.type, %Equal.type.2 [template]
  469. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template]
  470. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  471. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  472. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  473. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  474. // CHECK:STDOUT: %Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  475. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  476. // CHECK:STDOUT: %Self.3: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  477. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  478. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  479. // CHECK:STDOUT: %.8: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  480. // CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.13 [symbolic]
  481. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%C) [template]
  482. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%C) [template]
  483. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  484. // CHECK:STDOUT: %.10: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  485. // CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.13 [template]
  486. // CHECK:STDOUT: %.12: %.8 = assoc_entity element0, imports.%import_ref.14 [symbolic]
  487. // CHECK:STDOUT: %TestLhsBad.type: type = fn_type @TestLhsBad [template]
  488. // CHECK:STDOUT: %TestLhsBad: %TestLhsBad.type = struct_value () [template]
  489. // CHECK:STDOUT: %.13: type = assoc_entity_type %Eq.type, %NotEqual.type.2 [template]
  490. // CHECK:STDOUT: %.14: %.13 = assoc_entity element1, imports.%import_ref.15 [template]
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT:
  493. // CHECK:STDOUT: imports {
  494. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  495. // CHECK:STDOUT: .Eq = %import_ref.1
  496. // CHECK:STDOUT: .Bool = %import_ref.7
  497. // CHECK:STDOUT: .ImplicitAs = %import_ref.9
  498. // CHECK:STDOUT: import Core//prelude
  499. // CHECK:STDOUT: import Core//prelude/...
  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+40, loaded [template = constants.%.7]
  504. // CHECK:STDOUT: %import_ref.4: %.13 = import_ref Core//prelude/operators/comparison, inst+68, loaded [template = constants.%.14]
  505. // CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+35, loaded [template = constants.%Equal.2]
  506. // CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+63, loaded [template = constants.%NotEqual.2]
  507. // CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+5, loaded [template = constants.%Bool]
  508. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+35, unloaded
  509. // CHECK:STDOUT: %import_ref.9: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
  510. // CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/as, inst+55, unloaded
  511. // CHECK:STDOUT: %import_ref.11: @ImplicitAs.%.1 (%.8) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.12)]
  512. // CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/as, inst+70, unloaded
  513. // CHECK:STDOUT: %import_ref.13 = import_ref Core//prelude/operators/as, inst+70, unloaded
  514. // CHECK:STDOUT: %import_ref.14 = import_ref Core//prelude/operators/as, inst+70, unloaded
  515. // CHECK:STDOUT: %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+63, 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 = value_param_pattern %a.patt, runtime_param0
  537. // CHECK:STDOUT: %b.patt: %D = binding_pattern b
  538. // CHECK:STDOUT: %b.param_patt: %D = value_param_pattern %b.patt, runtime_param1
  539. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  540. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  541. // CHECK:STDOUT: } {
  542. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  543. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  544. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  545. // CHECK:STDOUT: %.loc12_30.1: type = value_of_initializer %bool.make_type [template = bool]
  546. // CHECK:STDOUT: %.loc12_30.2: type = converted %bool.make_type, %.loc12_30.1 [template = bool]
  547. // CHECK:STDOUT: %a.param: %C = value_param runtime_param0
  548. // CHECK:STDOUT: %a: %C = bind_name a, %a.param
  549. // CHECK:STDOUT: %b.param: %D = value_param runtime_param1
  550. // CHECK:STDOUT: %b: %D = bind_name b, %b.param
  551. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  552. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  553. // CHECK:STDOUT: }
  554. // CHECK:STDOUT: %TestLhsBad.decl: %TestLhsBad.type = fn_decl @TestLhsBad [template = constants.%TestLhsBad] {
  555. // CHECK:STDOUT: %a.patt: %D = binding_pattern a
  556. // CHECK:STDOUT: %a.param_patt: %D = value_param_pattern %a.patt, runtime_param0
  557. // CHECK:STDOUT: %b.patt: %C = binding_pattern b
  558. // CHECK:STDOUT: %b.param_patt: %C = value_param_pattern %b.patt, runtime_param1
  559. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  560. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  561. // CHECK:STDOUT: } {
  562. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  563. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  564. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  565. // CHECK:STDOUT: %.loc26_30.1: type = value_of_initializer %bool.make_type [template = bool]
  566. // CHECK:STDOUT: %.loc26_30.2: type = converted %bool.make_type, %.loc26_30.1 [template = bool]
  567. // CHECK:STDOUT: %a.param: %D = value_param runtime_param0
  568. // CHECK:STDOUT: %a: %D = bind_name a, %a.param
  569. // CHECK:STDOUT: %b.param: %C = value_param runtime_param1
  570. // CHECK:STDOUT: %b: %C = bind_name b, %b.param
  571. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  572. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  573. // CHECK:STDOUT: }
  574. // CHECK:STDOUT: }
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: interface @Eq {
  577. // CHECK:STDOUT: !members:
  578. // CHECK:STDOUT: .Self = imports.%import_ref.2
  579. // CHECK:STDOUT: .Equal = imports.%import_ref.3
  580. // CHECK:STDOUT: .NotEqual = imports.%import_ref.4
  581. // CHECK:STDOUT: witness = (imports.%import_ref.5, imports.%import_ref.6)
  582. // CHECK:STDOUT: }
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  585. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  586. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  587. // CHECK:STDOUT:
  588. // CHECK:STDOUT: !definition:
  589. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  590. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)]
  591. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  592. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  593. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.8)]
  594. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.8) = assoc_entity element0, imports.%import_ref.13 [symbolic = %.2 (constants.%.9)]
  595. // CHECK:STDOUT:
  596. // CHECK:STDOUT: interface {
  597. // CHECK:STDOUT: !members:
  598. // CHECK:STDOUT: .Self = imports.%import_ref.10
  599. // CHECK:STDOUT: .Convert = imports.%import_ref.11
  600. // CHECK:STDOUT: witness = (imports.%import_ref.12)
  601. // CHECK:STDOUT: }
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT:
  604. // CHECK:STDOUT: impl @impl: %C.ref as %Eq.ref {
  605. // CHECK:STDOUT: %Equal.decl: %Equal.type.1 = fn_decl @Equal.1 [template = constants.%Equal.1] {
  606. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  607. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  608. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  609. // CHECK:STDOUT: %other.param_patt: %C = value_param_pattern %other.patt, runtime_param1
  610. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  611. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  612. // CHECK:STDOUT: } {
  613. // CHECK:STDOUT: %C.ref.loc8_18: type = name_ref C, file.%C.decl [template = constants.%C]
  614. // CHECK:STDOUT: %C.ref.loc8_28: type = name_ref C, file.%C.decl [template = constants.%C]
  615. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  616. // CHECK:STDOUT: %.loc8_34.1: type = value_of_initializer %bool.make_type [template = bool]
  617. // CHECK:STDOUT: %.loc8_34.2: type = converted %bool.make_type, %.loc8_34.1 [template = bool]
  618. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  619. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  620. // CHECK:STDOUT: %other.param: %C = value_param runtime_param1
  621. // CHECK:STDOUT: %other: %C = bind_name other, %other.param
  622. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  623. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  624. // CHECK:STDOUT: }
  625. // CHECK:STDOUT: %NotEqual.decl: %NotEqual.type.1 = fn_decl @NotEqual.1 [template = constants.%NotEqual.1] {
  626. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  627. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  628. // CHECK:STDOUT: %other.patt: %C = binding_pattern other
  629. // CHECK:STDOUT: %other.param_patt: %C = value_param_pattern %other.patt, runtime_param1
  630. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  631. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  632. // CHECK:STDOUT: } {
  633. // CHECK:STDOUT: %C.ref.loc9_21: type = name_ref C, file.%C.decl [template = constants.%C]
  634. // CHECK:STDOUT: %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
  635. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  636. // CHECK:STDOUT: %.loc9_37.1: type = value_of_initializer %bool.make_type [template = bool]
  637. // CHECK:STDOUT: %.loc9_37.2: type = converted %bool.make_type, %.loc9_37.1 [template = bool]
  638. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  639. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  640. // CHECK:STDOUT: %other.param: %C = value_param runtime_param1
  641. // CHECK:STDOUT: %other: %C = bind_name other, %other.param
  642. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  643. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  644. // CHECK:STDOUT: }
  645. // CHECK:STDOUT: %.loc7: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: !members:
  648. // CHECK:STDOUT: .Equal = %Equal.decl
  649. // CHECK:STDOUT: .NotEqual = %NotEqual.decl
  650. // CHECK:STDOUT: witness = %.loc7
  651. // CHECK:STDOUT: }
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: class @C {
  654. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  655. // CHECK:STDOUT:
  656. // CHECK:STDOUT: !members:
  657. // CHECK:STDOUT: .Self = constants.%C
  658. // CHECK:STDOUT: }
  659. // CHECK:STDOUT:
  660. // CHECK:STDOUT: class @D {
  661. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  662. // CHECK:STDOUT:
  663. // CHECK:STDOUT: !members:
  664. // CHECK:STDOUT: .Self = constants.%D
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT:
  667. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  668. // CHECK:STDOUT:
  669. // CHECK:STDOUT: fn @Equal.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  670. // CHECK:STDOUT:
  671. // CHECK:STDOUT: fn @NotEqual.1[%self.param_patt: %C](%other.param_patt: %C) -> bool;
  672. // CHECK:STDOUT:
  673. // CHECK:STDOUT: generic fn @Equal.2(constants.%Self.1: %Eq.type) {
  674. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.1)]
  675. // CHECK:STDOUT:
  676. // CHECK:STDOUT: fn[%self.param_patt: @Equal.2.%Self (%Self.1)](%other.param_patt: @Equal.2.%Self (%Self.1)) -> bool;
  677. // CHECK:STDOUT: }
  678. // CHECK:STDOUT:
  679. // CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self.1: %Eq.type) {
  680. // CHECK:STDOUT: %Self: %Eq.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self.1)]
  681. // CHECK:STDOUT:
  682. // CHECK:STDOUT: fn[%self.param_patt: @NotEqual.2.%Self (%Self.1)](%other.param_patt: @NotEqual.2.%Self (%Self.1)) -> bool;
  683. // CHECK:STDOUT: }
  684. // CHECK:STDOUT:
  685. // CHECK:STDOUT: fn @TestRhsBad(%a.param_patt: %C, %b.param_patt: %D) -> bool {
  686. // CHECK:STDOUT: !entry:
  687. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  688. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  689. // CHECK:STDOUT: %Equal.ref: %.6 = name_ref Equal, imports.%import_ref.3 [template = constants.%.7]
  690. // CHECK:STDOUT: %.loc23_12.1: %Equal.type.2 = interface_witness_access constants.%.4, element0 [template = constants.%Equal.1]
  691. // CHECK:STDOUT: %.loc23_12.2: <bound method> = bound_method %a.ref, %.loc23_12.1
  692. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%C) [template = constants.%ImplicitAs.type.3]
  693. // CHECK:STDOUT: %.loc23_15.1: %.10 = specific_constant imports.%import_ref.11, @ImplicitAs(constants.%C) [template = constants.%.11]
  694. // CHECK:STDOUT: %Convert.ref: %.10 = name_ref Convert, %.loc23_15.1 [template = constants.%.11]
  695. // CHECK:STDOUT: %.loc23_15.2: %C = converted %b.ref, <error> [template = <error>]
  696. // CHECK:STDOUT: %Equal.call: init bool = call %.loc23_12.2(%a.ref, <error>)
  697. // CHECK:STDOUT: %.loc23_16.1: bool = value_of_initializer %Equal.call
  698. // CHECK:STDOUT: %.loc23_16.2: bool = converted %Equal.call, %.loc23_16.1
  699. // CHECK:STDOUT: return %.loc23_16.2
  700. // CHECK:STDOUT: }
  701. // CHECK:STDOUT:
  702. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  703. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  704. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  705. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)]
  706. // CHECK:STDOUT:
  707. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest);
  708. // CHECK:STDOUT: }
  709. // CHECK:STDOUT:
  710. // CHECK:STDOUT: fn @TestLhsBad(%a.param_patt: %D, %b.param_patt: %C) -> bool {
  711. // CHECK:STDOUT: !entry:
  712. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  713. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  714. // CHECK:STDOUT: %NotEqual.ref: %.13 = name_ref NotEqual, imports.%import_ref.4 [template = constants.%.14]
  715. // CHECK:STDOUT: return <error>
  716. // CHECK:STDOUT: }
  717. // CHECK:STDOUT:
  718. // CHECK:STDOUT: specific @Equal.2(constants.%Self.1) {
  719. // CHECK:STDOUT: %Self => constants.%Self.1
  720. // CHECK:STDOUT: }
  721. // CHECK:STDOUT:
  722. // CHECK:STDOUT: specific @Equal.2(constants.%C) {
  723. // CHECK:STDOUT: %Self => constants.%C
  724. // CHECK:STDOUT: }
  725. // CHECK:STDOUT:
  726. // CHECK:STDOUT: specific @NotEqual.2(constants.%Self.1) {
  727. // CHECK:STDOUT: %Self => constants.%Self.1
  728. // CHECK:STDOUT: }
  729. // CHECK:STDOUT:
  730. // CHECK:STDOUT: specific @NotEqual.2(constants.%C) {
  731. // CHECK:STDOUT: %Self => constants.%C
  732. // CHECK:STDOUT: }
  733. // CHECK:STDOUT:
  734. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  735. // CHECK:STDOUT: %Dest => constants.%Dest
  736. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  737. // CHECK:STDOUT: }
  738. // CHECK:STDOUT:
  739. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  740. // CHECK:STDOUT: %Dest => constants.%Dest
  741. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  742. // CHECK:STDOUT: }
  743. // CHECK:STDOUT:
  744. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  745. // CHECK:STDOUT: %Dest => constants.%Dest
  746. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  747. // CHECK:STDOUT: }
  748. // CHECK:STDOUT:
  749. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.2) {
  750. // CHECK:STDOUT: %Dest => constants.%Dest
  751. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  752. // CHECK:STDOUT: %Self => constants.%Self.2
  753. // CHECK:STDOUT: }
  754. // CHECK:STDOUT:
  755. // CHECK:STDOUT: specific @ImplicitAs(constants.%C) {
  756. // CHECK:STDOUT: %Dest => constants.%C
  757. // CHECK:STDOUT: %Dest.patt => constants.%C
  758. // CHECK:STDOUT:
  759. // CHECK:STDOUT: !definition:
  760. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  761. // CHECK:STDOUT: %Self => constants.%Self.3
  762. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  763. // CHECK:STDOUT: %Convert => constants.%Convert.2
  764. // CHECK:STDOUT: %.1 => constants.%.10
  765. // CHECK:STDOUT: %.2 => constants.%.11
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT: