and.carbon 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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/builtin/and.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/and.carbon
  10. fn F() -> bool { return true; }
  11. fn G() -> bool { return true; }
  12. fn And() -> bool {
  13. return F() and G();
  14. }
  15. fn Constant() {
  16. var a: if true and true then bool else () = true;
  17. var b: if true and false then bool else () = ();
  18. var c: if false and true then bool else () = ();
  19. var d: if false and false then bool else () = ();
  20. }
  21. fn PartialConstant(x: bool) {
  22. var a: if false and x then bool else () = ();
  23. }
  24. // CHECK:STDOUT: --- and.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  28. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  29. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  30. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  31. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  32. // CHECK:STDOUT: %true: bool = bool_literal true [template]
  33. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  34. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  35. // CHECK:STDOUT: %And.type: type = fn_type @And [template]
  36. // CHECK:STDOUT: %And: %And.type = struct_value () [template]
  37. // CHECK:STDOUT: %false: bool = bool_literal false [template]
  38. // CHECK:STDOUT: %Constant.type: type = fn_type @Constant [template]
  39. // CHECK:STDOUT: %Constant: %Constant.type = struct_value () [template]
  40. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  41. // CHECK:STDOUT: %PartialConstant.type: type = fn_type @PartialConstant [template]
  42. // CHECK:STDOUT: %PartialConstant: %PartialConstant.type = struct_value () [template]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: imports {
  46. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  47. // CHECK:STDOUT: .Bool = %Core.Bool
  48. // CHECK:STDOUT: import Core//prelude
  49. // CHECK:STDOUT: import Core//prelude/...
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: file {
  54. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  55. // CHECK:STDOUT: .Core = imports.%Core
  56. // CHECK:STDOUT: .F = %F.decl
  57. // CHECK:STDOUT: .G = %G.decl
  58. // CHECK:STDOUT: .And = %And.decl
  59. // CHECK:STDOUT: .Constant = %Constant.decl
  60. // CHECK:STDOUT: .PartialConstant = %PartialConstant.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %Core.import = import Core
  63. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  64. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  65. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param0
  66. // CHECK:STDOUT: } {
  67. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  68. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %bool.make_type [template = bool]
  69. // CHECK:STDOUT: %.loc11_11.2: type = converted %bool.make_type, %.loc11_11.1 [template = bool]
  70. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param0
  71. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  74. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  75. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param0
  76. // CHECK:STDOUT: } {
  77. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  78. // CHECK:STDOUT: %.loc12_11.1: type = value_of_initializer %bool.make_type [template = bool]
  79. // CHECK:STDOUT: %.loc12_11.2: type = converted %bool.make_type, %.loc12_11.1 [template = bool]
  80. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param0
  81. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %And.decl: %And.type = fn_decl @And [template = constants.%And] {
  84. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  85. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param0
  86. // CHECK:STDOUT: } {
  87. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  88. // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %bool.make_type [template = bool]
  89. // CHECK:STDOUT: %.loc14_13.2: type = converted %bool.make_type, %.loc14_13.1 [template = bool]
  90. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param0
  91. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %Constant.decl: %Constant.type = fn_decl @Constant [template = constants.%Constant] {} {}
  94. // CHECK:STDOUT: %PartialConstant.decl: %PartialConstant.type = fn_decl @PartialConstant [template = constants.%PartialConstant] {
  95. // CHECK:STDOUT: %x.patt: bool = binding_pattern x
  96. // CHECK:STDOUT: %x.param_patt: bool = value_param_pattern %x.patt, runtime_param0
  97. // CHECK:STDOUT: } {
  98. // CHECK:STDOUT: %x.param: bool = value_param runtime_param0
  99. // CHECK:STDOUT: %.loc25_23.1: type = splice_block %.loc25_23.3 [template = bool] {
  100. // CHECK:STDOUT: %bool.make_type.loc25: init type = call constants.%Bool() [template = bool]
  101. // CHECK:STDOUT: %.loc25_23.2: type = value_of_initializer %bool.make_type.loc25 [template = bool]
  102. // CHECK:STDOUT: %.loc25_23.3: type = converted %bool.make_type.loc25, %.loc25_23.2 [template = bool]
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: %x: bool = bind_name x, %x.param
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: fn @F() -> bool {
  109. // CHECK:STDOUT: !entry:
  110. // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true]
  111. // CHECK:STDOUT: return %true
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: fn @G() -> bool {
  115. // CHECK:STDOUT: !entry:
  116. // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true]
  117. // CHECK:STDOUT: return %true
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: fn @And() -> bool {
  121. // CHECK:STDOUT: !entry:
  122. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  123. // CHECK:STDOUT: %F.call: init bool = call %F.ref()
  124. // CHECK:STDOUT: %.loc15_14.1: bool = value_of_initializer %F.call
  125. // CHECK:STDOUT: %.loc15_14.2: bool = converted %F.call, %.loc15_14.1
  126. // CHECK:STDOUT: %false: bool = bool_literal false [template = constants.%false]
  127. // CHECK:STDOUT: if %.loc15_14.2 br !and.rhs else br !and.result(%false)
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: !and.rhs:
  130. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [template = constants.%G]
  131. // CHECK:STDOUT: %G.call: init bool = call %G.ref()
  132. // CHECK:STDOUT: %.loc15_14.3: bool = value_of_initializer %G.call
  133. // CHECK:STDOUT: %.loc15_14.4: bool = converted %G.call, %.loc15_14.3
  134. // CHECK:STDOUT: br !and.result(%.loc15_14.4)
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: !and.result:
  137. // CHECK:STDOUT: %.loc15_14.5: bool = block_arg !and.result
  138. // CHECK:STDOUT: return %.loc15_14.5
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: fn @Constant() {
  142. // CHECK:STDOUT: !entry:
  143. // CHECK:STDOUT: name_binding_decl {
  144. // CHECK:STDOUT: %a.patt: bool = binding_pattern a
  145. // CHECK:STDOUT: %.loc19_3: bool = var_pattern %a.patt
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %a.var: ref bool = var a
  148. // CHECK:STDOUT: %true.loc19_47: bool = bool_literal true [template = constants.%true]
  149. // CHECK:STDOUT: assign %a.var, %true.loc19_47
  150. // CHECK:STDOUT: br !.loc19_13
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: !.loc19_13:
  153. // CHECK:STDOUT: %true.loc19_13: bool = bool_literal true [template = constants.%true]
  154. // CHECK:STDOUT: %false.loc19: bool = bool_literal false [template = constants.%false]
  155. // CHECK:STDOUT: if %true.loc19_13 br !and.rhs.loc19 else br !and.result.loc19(%false.loc19)
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: !and.rhs.loc19:
  158. // CHECK:STDOUT: %true.loc19_22: bool = bool_literal true [template = constants.%true]
  159. // CHECK:STDOUT: br !and.result.loc19(%true.loc19_22)
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: !and.result.loc19:
  162. // CHECK:STDOUT: %.loc19_18: bool = block_arg !and.result.loc19 [template = constants.%true]
  163. // CHECK:STDOUT: if %.loc19_18 br !if.expr.then.loc19 else br !if.expr.else.loc19
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: !if.expr.then.loc19:
  166. // CHECK:STDOUT: %bool.make_type.loc19: init type = call constants.%Bool() [template = bool]
  167. // CHECK:STDOUT: %.loc19_32.1: type = value_of_initializer %bool.make_type.loc19 [template = bool]
  168. // CHECK:STDOUT: %.loc19_32.2: type = converted %bool.make_type.loc19, %.loc19_32.1 [template = bool]
  169. // CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_32.2)
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: !if.expr.else.loc19:
  172. // CHECK:STDOUT: %.loc19_43: %empty_tuple.type = tuple_literal ()
  173. // CHECK:STDOUT: %.loc19_37: type = converted %.loc19_43, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  174. // CHECK:STDOUT: br !if.expr.result.loc19(%.loc19_37)
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: !if.expr.result.loc19:
  177. // CHECK:STDOUT: %.loc19_10: type = block_arg !if.expr.result.loc19 [template = bool]
  178. // CHECK:STDOUT: br !.loc19_7
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: !.loc19_7:
  181. // CHECK:STDOUT: %a: ref bool = bind_name a, %a.var
  182. // CHECK:STDOUT: name_binding_decl {
  183. // CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b
  184. // CHECK:STDOUT: %.loc20_3.1: %empty_tuple.type = var_pattern %b.patt
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b
  187. // CHECK:STDOUT: %.loc20_49.1: %empty_tuple.type = tuple_literal ()
  188. // CHECK:STDOUT: %.loc20_49.2: init %empty_tuple.type = tuple_init () to %b.var [template = constants.%empty_tuple]
  189. // CHECK:STDOUT: %.loc20_3.2: init %empty_tuple.type = converted %.loc20_49.1, %.loc20_49.2 [template = constants.%empty_tuple]
  190. // CHECK:STDOUT: assign %b.var, %.loc20_3.2
  191. // CHECK:STDOUT: br !.loc20_13
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: !.loc20_13:
  194. // CHECK:STDOUT: %true.loc20: bool = bool_literal true [template = constants.%true]
  195. // CHECK:STDOUT: %false.loc20_18: bool = bool_literal false [template = constants.%false]
  196. // CHECK:STDOUT: if %true.loc20 br !and.rhs.loc20 else br !and.result.loc20(%false.loc20_18)
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: !and.rhs.loc20:
  199. // CHECK:STDOUT: %false.loc20_22: bool = bool_literal false [template = constants.%false]
  200. // CHECK:STDOUT: br !and.result.loc20(%false.loc20_22)
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: !and.result.loc20:
  203. // CHECK:STDOUT: %.loc20_18: bool = block_arg !and.result.loc20 [template = constants.%false]
  204. // CHECK:STDOUT: if %.loc20_18 br !if.expr.then.loc20 else br !if.expr.else.loc20
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: !if.expr.then.loc20:
  207. // CHECK:STDOUT: %bool.make_type.loc20: init type = call constants.%Bool() [template = bool]
  208. // CHECK:STDOUT: %.loc20_33.1: type = value_of_initializer %bool.make_type.loc20 [template = bool]
  209. // CHECK:STDOUT: %.loc20_33.2: type = converted %bool.make_type.loc20, %.loc20_33.1 [template = bool]
  210. // CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_33.2)
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: !if.expr.else.loc20:
  213. // CHECK:STDOUT: %.loc20_44: %empty_tuple.type = tuple_literal ()
  214. // CHECK:STDOUT: %.loc20_38: type = converted %.loc20_44, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  215. // CHECK:STDOUT: br !if.expr.result.loc20(%.loc20_38)
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: !if.expr.result.loc20:
  218. // CHECK:STDOUT: %.loc20_10: type = block_arg !if.expr.result.loc20 [template = constants.%empty_tuple.type]
  219. // CHECK:STDOUT: br !.loc20_7
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: !.loc20_7:
  222. // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var
  223. // CHECK:STDOUT: name_binding_decl {
  224. // CHECK:STDOUT: %c.patt: %empty_tuple.type = binding_pattern c
  225. // CHECK:STDOUT: %.loc21_3.1: %empty_tuple.type = var_pattern %c.patt
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT: %c.var: ref %empty_tuple.type = var c
  228. // CHECK:STDOUT: %.loc21_49.1: %empty_tuple.type = tuple_literal ()
  229. // CHECK:STDOUT: %.loc21_49.2: init %empty_tuple.type = tuple_init () to %c.var [template = constants.%empty_tuple]
  230. // CHECK:STDOUT: %.loc21_3.2: init %empty_tuple.type = converted %.loc21_49.1, %.loc21_49.2 [template = constants.%empty_tuple]
  231. // CHECK:STDOUT: assign %c.var, %.loc21_3.2
  232. // CHECK:STDOUT: br !.loc21_13
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: !.loc21_13:
  235. // CHECK:STDOUT: %false.loc21_13: bool = bool_literal false [template = constants.%false]
  236. // CHECK:STDOUT: %false.loc21_19: bool = bool_literal false [template = constants.%false]
  237. // CHECK:STDOUT: if %false.loc21_13 br !and.rhs.loc21 else br !and.result.loc21(%false.loc21_19)
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: !and.rhs.loc21:
  240. // CHECK:STDOUT: %true.loc21: bool = bool_literal true [template = constants.%true]
  241. // CHECK:STDOUT: br !and.result.loc21(%true.loc21)
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: !and.result.loc21:
  244. // CHECK:STDOUT: %.loc21_19: bool = block_arg !and.result.loc21 [template = constants.%false]
  245. // CHECK:STDOUT: if %.loc21_19 br !if.expr.then.loc21 else br !if.expr.else.loc21
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: !if.expr.then.loc21:
  248. // CHECK:STDOUT: %bool.make_type.loc21: init type = call constants.%Bool() [template = bool]
  249. // CHECK:STDOUT: %.loc21_33.1: type = value_of_initializer %bool.make_type.loc21 [template = bool]
  250. // CHECK:STDOUT: %.loc21_33.2: type = converted %bool.make_type.loc21, %.loc21_33.1 [template = bool]
  251. // CHECK:STDOUT: br !if.expr.result.loc21(%.loc21_33.2)
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: !if.expr.else.loc21:
  254. // CHECK:STDOUT: %.loc21_44: %empty_tuple.type = tuple_literal ()
  255. // CHECK:STDOUT: %.loc21_38: type = converted %.loc21_44, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  256. // CHECK:STDOUT: br !if.expr.result.loc21(%.loc21_38)
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: !if.expr.result.loc21:
  259. // CHECK:STDOUT: %.loc21_10: type = block_arg !if.expr.result.loc21 [template = constants.%empty_tuple.type]
  260. // CHECK:STDOUT: br !.loc21_7
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: !.loc21_7:
  263. // CHECK:STDOUT: %c: ref %empty_tuple.type = bind_name c, %c.var
  264. // CHECK:STDOUT: name_binding_decl {
  265. // CHECK:STDOUT: %d.patt: %empty_tuple.type = binding_pattern d
  266. // CHECK:STDOUT: %.loc22_3.1: %empty_tuple.type = var_pattern %d.patt
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT: %d.var: ref %empty_tuple.type = var d
  269. // CHECK:STDOUT: %.loc22_50.1: %empty_tuple.type = tuple_literal ()
  270. // CHECK:STDOUT: %.loc22_50.2: init %empty_tuple.type = tuple_init () to %d.var [template = constants.%empty_tuple]
  271. // CHECK:STDOUT: %.loc22_3.2: init %empty_tuple.type = converted %.loc22_50.1, %.loc22_50.2 [template = constants.%empty_tuple]
  272. // CHECK:STDOUT: assign %d.var, %.loc22_3.2
  273. // CHECK:STDOUT: br !.loc22_13
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: !.loc22_13:
  276. // CHECK:STDOUT: %false.loc22_13: bool = bool_literal false [template = constants.%false]
  277. // CHECK:STDOUT: %false.loc22_19: bool = bool_literal false [template = constants.%false]
  278. // CHECK:STDOUT: if %false.loc22_13 br !and.rhs.loc22 else br !and.result.loc22(%false.loc22_19)
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: !and.rhs.loc22:
  281. // CHECK:STDOUT: %false.loc22_23: bool = bool_literal false [template = constants.%false]
  282. // CHECK:STDOUT: br !and.result.loc22(%false.loc22_23)
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: !and.result.loc22:
  285. // CHECK:STDOUT: %.loc22_19: bool = block_arg !and.result.loc22 [template = constants.%false]
  286. // CHECK:STDOUT: if %.loc22_19 br !if.expr.then.loc22 else br !if.expr.else.loc22
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: !if.expr.then.loc22:
  289. // CHECK:STDOUT: %bool.make_type.loc22: init type = call constants.%Bool() [template = bool]
  290. // CHECK:STDOUT: %.loc22_34.1: type = value_of_initializer %bool.make_type.loc22 [template = bool]
  291. // CHECK:STDOUT: %.loc22_34.2: type = converted %bool.make_type.loc22, %.loc22_34.1 [template = bool]
  292. // CHECK:STDOUT: br !if.expr.result.loc22(%.loc22_34.2)
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: !if.expr.else.loc22:
  295. // CHECK:STDOUT: %.loc22_45: %empty_tuple.type = tuple_literal ()
  296. // CHECK:STDOUT: %.loc22_39: type = converted %.loc22_45, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  297. // CHECK:STDOUT: br !if.expr.result.loc22(%.loc22_39)
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: !if.expr.result.loc22:
  300. // CHECK:STDOUT: %.loc22_10: type = block_arg !if.expr.result.loc22 [template = constants.%empty_tuple.type]
  301. // CHECK:STDOUT: br !.loc22_7
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: !.loc22_7:
  304. // CHECK:STDOUT: %d: ref %empty_tuple.type = bind_name d, %d.var
  305. // CHECK:STDOUT: return
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: fn @PartialConstant(%x.param_patt: bool) {
  309. // CHECK:STDOUT: !entry:
  310. // CHECK:STDOUT: name_binding_decl {
  311. // CHECK:STDOUT: %a.patt: %empty_tuple.type = binding_pattern a
  312. // CHECK:STDOUT: %.loc26_3.1: %empty_tuple.type = var_pattern %a.patt
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  315. // CHECK:STDOUT: %.loc26_46.1: %empty_tuple.type = tuple_literal ()
  316. // CHECK:STDOUT: %.loc26_46.2: init %empty_tuple.type = tuple_init () to %a.var [template = constants.%empty_tuple]
  317. // CHECK:STDOUT: %.loc26_3.2: init %empty_tuple.type = converted %.loc26_46.1, %.loc26_46.2 [template = constants.%empty_tuple]
  318. // CHECK:STDOUT: assign %a.var, %.loc26_3.2
  319. // CHECK:STDOUT: br !.loc26_13
  320. // CHECK:STDOUT:
  321. // CHECK:STDOUT: !.loc26_13:
  322. // CHECK:STDOUT: %false.loc26_13: bool = bool_literal false [template = constants.%false]
  323. // CHECK:STDOUT: %false.loc26_19: bool = bool_literal false [template = constants.%false]
  324. // CHECK:STDOUT: if %false.loc26_13 br !and.rhs else br !and.result(%false.loc26_19)
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: !and.rhs:
  327. // CHECK:STDOUT: %x.ref: bool = name_ref x, %x
  328. // CHECK:STDOUT: br !and.result(%x.ref)
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: !and.result:
  331. // CHECK:STDOUT: %.loc26_19: bool = block_arg !and.result [template = constants.%false]
  332. // CHECK:STDOUT: if %.loc26_19 br !if.expr.then else br !if.expr.else
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: !if.expr.then:
  335. // CHECK:STDOUT: %bool.make_type.loc26: init type = call constants.%Bool() [template = bool]
  336. // CHECK:STDOUT: %.loc26_30.1: type = value_of_initializer %bool.make_type.loc26 [template = bool]
  337. // CHECK:STDOUT: %.loc26_30.2: type = converted %bool.make_type.loc26, %.loc26_30.1 [template = bool]
  338. // CHECK:STDOUT: br !if.expr.result(%.loc26_30.2)
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: !if.expr.else:
  341. // CHECK:STDOUT: %.loc26_41: %empty_tuple.type = tuple_literal ()
  342. // CHECK:STDOUT: %.loc26_35: type = converted %.loc26_41, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  343. // CHECK:STDOUT: br !if.expr.result(%.loc26_35)
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: !if.expr.result:
  346. // CHECK:STDOUT: %.loc26_10: type = block_arg !if.expr.result [template = constants.%empty_tuple.type]
  347. // CHECK:STDOUT: br !.loc26_7
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: !.loc26_7:
  350. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  351. // CHECK:STDOUT: return
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: