and.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/bool.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/builtin/and.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/and.carbon
  14. fn F() -> bool { return true; }
  15. fn G() -> bool { return true; }
  16. fn And() -> bool {
  17. return F() and G();
  18. }
  19. fn Constant() {
  20. var a: if true and true then bool else () = true;
  21. var b: if true and false then bool else () = ();
  22. var c: if false and true then bool else () = ();
  23. var d: if false and false then bool else () = ();
  24. }
  25. fn PartialConstant(x: bool) {
  26. var a: if false and x then bool else () = ();
  27. }
  28. // CHECK:STDOUT: --- and.carbon
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: constants {
  31. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [concrete]
  32. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [concrete]
  33. // CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete]
  34. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  35. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  36. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  37. // CHECK:STDOUT: %true: bool = bool_literal true [concrete]
  38. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  39. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  40. // CHECK:STDOUT: %Copy.impl_witness.a56: <witness> = impl_witness imports.%Copy.impl_witness_table.189 [concrete]
  41. // CHECK:STDOUT: %Copy.facet.253: %Copy.type = facet_value bool, (%Copy.impl_witness.a56) [concrete]
  42. // CHECK:STDOUT: %.05c: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet.253 [concrete]
  43. // CHECK:STDOUT: %bool.as.Copy.impl.Op.type: type = fn_type @bool.as.Copy.impl.Op [concrete]
  44. // CHECK:STDOUT: %bool.as.Copy.impl.Op: %bool.as.Copy.impl.Op.type = struct_value () [concrete]
  45. // CHECK:STDOUT: %bool.as.Copy.impl.Op.bound: <bound method> = bound_method %true, %bool.as.Copy.impl.Op [concrete]
  46. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  47. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  48. // CHECK:STDOUT: %And.type: type = fn_type @And [concrete]
  49. // CHECK:STDOUT: %And: %And.type = struct_value () [concrete]
  50. // CHECK:STDOUT: %false: bool = bool_literal false [concrete]
  51. // CHECK:STDOUT: %Constant.type: type = fn_type @Constant [concrete]
  52. // CHECK:STDOUT: %Constant: %Constant.type = struct_value () [concrete]
  53. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  54. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  55. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  56. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanAggregateDestroy>> [concrete]
  57. // CHECK:STDOUT: %facet_value: %type_where = facet_value %empty_tuple.type, () [concrete]
  58. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.type.4e0: type = fn_type @AggregateT.as_type.as.Destroy.impl.Op, @AggregateT.as_type.as.Destroy.impl(%facet_value) [concrete]
  59. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.c00: %AggregateT.as_type.as.Destroy.impl.Op.type.4e0 = struct_value () [concrete]
  60. // CHECK:STDOUT: %ptr.843: type = ptr_type %empty_tuple.type [concrete]
  61. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %AggregateT.as_type.as.Destroy.impl.Op.c00, @AggregateT.as_type.as.Destroy.impl.Op(%facet_value) [concrete]
  62. // CHECK:STDOUT: %bool.as.Destroy.impl.Op.type: type = fn_type @bool.as.Destroy.impl.Op [concrete]
  63. // CHECK:STDOUT: %bool.as.Destroy.impl.Op: %bool.as.Destroy.impl.Op.type = struct_value () [concrete]
  64. // CHECK:STDOUT: %ptr.bb2: type = ptr_type bool [concrete]
  65. // CHECK:STDOUT: %PartialConstant.type: type = fn_type @PartialConstant [concrete]
  66. // CHECK:STDOUT: %PartialConstant: %PartialConstant.type = struct_value () [concrete]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: imports {
  70. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  71. // CHECK:STDOUT: .Bool = %Core.Bool
  72. // CHECK:STDOUT: .Copy = %Core.Copy
  73. // CHECK:STDOUT: .Destroy = %Core.Destroy
  74. // CHECK:STDOUT: import Core//prelude
  75. // CHECK:STDOUT: import Core//prelude/...
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %Core.Bool: %Bool.type = import_ref Core//prelude/parts/bool, Bool, loaded [concrete = constants.%Bool]
  78. // CHECK:STDOUT: %Core.Copy: type = import_ref Core//prelude/parts/copy, Copy, loaded [concrete = constants.%Copy.type]
  79. // CHECK:STDOUT: %Core.import_ref.cc5: %bool.as.Copy.impl.Op.type = import_ref Core//prelude/parts/copy, loc20_31, loaded [concrete = constants.%bool.as.Copy.impl.Op]
  80. // CHECK:STDOUT: %Copy.impl_witness_table.189 = impl_witness_table (%Core.import_ref.cc5), @bool.as.Copy.impl [concrete]
  81. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: file {
  85. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  86. // CHECK:STDOUT: .Core = imports.%Core
  87. // CHECK:STDOUT: .F = %F.decl
  88. // CHECK:STDOUT: .G = %G.decl
  89. // CHECK:STDOUT: .And = %And.decl
  90. // CHECK:STDOUT: .Constant = %Constant.decl
  91. // CHECK:STDOUT: .PartialConstant = %PartialConstant.decl
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %Core.import = import Core
  94. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  95. // CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern [concrete]
  96. // CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern %return.patt, call_param0 [concrete]
  97. // CHECK:STDOUT: } {
  98. // CHECK:STDOUT: %Bool.call: init type = call constants.%Bool() [concrete = bool]
  99. // CHECK:STDOUT: %.loc15_11.1: type = value_of_initializer %Bool.call [concrete = bool]
  100. // CHECK:STDOUT: %.loc15_11.2: type = converted %Bool.call, %.loc15_11.1 [concrete = bool]
  101. // CHECK:STDOUT: %return.param: ref bool = out_param call_param0
  102. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  105. // CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern [concrete]
  106. // CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern %return.patt, call_param0 [concrete]
  107. // CHECK:STDOUT: } {
  108. // CHECK:STDOUT: %Bool.call: init type = call constants.%Bool() [concrete = bool]
  109. // CHECK:STDOUT: %.loc16_11.1: type = value_of_initializer %Bool.call [concrete = bool]
  110. // CHECK:STDOUT: %.loc16_11.2: type = converted %Bool.call, %.loc16_11.1 [concrete = bool]
  111. // CHECK:STDOUT: %return.param: ref bool = out_param call_param0
  112. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %And.decl: %And.type = fn_decl @And [concrete = constants.%And] {
  115. // CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern [concrete]
  116. // CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern %return.patt, call_param0 [concrete]
  117. // CHECK:STDOUT: } {
  118. // CHECK:STDOUT: %Bool.call: init type = call constants.%Bool() [concrete = bool]
  119. // CHECK:STDOUT: %.loc18_13.1: type = value_of_initializer %Bool.call [concrete = bool]
  120. // CHECK:STDOUT: %.loc18_13.2: type = converted %Bool.call, %.loc18_13.1 [concrete = bool]
  121. // CHECK:STDOUT: %return.param: ref bool = out_param call_param0
  122. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %Constant.decl: %Constant.type = fn_decl @Constant [concrete = constants.%Constant] {} {}
  125. // CHECK:STDOUT: %PartialConstant.decl: %PartialConstant.type = fn_decl @PartialConstant [concrete = constants.%PartialConstant] {
  126. // CHECK:STDOUT: %x.patt: %pattern_type.831 = binding_pattern x [concrete]
  127. // CHECK:STDOUT: %x.param_patt: %pattern_type.831 = value_param_pattern %x.patt, call_param0 [concrete]
  128. // CHECK:STDOUT: } {
  129. // CHECK:STDOUT: %x.param: bool = value_param call_param0
  130. // CHECK:STDOUT: %.loc29_23.1: type = splice_block %.loc29_23.3 [concrete = bool] {
  131. // CHECK:STDOUT: %Bool.call.loc29: init type = call constants.%Bool() [concrete = bool]
  132. // CHECK:STDOUT: %.loc29_23.2: type = value_of_initializer %Bool.call.loc29 [concrete = bool]
  133. // CHECK:STDOUT: %.loc29_23.3: type = converted %Bool.call.loc29, %.loc29_23.2 [concrete = bool]
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %x: bool = bind_name x, %x.param
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: fn @F() -> bool {
  140. // CHECK:STDOUT: !entry:
  141. // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
  142. // CHECK:STDOUT: %impl.elem0: %.05c = impl_witness_access constants.%Copy.impl_witness.a56, element0 [concrete = constants.%bool.as.Copy.impl.Op]
  143. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %true, %impl.elem0 [concrete = constants.%bool.as.Copy.impl.Op.bound]
  144. // CHECK:STDOUT: %bool.as.Copy.impl.Op.call: init bool = call %bound_method(%true) [concrete = constants.%true]
  145. // CHECK:STDOUT: return %bool.as.Copy.impl.Op.call to %return
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: fn @G() -> bool {
  149. // CHECK:STDOUT: !entry:
  150. // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
  151. // CHECK:STDOUT: %impl.elem0: %.05c = impl_witness_access constants.%Copy.impl_witness.a56, element0 [concrete = constants.%bool.as.Copy.impl.Op]
  152. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %true, %impl.elem0 [concrete = constants.%bool.as.Copy.impl.Op.bound]
  153. // CHECK:STDOUT: %bool.as.Copy.impl.Op.call: init bool = call %bound_method(%true) [concrete = constants.%true]
  154. // CHECK:STDOUT: return %bool.as.Copy.impl.Op.call to %return
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: fn @And() -> bool {
  158. // CHECK:STDOUT: !entry:
  159. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  160. // CHECK:STDOUT: %F.call: init bool = call %F.ref()
  161. // CHECK:STDOUT: %.loc19_14.1: bool = value_of_initializer %F.call
  162. // CHECK:STDOUT: %.loc19_14.2: bool = converted %F.call, %.loc19_14.1
  163. // CHECK:STDOUT: %false: bool = bool_literal false [concrete = constants.%false]
  164. // CHECK:STDOUT: if %.loc19_14.2 br !and.rhs else br !and.result(%false)
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: !and.rhs:
  167. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
  168. // CHECK:STDOUT: %G.call: init bool = call %G.ref()
  169. // CHECK:STDOUT: %.loc19_14.3: bool = value_of_initializer %G.call
  170. // CHECK:STDOUT: %.loc19_14.4: bool = converted %G.call, %.loc19_14.3
  171. // CHECK:STDOUT: br !and.result(%.loc19_14.4)
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: !and.result:
  174. // CHECK:STDOUT: %.loc19_14.5: bool = block_arg !and.result
  175. // CHECK:STDOUT: %impl.elem0: %.05c = impl_witness_access constants.%Copy.impl_witness.a56, element0 [concrete = constants.%bool.as.Copy.impl.Op]
  176. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc19_14.5, %impl.elem0
  177. // CHECK:STDOUT: %bool.as.Copy.impl.Op.call: init bool = call %bound_method(%.loc19_14.5)
  178. // CHECK:STDOUT: return %bool.as.Copy.impl.Op.call to %return
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: fn @Constant() {
  182. // CHECK:STDOUT: !entry:
  183. // CHECK:STDOUT: name_binding_decl {
  184. // CHECK:STDOUT: %a.patt: %pattern_type.831 = binding_pattern a [concrete]
  185. // CHECK:STDOUT: %a.var_patt: %pattern_type.831 = var_pattern %a.patt [concrete]
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: %a.var: ref bool = var %a.var_patt
  188. // CHECK:STDOUT: %true.loc23_47: bool = bool_literal true [concrete = constants.%true]
  189. // CHECK:STDOUT: %impl.elem0: %.05c = impl_witness_access constants.%Copy.impl_witness.a56, element0 [concrete = constants.%bool.as.Copy.impl.Op]
  190. // CHECK:STDOUT: %bound_method.loc23: <bound method> = bound_method %true.loc23_47, %impl.elem0 [concrete = constants.%bool.as.Copy.impl.Op.bound]
  191. // CHECK:STDOUT: %bool.as.Copy.impl.Op.call: init bool = call %bound_method.loc23(%true.loc23_47) [concrete = constants.%true]
  192. // CHECK:STDOUT: assign %a.var, %bool.as.Copy.impl.Op.call
  193. // CHECK:STDOUT: br !.loc23_13
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: !.loc23_13:
  196. // CHECK:STDOUT: %true.loc23_13: bool = bool_literal true [concrete = constants.%true]
  197. // CHECK:STDOUT: %false.loc23: bool = bool_literal false [concrete = constants.%false]
  198. // CHECK:STDOUT: if %true.loc23_13 br !and.rhs.loc23 else br !and.result.loc23(%false.loc23)
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: !and.rhs.loc23:
  201. // CHECK:STDOUT: %true.loc23_22: bool = bool_literal true [concrete = constants.%true]
  202. // CHECK:STDOUT: br !and.result.loc23(%true.loc23_22)
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: !and.result.loc23:
  205. // CHECK:STDOUT: %.loc23_18: bool = block_arg !and.result.loc23 [concrete = constants.%true]
  206. // CHECK:STDOUT: if %.loc23_18 br !if.expr.then.loc23 else br !if.expr.else.loc23
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: !if.expr.then.loc23:
  209. // CHECK:STDOUT: %Bool.call.loc23: init type = call constants.%Bool() [concrete = bool]
  210. // CHECK:STDOUT: %.loc23_32.1: type = value_of_initializer %Bool.call.loc23 [concrete = bool]
  211. // CHECK:STDOUT: %.loc23_32.2: type = converted %Bool.call.loc23, %.loc23_32.1 [concrete = bool]
  212. // CHECK:STDOUT: br !if.expr.result.loc23(%.loc23_32.2)
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: !if.expr.else.loc23:
  215. // CHECK:STDOUT: %.loc23_43: %empty_tuple.type = tuple_literal ()
  216. // CHECK:STDOUT: %.loc23_37: type = converted %.loc23_43, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  217. // CHECK:STDOUT: br !if.expr.result.loc23(%.loc23_37)
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: !if.expr.result.loc23:
  220. // CHECK:STDOUT: %.loc23_10: type = block_arg !if.expr.result.loc23 [concrete = bool]
  221. // CHECK:STDOUT: br !.loc23_7
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: !.loc23_7:
  224. // CHECK:STDOUT: %a: ref bool = bind_name a, %a.var
  225. // CHECK:STDOUT: name_binding_decl {
  226. // CHECK:STDOUT: %b.patt: %pattern_type.cb1 = binding_pattern b [concrete]
  227. // CHECK:STDOUT: %b.var_patt: %pattern_type.cb1 = var_pattern %b.patt [concrete]
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var %b.var_patt
  230. // CHECK:STDOUT: %.loc24_49.1: %empty_tuple.type = tuple_literal ()
  231. // CHECK:STDOUT: %.loc24_49.2: init %empty_tuple.type = tuple_init () to %b.var [concrete = constants.%empty_tuple]
  232. // CHECK:STDOUT: %.loc24_3.1: init %empty_tuple.type = converted %.loc24_49.1, %.loc24_49.2 [concrete = constants.%empty_tuple]
  233. // CHECK:STDOUT: assign %b.var, %.loc24_3.1
  234. // CHECK:STDOUT: br !.loc24_13
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: !.loc24_13:
  237. // CHECK:STDOUT: %true.loc24: bool = bool_literal true [concrete = constants.%true]
  238. // CHECK:STDOUT: %false.loc24_18: bool = bool_literal false [concrete = constants.%false]
  239. // CHECK:STDOUT: if %true.loc24 br !and.rhs.loc24 else br !and.result.loc24(%false.loc24_18)
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: !and.rhs.loc24:
  242. // CHECK:STDOUT: %false.loc24_22: bool = bool_literal false [concrete = constants.%false]
  243. // CHECK:STDOUT: br !and.result.loc24(%false.loc24_22)
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: !and.result.loc24:
  246. // CHECK:STDOUT: %.loc24_18: bool = block_arg !and.result.loc24 [concrete = constants.%false]
  247. // CHECK:STDOUT: if %.loc24_18 br !if.expr.then.loc24 else br !if.expr.else.loc24
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: !if.expr.then.loc24:
  250. // CHECK:STDOUT: %Bool.call.loc24: init type = call constants.%Bool() [concrete = bool]
  251. // CHECK:STDOUT: %.loc24_33.1: type = value_of_initializer %Bool.call.loc24 [concrete = bool]
  252. // CHECK:STDOUT: %.loc24_33.2: type = converted %Bool.call.loc24, %.loc24_33.1 [concrete = bool]
  253. // CHECK:STDOUT: br !if.expr.result.loc24(%.loc24_33.2)
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: !if.expr.else.loc24:
  256. // CHECK:STDOUT: %.loc24_44: %empty_tuple.type = tuple_literal ()
  257. // CHECK:STDOUT: %.loc24_38: type = converted %.loc24_44, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  258. // CHECK:STDOUT: br !if.expr.result.loc24(%.loc24_38)
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: !if.expr.result.loc24:
  261. // CHECK:STDOUT: %.loc24_10: type = block_arg !if.expr.result.loc24 [concrete = constants.%empty_tuple.type]
  262. // CHECK:STDOUT: br !.loc24_7
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: !.loc24_7:
  265. // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var
  266. // CHECK:STDOUT: name_binding_decl {
  267. // CHECK:STDOUT: %c.patt: %pattern_type.cb1 = binding_pattern c [concrete]
  268. // CHECK:STDOUT: %c.var_patt: %pattern_type.cb1 = var_pattern %c.patt [concrete]
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT: %c.var: ref %empty_tuple.type = var %c.var_patt
  271. // CHECK:STDOUT: %.loc25_49.1: %empty_tuple.type = tuple_literal ()
  272. // CHECK:STDOUT: %.loc25_49.2: init %empty_tuple.type = tuple_init () to %c.var [concrete = constants.%empty_tuple]
  273. // CHECK:STDOUT: %.loc25_3.1: init %empty_tuple.type = converted %.loc25_49.1, %.loc25_49.2 [concrete = constants.%empty_tuple]
  274. // CHECK:STDOUT: assign %c.var, %.loc25_3.1
  275. // CHECK:STDOUT: br !.loc25_13
  276. // CHECK:STDOUT:
  277. // CHECK:STDOUT: !.loc25_13:
  278. // CHECK:STDOUT: %false.loc25_13: bool = bool_literal false [concrete = constants.%false]
  279. // CHECK:STDOUT: %false.loc25_19: bool = bool_literal false [concrete = constants.%false]
  280. // CHECK:STDOUT: if %false.loc25_13 br !and.rhs.loc25 else br !and.result.loc25(%false.loc25_19)
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: !and.rhs.loc25:
  283. // CHECK:STDOUT: %true.loc25: bool = bool_literal true [concrete = constants.%true]
  284. // CHECK:STDOUT: br !and.result.loc25(%true.loc25)
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: !and.result.loc25:
  287. // CHECK:STDOUT: %.loc25_19: bool = block_arg !and.result.loc25 [concrete = constants.%false]
  288. // CHECK:STDOUT: if %.loc25_19 br !if.expr.then.loc25 else br !if.expr.else.loc25
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: !if.expr.then.loc25:
  291. // CHECK:STDOUT: %Bool.call.loc25: init type = call constants.%Bool() [concrete = bool]
  292. // CHECK:STDOUT: %.loc25_33.1: type = value_of_initializer %Bool.call.loc25 [concrete = bool]
  293. // CHECK:STDOUT: %.loc25_33.2: type = converted %Bool.call.loc25, %.loc25_33.1 [concrete = bool]
  294. // CHECK:STDOUT: br !if.expr.result.loc25(%.loc25_33.2)
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: !if.expr.else.loc25:
  297. // CHECK:STDOUT: %.loc25_44: %empty_tuple.type = tuple_literal ()
  298. // CHECK:STDOUT: %.loc25_38: type = converted %.loc25_44, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  299. // CHECK:STDOUT: br !if.expr.result.loc25(%.loc25_38)
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: !if.expr.result.loc25:
  302. // CHECK:STDOUT: %.loc25_10: type = block_arg !if.expr.result.loc25 [concrete = constants.%empty_tuple.type]
  303. // CHECK:STDOUT: br !.loc25_7
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: !.loc25_7:
  306. // CHECK:STDOUT: %c: ref %empty_tuple.type = bind_name c, %c.var
  307. // CHECK:STDOUT: name_binding_decl {
  308. // CHECK:STDOUT: %d.patt: %pattern_type.cb1 = binding_pattern d [concrete]
  309. // CHECK:STDOUT: %d.var_patt: %pattern_type.cb1 = var_pattern %d.patt [concrete]
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var %d.var_patt
  312. // CHECK:STDOUT: %.loc26_50.1: %empty_tuple.type = tuple_literal ()
  313. // CHECK:STDOUT: %.loc26_50.2: init %empty_tuple.type = tuple_init () to %d.var [concrete = constants.%empty_tuple]
  314. // CHECK:STDOUT: %.loc26_3.1: init %empty_tuple.type = converted %.loc26_50.1, %.loc26_50.2 [concrete = constants.%empty_tuple]
  315. // CHECK:STDOUT: assign %d.var, %.loc26_3.1
  316. // CHECK:STDOUT: br !.loc26_13
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: !.loc26_13:
  319. // CHECK:STDOUT: %false.loc26_13: bool = bool_literal false [concrete = constants.%false]
  320. // CHECK:STDOUT: %false.loc26_19: bool = bool_literal false [concrete = constants.%false]
  321. // CHECK:STDOUT: if %false.loc26_13 br !and.rhs.loc26 else br !and.result.loc26(%false.loc26_19)
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: !and.rhs.loc26:
  324. // CHECK:STDOUT: %false.loc26_23: bool = bool_literal false [concrete = constants.%false]
  325. // CHECK:STDOUT: br !and.result.loc26(%false.loc26_23)
  326. // CHECK:STDOUT:
  327. // CHECK:STDOUT: !and.result.loc26:
  328. // CHECK:STDOUT: %.loc26_19: bool = block_arg !and.result.loc26 [concrete = constants.%false]
  329. // CHECK:STDOUT: if %.loc26_19 br !if.expr.then.loc26 else br !if.expr.else.loc26
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: !if.expr.then.loc26:
  332. // CHECK:STDOUT: %Bool.call.loc26: init type = call constants.%Bool() [concrete = bool]
  333. // CHECK:STDOUT: %.loc26_34.1: type = value_of_initializer %Bool.call.loc26 [concrete = bool]
  334. // CHECK:STDOUT: %.loc26_34.2: type = converted %Bool.call.loc26, %.loc26_34.1 [concrete = bool]
  335. // CHECK:STDOUT: br !if.expr.result.loc26(%.loc26_34.2)
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: !if.expr.else.loc26:
  338. // CHECK:STDOUT: %.loc26_45: %empty_tuple.type = tuple_literal ()
  339. // CHECK:STDOUT: %.loc26_39: type = converted %.loc26_45, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  340. // CHECK:STDOUT: br !if.expr.result.loc26(%.loc26_39)
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: !if.expr.result.loc26:
  343. // CHECK:STDOUT: %.loc26_10: type = block_arg !if.expr.result.loc26 [concrete = constants.%empty_tuple.type]
  344. // CHECK:STDOUT: br !.loc26_7
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: !.loc26_7:
  347. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  348. // CHECK:STDOUT: %facet_value.loc26: %type_where = facet_value constants.%empty_tuple.type, () [concrete = constants.%facet_value]
  349. // CHECK:STDOUT: %.loc26_3.2: %type_where = converted constants.%empty_tuple.type, %facet_value.loc26 [concrete = constants.%facet_value]
  350. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc26: <bound method> = bound_method %d.var, constants.%AggregateT.as_type.as.Destroy.impl.Op.c00
  351. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.1: <specific function> = specific_function constants.%AggregateT.as_type.as.Destroy.impl.Op.c00, @AggregateT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%AggregateT.as_type.as.Destroy.impl.Op.specific_fn]
  352. // CHECK:STDOUT: %bound_method.loc26: <bound method> = bound_method %d.var, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.1
  353. // CHECK:STDOUT: %addr.loc26: %ptr.843 = addr_of %d.var
  354. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc26: init %empty_tuple.type = call %bound_method.loc26(%addr.loc26)
  355. // CHECK:STDOUT: %facet_value.loc25: %type_where = facet_value constants.%empty_tuple.type, () [concrete = constants.%facet_value]
  356. // CHECK:STDOUT: %.loc25_3.2: %type_where = converted constants.%empty_tuple.type, %facet_value.loc25 [concrete = constants.%facet_value]
  357. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc25: <bound method> = bound_method %c.var, constants.%AggregateT.as_type.as.Destroy.impl.Op.c00
  358. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.2: <specific function> = specific_function constants.%AggregateT.as_type.as.Destroy.impl.Op.c00, @AggregateT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%AggregateT.as_type.as.Destroy.impl.Op.specific_fn]
  359. // CHECK:STDOUT: %bound_method.loc25: <bound method> = bound_method %c.var, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.2
  360. // CHECK:STDOUT: %addr.loc25: %ptr.843 = addr_of %c.var
  361. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc25: init %empty_tuple.type = call %bound_method.loc25(%addr.loc25)
  362. // CHECK:STDOUT: %facet_value.loc24: %type_where = facet_value constants.%empty_tuple.type, () [concrete = constants.%facet_value]
  363. // CHECK:STDOUT: %.loc24_3.2: %type_where = converted constants.%empty_tuple.type, %facet_value.loc24 [concrete = constants.%facet_value]
  364. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound.loc24: <bound method> = bound_method %b.var, constants.%AggregateT.as_type.as.Destroy.impl.Op.c00
  365. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.3: <specific function> = specific_function constants.%AggregateT.as_type.as.Destroy.impl.Op.c00, @AggregateT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%AggregateT.as_type.as.Destroy.impl.Op.specific_fn]
  366. // CHECK:STDOUT: %bound_method.loc24: <bound method> = bound_method %b.var, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn.3
  367. // CHECK:STDOUT: %addr.loc24: %ptr.843 = addr_of %b.var
  368. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call.loc24: init %empty_tuple.type = call %bound_method.loc24(%addr.loc24)
  369. // CHECK:STDOUT: %bool.as.Destroy.impl.Op.bound: <bound method> = bound_method %a.var, constants.%bool.as.Destroy.impl.Op
  370. // CHECK:STDOUT: %addr.loc23: %ptr.bb2 = addr_of %a.var
  371. // CHECK:STDOUT: %bool.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bool.as.Destroy.impl.Op.bound(%addr.loc23)
  372. // CHECK:STDOUT: return
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: fn @PartialConstant(%x.param: bool) {
  376. // CHECK:STDOUT: !entry:
  377. // CHECK:STDOUT: name_binding_decl {
  378. // CHECK:STDOUT: %a.patt: %pattern_type.cb1 = binding_pattern a [concrete]
  379. // CHECK:STDOUT: %a.var_patt: %pattern_type.cb1 = var_pattern %a.patt [concrete]
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var %a.var_patt
  382. // CHECK:STDOUT: %.loc30_46.1: %empty_tuple.type = tuple_literal ()
  383. // CHECK:STDOUT: %.loc30_46.2: init %empty_tuple.type = tuple_init () to %a.var [concrete = constants.%empty_tuple]
  384. // CHECK:STDOUT: %.loc30_3.1: init %empty_tuple.type = converted %.loc30_46.1, %.loc30_46.2 [concrete = constants.%empty_tuple]
  385. // CHECK:STDOUT: assign %a.var, %.loc30_3.1
  386. // CHECK:STDOUT: br !.loc30_13
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: !.loc30_13:
  389. // CHECK:STDOUT: %false.loc30_13: bool = bool_literal false [concrete = constants.%false]
  390. // CHECK:STDOUT: %false.loc30_19: bool = bool_literal false [concrete = constants.%false]
  391. // CHECK:STDOUT: if %false.loc30_13 br !and.rhs else br !and.result(%false.loc30_19)
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: !and.rhs:
  394. // CHECK:STDOUT: %x.ref: bool = name_ref x, %x
  395. // CHECK:STDOUT: br !and.result(%x.ref)
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: !and.result:
  398. // CHECK:STDOUT: %.loc30_19: bool = block_arg !and.result [concrete = constants.%false]
  399. // CHECK:STDOUT: if %.loc30_19 br !if.expr.then else br !if.expr.else
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: !if.expr.then:
  402. // CHECK:STDOUT: %Bool.call.loc30: init type = call constants.%Bool() [concrete = bool]
  403. // CHECK:STDOUT: %.loc30_30.1: type = value_of_initializer %Bool.call.loc30 [concrete = bool]
  404. // CHECK:STDOUT: %.loc30_30.2: type = converted %Bool.call.loc30, %.loc30_30.1 [concrete = bool]
  405. // CHECK:STDOUT: br !if.expr.result(%.loc30_30.2)
  406. // CHECK:STDOUT:
  407. // CHECK:STDOUT: !if.expr.else:
  408. // CHECK:STDOUT: %.loc30_41: %empty_tuple.type = tuple_literal ()
  409. // CHECK:STDOUT: %.loc30_35: type = converted %.loc30_41, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  410. // CHECK:STDOUT: br !if.expr.result(%.loc30_35)
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: !if.expr.result:
  413. // CHECK:STDOUT: %.loc30_10: type = block_arg !if.expr.result [concrete = constants.%empty_tuple.type]
  414. // CHECK:STDOUT: br !.loc30_7
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: !.loc30_7:
  417. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  418. // CHECK:STDOUT: %facet_value: %type_where = facet_value constants.%empty_tuple.type, () [concrete = constants.%facet_value]
  419. // CHECK:STDOUT: %.loc30_3.2: %type_where = converted constants.%empty_tuple.type, %facet_value [concrete = constants.%facet_value]
  420. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %a.var, constants.%AggregateT.as_type.as.Destroy.impl.Op.c00
  421. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function constants.%AggregateT.as_type.as.Destroy.impl.Op.c00, @AggregateT.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%AggregateT.as_type.as.Destroy.impl.Op.specific_fn]
  422. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %a.var, %AggregateT.as_type.as.Destroy.impl.Op.specific_fn
  423. // CHECK:STDOUT: %addr: %ptr.843 = addr_of %a.var
  424. // CHECK:STDOUT: %AggregateT.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  425. // CHECK:STDOUT: return
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT: