assignment.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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/assignment.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/assignment.carbon
  10. fn Main() {
  11. var a: i32 = 12;
  12. a = 9;
  13. var b: (i32, i32) = (1, 2);
  14. b.0 = 3;
  15. b.1 = 4;
  16. var c: {.a: i32, .b: i32} = {.a = 1, .b = 2};
  17. c.a = 3;
  18. c.b = 4;
  19. var p: i32* = &a;
  20. *p = 5;
  21. *(if true then p else &a) = 10;
  22. }
  23. // CHECK:STDOUT: --- assignment.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  27. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  28. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  29. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  30. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  31. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  32. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 12 [template]
  33. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  34. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
  35. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  36. // CHECK:STDOUT: %.22: <witness> = interface_witness (%Convert.14) [template]
  37. // CHECK:STDOUT: %.23: <bound method> = bound_method %.2, %Convert.14 [template]
  38. // CHECK:STDOUT: %.24: <specific function> = specific_function %.23, @Convert.2(%.1) [template]
  39. // CHECK:STDOUT: %.25: %i32 = int_value 12 [template]
  40. // CHECK:STDOUT: %.26: Core.IntLiteral = int_value 9 [template]
  41. // CHECK:STDOUT: %.27: <bound method> = bound_method %.26, %Convert.14 [template]
  42. // CHECK:STDOUT: %.28: <specific function> = specific_function %.27, @Convert.2(%.1) [template]
  43. // CHECK:STDOUT: %.29: %i32 = int_value 9 [template]
  44. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
  45. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32, %i32) [template]
  46. // CHECK:STDOUT: %.31: Core.IntLiteral = int_value 1 [template]
  47. // CHECK:STDOUT: %.32: Core.IntLiteral = int_value 2 [template]
  48. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template]
  49. // CHECK:STDOUT: %.33: <bound method> = bound_method %.31, %Convert.14 [template]
  50. // CHECK:STDOUT: %.34: <specific function> = specific_function %.33, @Convert.2(%.1) [template]
  51. // CHECK:STDOUT: %.35: %i32 = int_value 1 [template]
  52. // CHECK:STDOUT: %.36: <bound method> = bound_method %.32, %Convert.14 [template]
  53. // CHECK:STDOUT: %.37: <specific function> = specific_function %.36, @Convert.2(%.1) [template]
  54. // CHECK:STDOUT: %.38: %i32 = int_value 2 [template]
  55. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.35, %.38) [template]
  56. // CHECK:STDOUT: %.39: Core.IntLiteral = int_value 0 [template]
  57. // CHECK:STDOUT: %.40: Core.IntLiteral = int_value 3 [template]
  58. // CHECK:STDOUT: %.41: <bound method> = bound_method %.40, %Convert.14 [template]
  59. // CHECK:STDOUT: %.42: <specific function> = specific_function %.41, @Convert.2(%.1) [template]
  60. // CHECK:STDOUT: %.43: %i32 = int_value 3 [template]
  61. // CHECK:STDOUT: %.44: Core.IntLiteral = int_value 4 [template]
  62. // CHECK:STDOUT: %.45: <bound method> = bound_method %.44, %Convert.14 [template]
  63. // CHECK:STDOUT: %.46: <specific function> = specific_function %.45, @Convert.2(%.1) [template]
  64. // CHECK:STDOUT: %.47: %i32 = int_value 4 [template]
  65. // CHECK:STDOUT: %.48: type = struct_type {.a: %i32, .b: %i32} [template]
  66. // CHECK:STDOUT: %.50: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [template]
  67. // CHECK:STDOUT: %struct: %.48 = struct_value (%.35, %.38) [template]
  68. // CHECK:STDOUT: %.51: type = ptr_type %i32 [template]
  69. // CHECK:STDOUT: %.52: Core.IntLiteral = int_value 5 [template]
  70. // CHECK:STDOUT: %.53: <bound method> = bound_method %.52, %Convert.14 [template]
  71. // CHECK:STDOUT: %.54: <specific function> = specific_function %.53, @Convert.2(%.1) [template]
  72. // CHECK:STDOUT: %.55: %i32 = int_value 5 [template]
  73. // CHECK:STDOUT: %.56: bool = bool_literal true [template]
  74. // CHECK:STDOUT: %.57: Core.IntLiteral = int_value 10 [template]
  75. // CHECK:STDOUT: %.58: <bound method> = bound_method %.57, %Convert.14 [template]
  76. // CHECK:STDOUT: %.59: <specific function> = specific_function %.58, @Convert.2(%.1) [template]
  77. // CHECK:STDOUT: %.60: %i32 = int_value 10 [template]
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT:
  80. // CHECK:STDOUT: imports {
  81. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  82. // CHECK:STDOUT: .Int = %import_ref.1
  83. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  84. // CHECK:STDOUT: import Core//prelude
  85. // CHECK:STDOUT: import Core//prelude/...
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: file {
  90. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  91. // CHECK:STDOUT: .Core = imports.%Core
  92. // CHECK:STDOUT: .Main = %Main.decl
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %Core.import = import Core
  95. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: fn @Main() {
  99. // CHECK:STDOUT: !entry:
  100. // CHECK:STDOUT: %.loc12_10.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  101. // CHECK:STDOUT: %int.make_type_signed.loc12: init type = call constants.%Int(%.loc12_10.1) [template = constants.%i32]
  102. // CHECK:STDOUT: %.loc12_10.2: type = value_of_initializer %int.make_type_signed.loc12 [template = constants.%i32]
  103. // CHECK:STDOUT: %.loc12_10.3: type = converted %int.make_type_signed.loc12, %.loc12_10.2 [template = constants.%i32]
  104. // CHECK:STDOUT: %a.var: ref %i32 = var a
  105. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  106. // CHECK:STDOUT: %.loc12_16: Core.IntLiteral = int_value 12 [template = constants.%.2]
  107. // CHECK:STDOUT: %.loc12_18.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  108. // CHECK:STDOUT: %.loc12_18.2: <bound method> = bound_method %.loc12_16, %.loc12_18.1 [template = constants.%.23]
  109. // CHECK:STDOUT: %.loc12_18.3: <specific function> = specific_function %.loc12_18.2, @Convert.2(constants.%.1) [template = constants.%.24]
  110. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %.loc12_18.3(%.loc12_16) [template = constants.%.25]
  111. // CHECK:STDOUT: %.loc12_18.4: init %i32 = converted %.loc12_16, %int.convert_checked.loc12 [template = constants.%.25]
  112. // CHECK:STDOUT: assign %a.var, %.loc12_18.4
  113. // CHECK:STDOUT: %a.ref.loc13: ref %i32 = name_ref a, %a
  114. // CHECK:STDOUT: %.loc13_7: Core.IntLiteral = int_value 9 [template = constants.%.26]
  115. // CHECK:STDOUT: %.loc13_5.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  116. // CHECK:STDOUT: %.loc13_5.2: <bound method> = bound_method %.loc13_7, %.loc13_5.1 [template = constants.%.27]
  117. // CHECK:STDOUT: %.loc13_5.3: <specific function> = specific_function %.loc13_5.2, @Convert.2(constants.%.1) [template = constants.%.28]
  118. // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %.loc13_5.3(%.loc13_7) [template = constants.%.29]
  119. // CHECK:STDOUT: %.loc13_5.4: init %i32 = converted %.loc13_7, %int.convert_checked.loc13 [template = constants.%.29]
  120. // CHECK:STDOUT: assign %a.ref.loc13, %.loc13_5.4
  121. // CHECK:STDOUT: %.loc15_11: Core.IntLiteral = int_value 32 [template = constants.%.1]
  122. // CHECK:STDOUT: %int.make_type_signed.loc15_11: init type = call constants.%Int(%.loc15_11) [template = constants.%i32]
  123. // CHECK:STDOUT: %.loc15_16: Core.IntLiteral = int_value 32 [template = constants.%.1]
  124. // CHECK:STDOUT: %int.make_type_signed.loc15_16: init type = call constants.%Int(%.loc15_16) [template = constants.%i32]
  125. // CHECK:STDOUT: %.loc15_19.1: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc15_11, %int.make_type_signed.loc15_16)
  126. // CHECK:STDOUT: %.loc15_19.2: type = value_of_initializer %int.make_type_signed.loc15_11 [template = constants.%i32]
  127. // CHECK:STDOUT: %.loc15_19.3: type = converted %int.make_type_signed.loc15_11, %.loc15_19.2 [template = constants.%i32]
  128. // CHECK:STDOUT: %.loc15_19.4: type = value_of_initializer %int.make_type_signed.loc15_16 [template = constants.%i32]
  129. // CHECK:STDOUT: %.loc15_19.5: type = converted %int.make_type_signed.loc15_16, %.loc15_19.4 [template = constants.%i32]
  130. // CHECK:STDOUT: %.loc15_19.6: type = converted %.loc15_19.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  131. // CHECK:STDOUT: %b.var: ref %tuple.type.2 = var b
  132. // CHECK:STDOUT: %b: ref %tuple.type.2 = bind_name b, %b.var
  133. // CHECK:STDOUT: %.loc15_24: Core.IntLiteral = int_value 1 [template = constants.%.31]
  134. // CHECK:STDOUT: %.loc15_27: Core.IntLiteral = int_value 2 [template = constants.%.32]
  135. // CHECK:STDOUT: %.loc15_28.1: %tuple.type.3 = tuple_literal (%.loc15_24, %.loc15_27)
  136. // CHECK:STDOUT: %.loc15_28.2: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  137. // CHECK:STDOUT: %.loc15_28.3: <bound method> = bound_method %.loc15_24, %.loc15_28.2 [template = constants.%.33]
  138. // CHECK:STDOUT: %.loc15_28.4: <specific function> = specific_function %.loc15_28.3, @Convert.2(constants.%.1) [template = constants.%.34]
  139. // CHECK:STDOUT: %int.convert_checked.loc15_28.1: init %i32 = call %.loc15_28.4(%.loc15_24) [template = constants.%.35]
  140. // CHECK:STDOUT: %.loc15_28.5: init %i32 = converted %.loc15_24, %int.convert_checked.loc15_28.1 [template = constants.%.35]
  141. // CHECK:STDOUT: %.loc15_28.6: ref %i32 = tuple_access %b.var, element0
  142. // CHECK:STDOUT: %.loc15_28.7: init %i32 = initialize_from %.loc15_28.5 to %.loc15_28.6 [template = constants.%.35]
  143. // CHECK:STDOUT: %.loc15_28.8: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  144. // CHECK:STDOUT: %.loc15_28.9: <bound method> = bound_method %.loc15_27, %.loc15_28.8 [template = constants.%.36]
  145. // CHECK:STDOUT: %.loc15_28.10: <specific function> = specific_function %.loc15_28.9, @Convert.2(constants.%.1) [template = constants.%.37]
  146. // CHECK:STDOUT: %int.convert_checked.loc15_28.2: init %i32 = call %.loc15_28.10(%.loc15_27) [template = constants.%.38]
  147. // CHECK:STDOUT: %.loc15_28.11: init %i32 = converted %.loc15_27, %int.convert_checked.loc15_28.2 [template = constants.%.38]
  148. // CHECK:STDOUT: %.loc15_28.12: ref %i32 = tuple_access %b.var, element1
  149. // CHECK:STDOUT: %.loc15_28.13: init %i32 = initialize_from %.loc15_28.11 to %.loc15_28.12 [template = constants.%.38]
  150. // CHECK:STDOUT: %.loc15_28.14: init %tuple.type.2 = tuple_init (%.loc15_28.7, %.loc15_28.13) to %b.var [template = constants.%tuple]
  151. // CHECK:STDOUT: %.loc15_29: init %tuple.type.2 = converted %.loc15_28.1, %.loc15_28.14 [template = constants.%tuple]
  152. // CHECK:STDOUT: assign %b.var, %.loc15_29
  153. // CHECK:STDOUT: %b.ref.loc16: ref %tuple.type.2 = name_ref b, %b
  154. // CHECK:STDOUT: %.loc16_5: Core.IntLiteral = int_value 0 [template = constants.%.39]
  155. // CHECK:STDOUT: %.loc16_4: ref %i32 = tuple_access %b.ref.loc16, element0
  156. // CHECK:STDOUT: %.loc16_9: Core.IntLiteral = int_value 3 [template = constants.%.40]
  157. // CHECK:STDOUT: %.loc16_7.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  158. // CHECK:STDOUT: %.loc16_7.2: <bound method> = bound_method %.loc16_9, %.loc16_7.1 [template = constants.%.41]
  159. // CHECK:STDOUT: %.loc16_7.3: <specific function> = specific_function %.loc16_7.2, @Convert.2(constants.%.1) [template = constants.%.42]
  160. // CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %.loc16_7.3(%.loc16_9) [template = constants.%.43]
  161. // CHECK:STDOUT: %.loc16_7.4: init %i32 = converted %.loc16_9, %int.convert_checked.loc16 [template = constants.%.43]
  162. // CHECK:STDOUT: assign %.loc16_4, %.loc16_7.4
  163. // CHECK:STDOUT: %b.ref.loc17: ref %tuple.type.2 = name_ref b, %b
  164. // CHECK:STDOUT: %.loc17_5: Core.IntLiteral = int_value 1 [template = constants.%.31]
  165. // CHECK:STDOUT: %.loc17_4: ref %i32 = tuple_access %b.ref.loc17, element1
  166. // CHECK:STDOUT: %.loc17_9: Core.IntLiteral = int_value 4 [template = constants.%.44]
  167. // CHECK:STDOUT: %.loc17_7.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  168. // CHECK:STDOUT: %.loc17_7.2: <bound method> = bound_method %.loc17_9, %.loc17_7.1 [template = constants.%.45]
  169. // CHECK:STDOUT: %.loc17_7.3: <specific function> = specific_function %.loc17_7.2, @Convert.2(constants.%.1) [template = constants.%.46]
  170. // CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %.loc17_7.3(%.loc17_9) [template = constants.%.47]
  171. // CHECK:STDOUT: %.loc17_7.4: init %i32 = converted %.loc17_9, %int.convert_checked.loc17 [template = constants.%.47]
  172. // CHECK:STDOUT: assign %.loc17_4, %.loc17_7.4
  173. // CHECK:STDOUT: %.loc19_15.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  174. // CHECK:STDOUT: %int.make_type_signed.loc19_15: init type = call constants.%Int(%.loc19_15.1) [template = constants.%i32]
  175. // CHECK:STDOUT: %.loc19_15.2: type = value_of_initializer %int.make_type_signed.loc19_15 [template = constants.%i32]
  176. // CHECK:STDOUT: %.loc19_15.3: type = converted %int.make_type_signed.loc19_15, %.loc19_15.2 [template = constants.%i32]
  177. // CHECK:STDOUT: %.loc19_24.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  178. // CHECK:STDOUT: %int.make_type_signed.loc19_24: init type = call constants.%Int(%.loc19_24.1) [template = constants.%i32]
  179. // CHECK:STDOUT: %.loc19_24.2: type = value_of_initializer %int.make_type_signed.loc19_24 [template = constants.%i32]
  180. // CHECK:STDOUT: %.loc19_24.3: type = converted %int.make_type_signed.loc19_24, %.loc19_24.2 [template = constants.%i32]
  181. // CHECK:STDOUT: %.loc19_27: type = struct_type {.a: %i32, .b: %i32} [template = constants.%.48]
  182. // CHECK:STDOUT: %c.var: ref %.48 = var c
  183. // CHECK:STDOUT: %c: ref %.48 = bind_name c, %c.var
  184. // CHECK:STDOUT: %.loc19_37: Core.IntLiteral = int_value 1 [template = constants.%.31]
  185. // CHECK:STDOUT: %.loc19_45: Core.IntLiteral = int_value 2 [template = constants.%.32]
  186. // CHECK:STDOUT: %.loc19_46.1: %.50 = struct_literal (%.loc19_37, %.loc19_45)
  187. // CHECK:STDOUT: %.loc19_46.2: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  188. // CHECK:STDOUT: %.loc19_46.3: <bound method> = bound_method %.loc19_37, %.loc19_46.2 [template = constants.%.33]
  189. // CHECK:STDOUT: %.loc19_46.4: <specific function> = specific_function %.loc19_46.3, @Convert.2(constants.%.1) [template = constants.%.34]
  190. // CHECK:STDOUT: %int.convert_checked.loc19_46.1: init %i32 = call %.loc19_46.4(%.loc19_37) [template = constants.%.35]
  191. // CHECK:STDOUT: %.loc19_46.5: init %i32 = converted %.loc19_37, %int.convert_checked.loc19_46.1 [template = constants.%.35]
  192. // CHECK:STDOUT: %.loc19_46.6: ref %i32 = struct_access %c.var, element0
  193. // CHECK:STDOUT: %.loc19_46.7: init %i32 = initialize_from %.loc19_46.5 to %.loc19_46.6 [template = constants.%.35]
  194. // CHECK:STDOUT: %.loc19_46.8: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  195. // CHECK:STDOUT: %.loc19_46.9: <bound method> = bound_method %.loc19_45, %.loc19_46.8 [template = constants.%.36]
  196. // CHECK:STDOUT: %.loc19_46.10: <specific function> = specific_function %.loc19_46.9, @Convert.2(constants.%.1) [template = constants.%.37]
  197. // CHECK:STDOUT: %int.convert_checked.loc19_46.2: init %i32 = call %.loc19_46.10(%.loc19_45) [template = constants.%.38]
  198. // CHECK:STDOUT: %.loc19_46.11: init %i32 = converted %.loc19_45, %int.convert_checked.loc19_46.2 [template = constants.%.38]
  199. // CHECK:STDOUT: %.loc19_46.12: ref %i32 = struct_access %c.var, element1
  200. // CHECK:STDOUT: %.loc19_46.13: init %i32 = initialize_from %.loc19_46.11 to %.loc19_46.12 [template = constants.%.38]
  201. // CHECK:STDOUT: %.loc19_46.14: init %.48 = struct_init (%.loc19_46.7, %.loc19_46.13) to %c.var [template = constants.%struct]
  202. // CHECK:STDOUT: %.loc19_47: init %.48 = converted %.loc19_46.1, %.loc19_46.14 [template = constants.%struct]
  203. // CHECK:STDOUT: assign %c.var, %.loc19_47
  204. // CHECK:STDOUT: %c.ref.loc20: ref %.48 = name_ref c, %c
  205. // CHECK:STDOUT: %.loc20_4: ref %i32 = struct_access %c.ref.loc20, element0
  206. // CHECK:STDOUT: %.loc20_9: Core.IntLiteral = int_value 3 [template = constants.%.40]
  207. // CHECK:STDOUT: %.loc20_7.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  208. // CHECK:STDOUT: %.loc20_7.2: <bound method> = bound_method %.loc20_9, %.loc20_7.1 [template = constants.%.41]
  209. // CHECK:STDOUT: %.loc20_7.3: <specific function> = specific_function %.loc20_7.2, @Convert.2(constants.%.1) [template = constants.%.42]
  210. // CHECK:STDOUT: %int.convert_checked.loc20: init %i32 = call %.loc20_7.3(%.loc20_9) [template = constants.%.43]
  211. // CHECK:STDOUT: %.loc20_7.4: init %i32 = converted %.loc20_9, %int.convert_checked.loc20 [template = constants.%.43]
  212. // CHECK:STDOUT: assign %.loc20_4, %.loc20_7.4
  213. // CHECK:STDOUT: %c.ref.loc21: ref %.48 = name_ref c, %c
  214. // CHECK:STDOUT: %.loc21_4: ref %i32 = struct_access %c.ref.loc21, element1
  215. // CHECK:STDOUT: %.loc21_9: Core.IntLiteral = int_value 4 [template = constants.%.44]
  216. // CHECK:STDOUT: %.loc21_7.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  217. // CHECK:STDOUT: %.loc21_7.2: <bound method> = bound_method %.loc21_9, %.loc21_7.1 [template = constants.%.45]
  218. // CHECK:STDOUT: %.loc21_7.3: <specific function> = specific_function %.loc21_7.2, @Convert.2(constants.%.1) [template = constants.%.46]
  219. // CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %.loc21_7.3(%.loc21_9) [template = constants.%.47]
  220. // CHECK:STDOUT: %.loc21_7.4: init %i32 = converted %.loc21_9, %int.convert_checked.loc21 [template = constants.%.47]
  221. // CHECK:STDOUT: assign %.loc21_4, %.loc21_7.4
  222. // CHECK:STDOUT: %.loc23_10: Core.IntLiteral = int_value 32 [template = constants.%.1]
  223. // CHECK:STDOUT: %int.make_type_signed.loc23: init type = call constants.%Int(%.loc23_10) [template = constants.%i32]
  224. // CHECK:STDOUT: %.loc23_13.1: type = value_of_initializer %int.make_type_signed.loc23 [template = constants.%i32]
  225. // CHECK:STDOUT: %.loc23_13.2: type = converted %int.make_type_signed.loc23, %.loc23_13.1 [template = constants.%i32]
  226. // CHECK:STDOUT: %.loc23_13.3: type = ptr_type %i32 [template = constants.%.51]
  227. // CHECK:STDOUT: %p.var: ref %.51 = var p
  228. // CHECK:STDOUT: %p: ref %.51 = bind_name p, %p.var
  229. // CHECK:STDOUT: %a.ref.loc23: ref %i32 = name_ref a, %a
  230. // CHECK:STDOUT: %.loc23_17: %.51 = addr_of %a.ref.loc23
  231. // CHECK:STDOUT: assign %p.var, %.loc23_17
  232. // CHECK:STDOUT: %p.ref.loc24: ref %.51 = name_ref p, %p
  233. // CHECK:STDOUT: %.loc24_4: %.51 = bind_value %p.ref.loc24
  234. // CHECK:STDOUT: %.loc24_3: ref %i32 = deref %.loc24_4
  235. // CHECK:STDOUT: %.loc24_8: Core.IntLiteral = int_value 5 [template = constants.%.52]
  236. // CHECK:STDOUT: %.loc24_6.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  237. // CHECK:STDOUT: %.loc24_6.2: <bound method> = bound_method %.loc24_8, %.loc24_6.1 [template = constants.%.53]
  238. // CHECK:STDOUT: %.loc24_6.3: <specific function> = specific_function %.loc24_6.2, @Convert.2(constants.%.1) [template = constants.%.54]
  239. // CHECK:STDOUT: %int.convert_checked.loc24: init %i32 = call %.loc24_6.3(%.loc24_8) [template = constants.%.55]
  240. // CHECK:STDOUT: %.loc24_6.4: init %i32 = converted %.loc24_8, %int.convert_checked.loc24 [template = constants.%.55]
  241. // CHECK:STDOUT: assign %.loc24_3, %.loc24_6.4
  242. // CHECK:STDOUT: %.loc26_8: bool = bool_literal true [template = constants.%.56]
  243. // CHECK:STDOUT: if %.loc26_8 br !if.expr.then else br !if.expr.else
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: !if.expr.then:
  246. // CHECK:STDOUT: %p.ref.loc26: ref %.51 = name_ref p, %p
  247. // CHECK:STDOUT: %.loc26_18: %.51 = bind_value %p.ref.loc26
  248. // CHECK:STDOUT: br !if.expr.result(%.loc26_18)
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: !if.expr.else:
  251. // CHECK:STDOUT: %a.ref.loc26: ref %i32 = name_ref a, %a
  252. // CHECK:STDOUT: %.loc26_25: %.51 = addr_of %a.ref.loc26
  253. // CHECK:STDOUT: br !if.expr.result(%.loc26_25)
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: !if.expr.result:
  256. // CHECK:STDOUT: %.loc26_5: %.51 = block_arg !if.expr.result
  257. // CHECK:STDOUT: %.loc26_3: ref %i32 = deref %.loc26_5
  258. // CHECK:STDOUT: %.loc26_31: Core.IntLiteral = int_value 10 [template = constants.%.57]
  259. // CHECK:STDOUT: %.loc26_29.1: %Convert.type.2 = interface_witness_access constants.%.22, element0 [template = constants.%Convert.14]
  260. // CHECK:STDOUT: %.loc26_29.2: <bound method> = bound_method %.loc26_31, %.loc26_29.1 [template = constants.%.58]
  261. // CHECK:STDOUT: %.loc26_29.3: <specific function> = specific_function %.loc26_29.2, @Convert.2(constants.%.1) [template = constants.%.59]
  262. // CHECK:STDOUT: %int.convert_checked.loc26: init %i32 = call %.loc26_29.3(%.loc26_31) [template = constants.%.60]
  263. // CHECK:STDOUT: %.loc26_29.4: init %i32 = converted %.loc26_31, %int.convert_checked.loc26 [template = constants.%.60]
  264. // CHECK:STDOUT: assign %.loc26_3, %.loc26_29.4
  265. // CHECK:STDOUT: return
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT: