assignment.carbon 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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: %int_32: Core.IntLiteral = int_value 32 [template]
  29. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  30. // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [template]
  31. // CHECK:STDOUT: %Convert.type.cd1: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  32. // CHECK:STDOUT: %impl_witness.5b0: <witness> = impl_witness (imports.%import_ref.723), @impl.1(%int_32) [template]
  33. // CHECK:STDOUT: %Convert.type.466: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  34. // CHECK:STDOUT: %Convert.925: %Convert.type.466 = struct_value () [template]
  35. // CHECK:STDOUT: %Convert.bound.8aa: <bound method> = bound_method %int_12.6a3, %Convert.925 [template]
  36. // CHECK:STDOUT: %Convert.specific_fn.545: <specific function> = specific_function %Convert.bound.8aa, @Convert.2(%int_32) [template]
  37. // CHECK:STDOUT: %int_12.43d: %i32 = int_value 12 [template]
  38. // CHECK:STDOUT: %int_9.988: Core.IntLiteral = int_value 9 [template]
  39. // CHECK:STDOUT: %Convert.bound.cc8: <bound method> = bound_method %int_9.988, %Convert.925 [template]
  40. // CHECK:STDOUT: %Convert.specific_fn.b8b: <specific function> = specific_function %Convert.bound.cc8, @Convert.2(%int_32) [template]
  41. // CHECK:STDOUT: %int_9.82c: %i32 = int_value 9 [template]
  42. // CHECK:STDOUT: %tuple.type.471: type = tuple_type (%i32, %i32) [template]
  43. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  44. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template]
  45. // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template]
  46. // CHECK:STDOUT: %Convert.bound.afd: <bound method> = bound_method %int_1.5b8, %Convert.925 [template]
  47. // CHECK:STDOUT: %Convert.specific_fn.b73: <specific function> = specific_function %Convert.bound.afd, @Convert.2(%int_32) [template]
  48. // CHECK:STDOUT: %int_1.c60: %i32 = int_value 1 [template]
  49. // CHECK:STDOUT: %Convert.bound.f0b: <bound method> = bound_method %int_2.ecc, %Convert.925 [template]
  50. // CHECK:STDOUT: %Convert.specific_fn.20e: <specific function> = specific_function %Convert.bound.f0b, @Convert.2(%int_32) [template]
  51. // CHECK:STDOUT: %int_2.166: %i32 = int_value 2 [template]
  52. // CHECK:STDOUT: %tuple: %tuple.type.471 = tuple_value (%int_1.c60, %int_2.166) [template]
  53. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  54. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  55. // CHECK:STDOUT: %Convert.bound.0db: <bound method> = bound_method %int_3.1ba, %Convert.925 [template]
  56. // CHECK:STDOUT: %Convert.specific_fn.456: <specific function> = specific_function %Convert.bound.0db, @Convert.2(%int_32) [template]
  57. // CHECK:STDOUT: %int_3.25b: %i32 = int_value 3 [template]
  58. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template]
  59. // CHECK:STDOUT: %Convert.bound.fe5: <bound method> = bound_method %int_4.0c1, %Convert.925 [template]
  60. // CHECK:STDOUT: %Convert.specific_fn.c6f: <specific function> = specific_function %Convert.bound.fe5, @Convert.2(%int_32) [template]
  61. // CHECK:STDOUT: %int_4.2ec: %i32 = int_value 4 [template]
  62. // CHECK:STDOUT: %struct_type.a.b.3de: type = struct_type {.a: %i32, .b: %i32} [template]
  63. // CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [template]
  64. // CHECK:STDOUT: %struct: %struct_type.a.b.3de = struct_value (%int_1.c60, %int_2.166) [template]
  65. // CHECK:STDOUT: %ptr.dc3: type = ptr_type %i32 [template]
  66. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [template]
  67. // CHECK:STDOUT: %Convert.bound.b33: <bound method> = bound_method %int_5.64b, %Convert.925 [template]
  68. // CHECK:STDOUT: %Convert.specific_fn.89d: <specific function> = specific_function %Convert.bound.b33, @Convert.2(%int_32) [template]
  69. // CHECK:STDOUT: %int_5.70b: %i32 = int_value 5 [template]
  70. // CHECK:STDOUT: %true: bool = bool_literal true [template]
  71. // CHECK:STDOUT: %int_10.64f: Core.IntLiteral = int_value 10 [template]
  72. // CHECK:STDOUT: %Convert.bound.d24: <bound method> = bound_method %int_10.64f, %Convert.925 [template]
  73. // CHECK:STDOUT: %Convert.specific_fn.970: <specific function> = specific_function %Convert.bound.d24, @Convert.2(%int_32) [template]
  74. // CHECK:STDOUT: %int_10.55a: %i32 = int_value 10 [template]
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: imports {
  78. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  79. // CHECK:STDOUT: .Int = %import_ref.187
  80. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  81. // CHECK:STDOUT: import Core//prelude
  82. // CHECK:STDOUT: import Core//prelude/...
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: file {
  87. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  88. // CHECK:STDOUT: .Core = imports.%Core
  89. // CHECK:STDOUT: .Main = %Main.decl
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: %Core.import = import Core
  92. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: fn @Main() {
  96. // CHECK:STDOUT: !entry:
  97. // CHECK:STDOUT: %a.var: ref %i32 = var a
  98. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  99. // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [template = constants.%int_12.6a3]
  100. // CHECK:STDOUT: %impl.elem0.loc12: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  101. // CHECK:STDOUT: %Convert.bound.loc12: <bound method> = bound_method %int_12, %impl.elem0.loc12 [template = constants.%Convert.bound.8aa]
  102. // CHECK:STDOUT: %Convert.specific_fn.loc12: <specific function> = specific_function %Convert.bound.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.545]
  103. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %Convert.specific_fn.loc12(%int_12) [template = constants.%int_12.43d]
  104. // CHECK:STDOUT: %.loc12: init %i32 = converted %int_12, %int.convert_checked.loc12 [template = constants.%int_12.43d]
  105. // CHECK:STDOUT: assign %a.var, %.loc12
  106. // CHECK:STDOUT: %a.ref.loc13: ref %i32 = name_ref a, %a
  107. // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [template = constants.%int_9.988]
  108. // CHECK:STDOUT: %impl.elem0.loc13: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  109. // CHECK:STDOUT: %Convert.bound.loc13: <bound method> = bound_method %int_9, %impl.elem0.loc13 [template = constants.%Convert.bound.cc8]
  110. // CHECK:STDOUT: %Convert.specific_fn.loc13: <specific function> = specific_function %Convert.bound.loc13, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b8b]
  111. // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %Convert.specific_fn.loc13(%int_9) [template = constants.%int_9.82c]
  112. // CHECK:STDOUT: %.loc13: init %i32 = converted %int_9, %int.convert_checked.loc13 [template = constants.%int_9.82c]
  113. // CHECK:STDOUT: assign %a.ref.loc13, %.loc13
  114. // CHECK:STDOUT: %b.var: ref %tuple.type.471 = var b
  115. // CHECK:STDOUT: %b: ref %tuple.type.471 = bind_name b, %b.var
  116. // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  117. // CHECK:STDOUT: %int_2.loc15: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  118. // CHECK:STDOUT: %.loc15_28.1: %tuple.type.f94 = tuple_literal (%int_1.loc15, %int_2.loc15)
  119. // CHECK:STDOUT: %impl.elem0.loc15_28.1: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  120. // CHECK:STDOUT: %Convert.bound.loc15_28.1: <bound method> = bound_method %int_1.loc15, %impl.elem0.loc15_28.1 [template = constants.%Convert.bound.afd]
  121. // CHECK:STDOUT: %Convert.specific_fn.loc15_28.1: <specific function> = specific_function %Convert.bound.loc15_28.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b73]
  122. // CHECK:STDOUT: %int.convert_checked.loc15_28.1: init %i32 = call %Convert.specific_fn.loc15_28.1(%int_1.loc15) [template = constants.%int_1.c60]
  123. // CHECK:STDOUT: %.loc15_28.2: init %i32 = converted %int_1.loc15, %int.convert_checked.loc15_28.1 [template = constants.%int_1.c60]
  124. // CHECK:STDOUT: %tuple.elem0.loc15: ref %i32 = tuple_access %b.var, element0
  125. // CHECK:STDOUT: %.loc15_28.3: init %i32 = initialize_from %.loc15_28.2 to %tuple.elem0.loc15 [template = constants.%int_1.c60]
  126. // CHECK:STDOUT: %impl.elem0.loc15_28.2: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  127. // CHECK:STDOUT: %Convert.bound.loc15_28.2: <bound method> = bound_method %int_2.loc15, %impl.elem0.loc15_28.2 [template = constants.%Convert.bound.f0b]
  128. // CHECK:STDOUT: %Convert.specific_fn.loc15_28.2: <specific function> = specific_function %Convert.bound.loc15_28.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.20e]
  129. // CHECK:STDOUT: %int.convert_checked.loc15_28.2: init %i32 = call %Convert.specific_fn.loc15_28.2(%int_2.loc15) [template = constants.%int_2.166]
  130. // CHECK:STDOUT: %.loc15_28.4: init %i32 = converted %int_2.loc15, %int.convert_checked.loc15_28.2 [template = constants.%int_2.166]
  131. // CHECK:STDOUT: %tuple.elem1.loc15: ref %i32 = tuple_access %b.var, element1
  132. // CHECK:STDOUT: %.loc15_28.5: init %i32 = initialize_from %.loc15_28.4 to %tuple.elem1.loc15 [template = constants.%int_2.166]
  133. // CHECK:STDOUT: %.loc15_28.6: init %tuple.type.471 = tuple_init (%.loc15_28.3, %.loc15_28.5) to %b.var [template = constants.%tuple]
  134. // CHECK:STDOUT: %.loc15_29: init %tuple.type.471 = converted %.loc15_28.1, %.loc15_28.6 [template = constants.%tuple]
  135. // CHECK:STDOUT: assign %b.var, %.loc15_29
  136. // CHECK:STDOUT: %b.ref.loc16: ref %tuple.type.471 = name_ref b, %b
  137. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  138. // CHECK:STDOUT: %tuple.elem0.loc16: ref %i32 = tuple_access %b.ref.loc16, element0
  139. // CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  140. // CHECK:STDOUT: %impl.elem0.loc16: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  141. // CHECK:STDOUT: %Convert.bound.loc16: <bound method> = bound_method %int_3.loc16, %impl.elem0.loc16 [template = constants.%Convert.bound.0db]
  142. // CHECK:STDOUT: %Convert.specific_fn.loc16: <specific function> = specific_function %Convert.bound.loc16, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.456]
  143. // CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %Convert.specific_fn.loc16(%int_3.loc16) [template = constants.%int_3.25b]
  144. // CHECK:STDOUT: %.loc16: init %i32 = converted %int_3.loc16, %int.convert_checked.loc16 [template = constants.%int_3.25b]
  145. // CHECK:STDOUT: assign %tuple.elem0.loc16, %.loc16
  146. // CHECK:STDOUT: %b.ref.loc17: ref %tuple.type.471 = name_ref b, %b
  147. // CHECK:STDOUT: %int_1.loc17: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  148. // CHECK:STDOUT: %tuple.elem1.loc17: ref %i32 = tuple_access %b.ref.loc17, element1
  149. // CHECK:STDOUT: %int_4.loc17: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  150. // CHECK:STDOUT: %impl.elem0.loc17: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  151. // CHECK:STDOUT: %Convert.bound.loc17: <bound method> = bound_method %int_4.loc17, %impl.elem0.loc17 [template = constants.%Convert.bound.fe5]
  152. // CHECK:STDOUT: %Convert.specific_fn.loc17: <specific function> = specific_function %Convert.bound.loc17, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.c6f]
  153. // CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %Convert.specific_fn.loc17(%int_4.loc17) [template = constants.%int_4.2ec]
  154. // CHECK:STDOUT: %.loc17: init %i32 = converted %int_4.loc17, %int.convert_checked.loc17 [template = constants.%int_4.2ec]
  155. // CHECK:STDOUT: assign %tuple.elem1.loc17, %.loc17
  156. // CHECK:STDOUT: %c.var: ref %struct_type.a.b.3de = var c
  157. // CHECK:STDOUT: %c: ref %struct_type.a.b.3de = bind_name c, %c.var
  158. // CHECK:STDOUT: %int_1.loc19: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  159. // CHECK:STDOUT: %int_2.loc19: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  160. // CHECK:STDOUT: %.loc19_46.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc19, %int_2.loc19)
  161. // CHECK:STDOUT: %impl.elem0.loc19_46.1: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  162. // CHECK:STDOUT: %Convert.bound.loc19_46.1: <bound method> = bound_method %int_1.loc19, %impl.elem0.loc19_46.1 [template = constants.%Convert.bound.afd]
  163. // CHECK:STDOUT: %Convert.specific_fn.loc19_46.1: <specific function> = specific_function %Convert.bound.loc19_46.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b73]
  164. // CHECK:STDOUT: %int.convert_checked.loc19_46.1: init %i32 = call %Convert.specific_fn.loc19_46.1(%int_1.loc19) [template = constants.%int_1.c60]
  165. // CHECK:STDOUT: %.loc19_46.2: init %i32 = converted %int_1.loc19, %int.convert_checked.loc19_46.1 [template = constants.%int_1.c60]
  166. // CHECK:STDOUT: %.loc19_46.3: ref %i32 = struct_access %c.var, element0
  167. // CHECK:STDOUT: %.loc19_46.4: init %i32 = initialize_from %.loc19_46.2 to %.loc19_46.3 [template = constants.%int_1.c60]
  168. // CHECK:STDOUT: %impl.elem0.loc19_46.2: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  169. // CHECK:STDOUT: %Convert.bound.loc19_46.2: <bound method> = bound_method %int_2.loc19, %impl.elem0.loc19_46.2 [template = constants.%Convert.bound.f0b]
  170. // CHECK:STDOUT: %Convert.specific_fn.loc19_46.2: <specific function> = specific_function %Convert.bound.loc19_46.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.20e]
  171. // CHECK:STDOUT: %int.convert_checked.loc19_46.2: init %i32 = call %Convert.specific_fn.loc19_46.2(%int_2.loc19) [template = constants.%int_2.166]
  172. // CHECK:STDOUT: %.loc19_46.5: init %i32 = converted %int_2.loc19, %int.convert_checked.loc19_46.2 [template = constants.%int_2.166]
  173. // CHECK:STDOUT: %.loc19_46.6: ref %i32 = struct_access %c.var, element1
  174. // CHECK:STDOUT: %.loc19_46.7: init %i32 = initialize_from %.loc19_46.5 to %.loc19_46.6 [template = constants.%int_2.166]
  175. // CHECK:STDOUT: %.loc19_46.8: init %struct_type.a.b.3de = struct_init (%.loc19_46.4, %.loc19_46.7) to %c.var [template = constants.%struct]
  176. // CHECK:STDOUT: %.loc19_47: init %struct_type.a.b.3de = converted %.loc19_46.1, %.loc19_46.8 [template = constants.%struct]
  177. // CHECK:STDOUT: assign %c.var, %.loc19_47
  178. // CHECK:STDOUT: %c.ref.loc20: ref %struct_type.a.b.3de = name_ref c, %c
  179. // CHECK:STDOUT: %.loc20_4: ref %i32 = struct_access %c.ref.loc20, element0
  180. // CHECK:STDOUT: %int_3.loc20: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  181. // CHECK:STDOUT: %impl.elem0.loc20: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  182. // CHECK:STDOUT: %Convert.bound.loc20: <bound method> = bound_method %int_3.loc20, %impl.elem0.loc20 [template = constants.%Convert.bound.0db]
  183. // CHECK:STDOUT: %Convert.specific_fn.loc20: <specific function> = specific_function %Convert.bound.loc20, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.456]
  184. // CHECK:STDOUT: %int.convert_checked.loc20: init %i32 = call %Convert.specific_fn.loc20(%int_3.loc20) [template = constants.%int_3.25b]
  185. // CHECK:STDOUT: %.loc20_7: init %i32 = converted %int_3.loc20, %int.convert_checked.loc20 [template = constants.%int_3.25b]
  186. // CHECK:STDOUT: assign %.loc20_4, %.loc20_7
  187. // CHECK:STDOUT: %c.ref.loc21: ref %struct_type.a.b.3de = name_ref c, %c
  188. // CHECK:STDOUT: %.loc21_4: ref %i32 = struct_access %c.ref.loc21, element1
  189. // CHECK:STDOUT: %int_4.loc21: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  190. // CHECK:STDOUT: %impl.elem0.loc21: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  191. // CHECK:STDOUT: %Convert.bound.loc21: <bound method> = bound_method %int_4.loc21, %impl.elem0.loc21 [template = constants.%Convert.bound.fe5]
  192. // CHECK:STDOUT: %Convert.specific_fn.loc21: <specific function> = specific_function %Convert.bound.loc21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.c6f]
  193. // CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %Convert.specific_fn.loc21(%int_4.loc21) [template = constants.%int_4.2ec]
  194. // CHECK:STDOUT: %.loc21_7: init %i32 = converted %int_4.loc21, %int.convert_checked.loc21 [template = constants.%int_4.2ec]
  195. // CHECK:STDOUT: assign %.loc21_4, %.loc21_7
  196. // CHECK:STDOUT: %p.var: ref %ptr.dc3 = var p
  197. // CHECK:STDOUT: %p: ref %ptr.dc3 = bind_name p, %p.var
  198. // CHECK:STDOUT: %a.ref.loc23: ref %i32 = name_ref a, %a
  199. // CHECK:STDOUT: %addr.loc23: %ptr.dc3 = addr_of %a.ref.loc23
  200. // CHECK:STDOUT: assign %p.var, %addr.loc23
  201. // CHECK:STDOUT: %p.ref.loc24: ref %ptr.dc3 = name_ref p, %p
  202. // CHECK:STDOUT: %.loc24_4: %ptr.dc3 = bind_value %p.ref.loc24
  203. // CHECK:STDOUT: %.loc24_3: ref %i32 = deref %.loc24_4
  204. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b]
  205. // CHECK:STDOUT: %impl.elem0.loc24: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  206. // CHECK:STDOUT: %Convert.bound.loc24: <bound method> = bound_method %int_5, %impl.elem0.loc24 [template = constants.%Convert.bound.b33]
  207. // CHECK:STDOUT: %Convert.specific_fn.loc24: <specific function> = specific_function %Convert.bound.loc24, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.89d]
  208. // CHECK:STDOUT: %int.convert_checked.loc24: init %i32 = call %Convert.specific_fn.loc24(%int_5) [template = constants.%int_5.70b]
  209. // CHECK:STDOUT: %.loc24_6: init %i32 = converted %int_5, %int.convert_checked.loc24 [template = constants.%int_5.70b]
  210. // CHECK:STDOUT: assign %.loc24_3, %.loc24_6
  211. // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true]
  212. // CHECK:STDOUT: if %true br !if.expr.then else br !if.expr.else
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: !if.expr.then:
  215. // CHECK:STDOUT: %p.ref.loc26: ref %ptr.dc3 = name_ref p, %p
  216. // CHECK:STDOUT: %.loc26_18: %ptr.dc3 = bind_value %p.ref.loc26
  217. // CHECK:STDOUT: br !if.expr.result(%.loc26_18)
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: !if.expr.else:
  220. // CHECK:STDOUT: %a.ref.loc26: ref %i32 = name_ref a, %a
  221. // CHECK:STDOUT: %addr.loc26: %ptr.dc3 = addr_of %a.ref.loc26
  222. // CHECK:STDOUT: br !if.expr.result(%addr.loc26)
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: !if.expr.result:
  225. // CHECK:STDOUT: %.loc26_5: %ptr.dc3 = block_arg !if.expr.result
  226. // CHECK:STDOUT: %.loc26_3: ref %i32 = deref %.loc26_5
  227. // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [template = constants.%int_10.64f]
  228. // CHECK:STDOUT: %impl.elem0.loc26: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  229. // CHECK:STDOUT: %Convert.bound.loc26: <bound method> = bound_method %int_10, %impl.elem0.loc26 [template = constants.%Convert.bound.d24]
  230. // CHECK:STDOUT: %Convert.specific_fn.loc26: <specific function> = specific_function %Convert.bound.loc26, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.970]
  231. // CHECK:STDOUT: %int.convert_checked.loc26: init %i32 = call %Convert.specific_fn.loc26(%int_10) [template = constants.%int_10.55a]
  232. // CHECK:STDOUT: %.loc26_29: init %i32 = converted %int_10, %int.convert_checked.loc26 [template = constants.%int_10.55a]
  233. // CHECK:STDOUT: assign %.loc26_3, %.loc26_29
  234. // CHECK:STDOUT: return
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT: