assignment.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  32. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  33. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  34. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  35. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  36. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  37. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  38. // CHECK:STDOUT: %Convert.bound.221: <bound method> = bound_method %int_12.6a3, %Convert.956 [template]
  39. // CHECK:STDOUT: %Convert.specific_fn.9a9: <specific function> = specific_function %Convert.bound.221, @Convert.2(%int_32) [template]
  40. // CHECK:STDOUT: %int_12.1e1: %i32 = int_value 12 [template]
  41. // CHECK:STDOUT: %int_9.988: Core.IntLiteral = int_value 9 [template]
  42. // CHECK:STDOUT: %Convert.bound.9e2: <bound method> = bound_method %int_9.988, %Convert.956 [template]
  43. // CHECK:STDOUT: %Convert.specific_fn.b02: <specific function> = specific_function %Convert.bound.9e2, @Convert.2(%int_32) [template]
  44. // CHECK:STDOUT: %int_9.f88: %i32 = int_value 9 [template]
  45. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
  46. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template]
  47. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  48. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template]
  49. // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template]
  50. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  51. // CHECK:STDOUT: %Convert.specific_fn.70c: <specific function> = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template]
  52. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  53. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [template]
  54. // CHECK:STDOUT: %Convert.specific_fn.787: <specific function> = specific_function %Convert.bound.ef9, @Convert.2(%int_32) [template]
  55. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template]
  56. // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_1.5d2, %int_2.ef8) [template]
  57. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  58. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  59. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [template]
  60. // CHECK:STDOUT: %Convert.specific_fn.b42: <specific function> = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template]
  61. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template]
  62. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template]
  63. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [template]
  64. // CHECK:STDOUT: %Convert.specific_fn.450: <specific function> = specific_function %Convert.bound.ac3, @Convert.2(%int_32) [template]
  65. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [template]
  66. // CHECK:STDOUT: %struct_type.a.b.501: type = struct_type {.a: %i32, .b: %i32} [template]
  67. // CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [template]
  68. // CHECK:STDOUT: %struct: %struct_type.a.b.501 = struct_value (%int_1.5d2, %int_2.ef8) [template]
  69. // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [template]
  70. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [template]
  71. // CHECK:STDOUT: %Convert.bound.4e6: <bound method> = bound_method %int_5.64b, %Convert.956 [template]
  72. // CHECK:STDOUT: %Convert.specific_fn.ba9: <specific function> = specific_function %Convert.bound.4e6, @Convert.2(%int_32) [template]
  73. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [template]
  74. // CHECK:STDOUT: %true: bool = bool_literal true [template]
  75. // CHECK:STDOUT: %int_10.64f: Core.IntLiteral = int_value 10 [template]
  76. // CHECK:STDOUT: %Convert.bound.491: <bound method> = bound_method %int_10.64f, %Convert.956 [template]
  77. // CHECK:STDOUT: %Convert.specific_fn.e67: <specific function> = specific_function %Convert.bound.491, @Convert.2(%int_32) [template]
  78. // CHECK:STDOUT: %int_10.265: %i32 = int_value 10 [template]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: imports {
  82. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  83. // CHECK:STDOUT: .Int = %Core.Int
  84. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  85. // CHECK:STDOUT: import Core//prelude
  86. // CHECK:STDOUT: import Core//prelude/...
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: file {
  91. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  92. // CHECK:STDOUT: .Core = imports.%Core
  93. // CHECK:STDOUT: .Main = %Main.decl
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: %Core.import = import Core
  96. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: fn @Main() {
  100. // CHECK:STDOUT: !entry:
  101. // CHECK:STDOUT: name_binding_decl {
  102. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  103. // CHECK:STDOUT: %.loc12_3.1: %i32 = var_pattern %a.patt
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: %a.var: ref %i32 = var a
  106. // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [template = constants.%int_12.6a3]
  107. // CHECK:STDOUT: %impl.elem0.loc12: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  108. // CHECK:STDOUT: %bound_method.loc12: <bound method> = bound_method %int_12, %impl.elem0.loc12 [template = constants.%Convert.bound.221]
  109. // CHECK:STDOUT: %specific_fn.loc12: <specific function> = specific_function %bound_method.loc12, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.9a9]
  110. // CHECK:STDOUT: %int.convert_checked.loc12: init %i32 = call %specific_fn.loc12(%int_12) [template = constants.%int_12.1e1]
  111. // CHECK:STDOUT: %.loc12_3.2: init %i32 = converted %int_12, %int.convert_checked.loc12 [template = constants.%int_12.1e1]
  112. // CHECK:STDOUT: assign %a.var, %.loc12_3.2
  113. // CHECK:STDOUT: %.loc12_10: type = splice_block %i32.loc12 [template = constants.%i32] {
  114. // CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  115. // CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  118. // CHECK:STDOUT: %a.ref.loc13: ref %i32 = name_ref a, %a
  119. // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [template = constants.%int_9.988]
  120. // CHECK:STDOUT: %impl.elem0.loc13: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  121. // CHECK:STDOUT: %bound_method.loc13: <bound method> = bound_method %int_9, %impl.elem0.loc13 [template = constants.%Convert.bound.9e2]
  122. // CHECK:STDOUT: %specific_fn.loc13: <specific function> = specific_function %bound_method.loc13, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b02]
  123. // CHECK:STDOUT: %int.convert_checked.loc13: init %i32 = call %specific_fn.loc13(%int_9) [template = constants.%int_9.f88]
  124. // CHECK:STDOUT: %.loc13: init %i32 = converted %int_9, %int.convert_checked.loc13 [template = constants.%int_9.f88]
  125. // CHECK:STDOUT: assign %a.ref.loc13, %.loc13
  126. // CHECK:STDOUT: name_binding_decl {
  127. // CHECK:STDOUT: %b.patt: %tuple.type.d07 = binding_pattern b
  128. // CHECK:STDOUT: %.loc15_3.1: %tuple.type.d07 = var_pattern %b.patt
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %b.var: ref %tuple.type.d07 = var b
  131. // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  132. // CHECK:STDOUT: %int_2.loc15: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  133. // CHECK:STDOUT: %.loc15_28.1: %tuple.type.f94 = tuple_literal (%int_1.loc15, %int_2.loc15)
  134. // CHECK:STDOUT: %impl.elem0.loc15_28.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  135. // CHECK:STDOUT: %bound_method.loc15_28.1: <bound method> = bound_method %int_1.loc15, %impl.elem0.loc15_28.1 [template = constants.%Convert.bound.ab5]
  136. // CHECK:STDOUT: %specific_fn.loc15_28.1: <specific function> = specific_function %bound_method.loc15_28.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c]
  137. // CHECK:STDOUT: %int.convert_checked.loc15_28.1: init %i32 = call %specific_fn.loc15_28.1(%int_1.loc15) [template = constants.%int_1.5d2]
  138. // CHECK:STDOUT: %.loc15_28.2: init %i32 = converted %int_1.loc15, %int.convert_checked.loc15_28.1 [template = constants.%int_1.5d2]
  139. // CHECK:STDOUT: %tuple.elem0.loc15: ref %i32 = tuple_access %b.var, element0
  140. // CHECK:STDOUT: %.loc15_28.3: init %i32 = initialize_from %.loc15_28.2 to %tuple.elem0.loc15 [template = constants.%int_1.5d2]
  141. // CHECK:STDOUT: %impl.elem0.loc15_28.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  142. // CHECK:STDOUT: %bound_method.loc15_28.2: <bound method> = bound_method %int_2.loc15, %impl.elem0.loc15_28.2 [template = constants.%Convert.bound.ef9]
  143. // CHECK:STDOUT: %specific_fn.loc15_28.2: <specific function> = specific_function %bound_method.loc15_28.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787]
  144. // CHECK:STDOUT: %int.convert_checked.loc15_28.2: init %i32 = call %specific_fn.loc15_28.2(%int_2.loc15) [template = constants.%int_2.ef8]
  145. // CHECK:STDOUT: %.loc15_28.4: init %i32 = converted %int_2.loc15, %int.convert_checked.loc15_28.2 [template = constants.%int_2.ef8]
  146. // CHECK:STDOUT: %tuple.elem1.loc15: ref %i32 = tuple_access %b.var, element1
  147. // CHECK:STDOUT: %.loc15_28.5: init %i32 = initialize_from %.loc15_28.4 to %tuple.elem1.loc15 [template = constants.%int_2.ef8]
  148. // CHECK:STDOUT: %.loc15_28.6: init %tuple.type.d07 = tuple_init (%.loc15_28.3, %.loc15_28.5) to %b.var [template = constants.%tuple]
  149. // CHECK:STDOUT: %.loc15_3.2: init %tuple.type.d07 = converted %.loc15_28.1, %.loc15_28.6 [template = constants.%tuple]
  150. // CHECK:STDOUT: assign %b.var, %.loc15_3.2
  151. // CHECK:STDOUT: %.loc15_19.1: type = splice_block %.loc15_19.3 [template = constants.%tuple.type.d07] {
  152. // CHECK:STDOUT: %int_32.loc15_11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  153. // CHECK:STDOUT: %i32.loc15_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  154. // CHECK:STDOUT: %int_32.loc15_16: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  155. // CHECK:STDOUT: %i32.loc15_16: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  156. // CHECK:STDOUT: %.loc15_19.2: %tuple.type.24b = tuple_literal (%i32.loc15_11, %i32.loc15_16)
  157. // CHECK:STDOUT: %.loc15_19.3: type = converted %.loc15_19.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07]
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: %b: ref %tuple.type.d07 = bind_name b, %b.var
  160. // CHECK:STDOUT: %b.ref.loc16: ref %tuple.type.d07 = name_ref b, %b
  161. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  162. // CHECK:STDOUT: %tuple.elem0.loc16: ref %i32 = tuple_access %b.ref.loc16, element0
  163. // CHECK:STDOUT: %int_3.loc16: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  164. // CHECK:STDOUT: %impl.elem0.loc16: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  165. // CHECK:STDOUT: %bound_method.loc16: <bound method> = bound_method %int_3.loc16, %impl.elem0.loc16 [template = constants.%Convert.bound.b30]
  166. // CHECK:STDOUT: %specific_fn.loc16: <specific function> = specific_function %bound_method.loc16, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42]
  167. // CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %specific_fn.loc16(%int_3.loc16) [template = constants.%int_3.822]
  168. // CHECK:STDOUT: %.loc16: init %i32 = converted %int_3.loc16, %int.convert_checked.loc16 [template = constants.%int_3.822]
  169. // CHECK:STDOUT: assign %tuple.elem0.loc16, %.loc16
  170. // CHECK:STDOUT: %b.ref.loc17: ref %tuple.type.d07 = name_ref b, %b
  171. // CHECK:STDOUT: %int_1.loc17: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  172. // CHECK:STDOUT: %tuple.elem1.loc17: ref %i32 = tuple_access %b.ref.loc17, element1
  173. // CHECK:STDOUT: %int_4.loc17: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  174. // CHECK:STDOUT: %impl.elem0.loc17: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  175. // CHECK:STDOUT: %bound_method.loc17: <bound method> = bound_method %int_4.loc17, %impl.elem0.loc17 [template = constants.%Convert.bound.ac3]
  176. // CHECK:STDOUT: %specific_fn.loc17: <specific function> = specific_function %bound_method.loc17, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.450]
  177. // CHECK:STDOUT: %int.convert_checked.loc17: init %i32 = call %specific_fn.loc17(%int_4.loc17) [template = constants.%int_4.940]
  178. // CHECK:STDOUT: %.loc17: init %i32 = converted %int_4.loc17, %int.convert_checked.loc17 [template = constants.%int_4.940]
  179. // CHECK:STDOUT: assign %tuple.elem1.loc17, %.loc17
  180. // CHECK:STDOUT: name_binding_decl {
  181. // CHECK:STDOUT: %c.patt: %struct_type.a.b.501 = binding_pattern c
  182. // CHECK:STDOUT: %.loc19_3.1: %struct_type.a.b.501 = var_pattern %c.patt
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT: %c.var: ref %struct_type.a.b.501 = var c
  185. // CHECK:STDOUT: %int_1.loc19: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  186. // CHECK:STDOUT: %int_2.loc19: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  187. // CHECK:STDOUT: %.loc19_46.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc19, %int_2.loc19)
  188. // CHECK:STDOUT: %impl.elem0.loc19_46.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  189. // CHECK:STDOUT: %bound_method.loc19_46.1: <bound method> = bound_method %int_1.loc19, %impl.elem0.loc19_46.1 [template = constants.%Convert.bound.ab5]
  190. // CHECK:STDOUT: %specific_fn.loc19_46.1: <specific function> = specific_function %bound_method.loc19_46.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c]
  191. // CHECK:STDOUT: %int.convert_checked.loc19_46.1: init %i32 = call %specific_fn.loc19_46.1(%int_1.loc19) [template = constants.%int_1.5d2]
  192. // CHECK:STDOUT: %.loc19_46.2: init %i32 = converted %int_1.loc19, %int.convert_checked.loc19_46.1 [template = constants.%int_1.5d2]
  193. // CHECK:STDOUT: %.loc19_46.3: ref %i32 = struct_access %c.var, element0
  194. // CHECK:STDOUT: %.loc19_46.4: init %i32 = initialize_from %.loc19_46.2 to %.loc19_46.3 [template = constants.%int_1.5d2]
  195. // CHECK:STDOUT: %impl.elem0.loc19_46.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  196. // CHECK:STDOUT: %bound_method.loc19_46.2: <bound method> = bound_method %int_2.loc19, %impl.elem0.loc19_46.2 [template = constants.%Convert.bound.ef9]
  197. // CHECK:STDOUT: %specific_fn.loc19_46.2: <specific function> = specific_function %bound_method.loc19_46.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787]
  198. // CHECK:STDOUT: %int.convert_checked.loc19_46.2: init %i32 = call %specific_fn.loc19_46.2(%int_2.loc19) [template = constants.%int_2.ef8]
  199. // CHECK:STDOUT: %.loc19_46.5: init %i32 = converted %int_2.loc19, %int.convert_checked.loc19_46.2 [template = constants.%int_2.ef8]
  200. // CHECK:STDOUT: %.loc19_46.6: ref %i32 = struct_access %c.var, element1
  201. // CHECK:STDOUT: %.loc19_46.7: init %i32 = initialize_from %.loc19_46.5 to %.loc19_46.6 [template = constants.%int_2.ef8]
  202. // CHECK:STDOUT: %.loc19_46.8: init %struct_type.a.b.501 = struct_init (%.loc19_46.4, %.loc19_46.7) to %c.var [template = constants.%struct]
  203. // CHECK:STDOUT: %.loc19_3.2: init %struct_type.a.b.501 = converted %.loc19_46.1, %.loc19_46.8 [template = constants.%struct]
  204. // CHECK:STDOUT: assign %c.var, %.loc19_3.2
  205. // CHECK:STDOUT: %.loc19_27: type = splice_block %struct_type.a.b [template = constants.%struct_type.a.b.501] {
  206. // CHECK:STDOUT: %int_32.loc19_15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  207. // CHECK:STDOUT: %i32.loc19_15: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  208. // CHECK:STDOUT: %int_32.loc19_24: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  209. // CHECK:STDOUT: %i32.loc19_24: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  210. // CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %i32, .b: %i32} [template = constants.%struct_type.a.b.501]
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT: %c: ref %struct_type.a.b.501 = bind_name c, %c.var
  213. // CHECK:STDOUT: %c.ref.loc20: ref %struct_type.a.b.501 = name_ref c, %c
  214. // CHECK:STDOUT: %.loc20_4: ref %i32 = struct_access %c.ref.loc20, element0
  215. // CHECK:STDOUT: %int_3.loc20: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  216. // CHECK:STDOUT: %impl.elem0.loc20: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  217. // CHECK:STDOUT: %bound_method.loc20: <bound method> = bound_method %int_3.loc20, %impl.elem0.loc20 [template = constants.%Convert.bound.b30]
  218. // CHECK:STDOUT: %specific_fn.loc20: <specific function> = specific_function %bound_method.loc20, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42]
  219. // CHECK:STDOUT: %int.convert_checked.loc20: init %i32 = call %specific_fn.loc20(%int_3.loc20) [template = constants.%int_3.822]
  220. // CHECK:STDOUT: %.loc20_7: init %i32 = converted %int_3.loc20, %int.convert_checked.loc20 [template = constants.%int_3.822]
  221. // CHECK:STDOUT: assign %.loc20_4, %.loc20_7
  222. // CHECK:STDOUT: %c.ref.loc21: ref %struct_type.a.b.501 = name_ref c, %c
  223. // CHECK:STDOUT: %.loc21_4: ref %i32 = struct_access %c.ref.loc21, element1
  224. // CHECK:STDOUT: %int_4.loc21: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  225. // CHECK:STDOUT: %impl.elem0.loc21: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  226. // CHECK:STDOUT: %bound_method.loc21: <bound method> = bound_method %int_4.loc21, %impl.elem0.loc21 [template = constants.%Convert.bound.ac3]
  227. // CHECK:STDOUT: %specific_fn.loc21: <specific function> = specific_function %bound_method.loc21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.450]
  228. // CHECK:STDOUT: %int.convert_checked.loc21: init %i32 = call %specific_fn.loc21(%int_4.loc21) [template = constants.%int_4.940]
  229. // CHECK:STDOUT: %.loc21_7: init %i32 = converted %int_4.loc21, %int.convert_checked.loc21 [template = constants.%int_4.940]
  230. // CHECK:STDOUT: assign %.loc21_4, %.loc21_7
  231. // CHECK:STDOUT: name_binding_decl {
  232. // CHECK:STDOUT: %p.patt: %ptr.235 = binding_pattern p
  233. // CHECK:STDOUT: %.loc23_3: %ptr.235 = var_pattern %p.patt
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT: %p.var: ref %ptr.235 = var p
  236. // CHECK:STDOUT: %a.ref.loc23: ref %i32 = name_ref a, %a
  237. // CHECK:STDOUT: %addr.loc23: %ptr.235 = addr_of %a.ref.loc23
  238. // CHECK:STDOUT: assign %p.var, %addr.loc23
  239. // CHECK:STDOUT: %.loc23_13: type = splice_block %ptr [template = constants.%ptr.235] {
  240. // CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  241. // CHECK:STDOUT: %i32.loc23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  242. // CHECK:STDOUT: %ptr: type = ptr_type %i32 [template = constants.%ptr.235]
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT: %p: ref %ptr.235 = bind_name p, %p.var
  245. // CHECK:STDOUT: %p.ref.loc24: ref %ptr.235 = name_ref p, %p
  246. // CHECK:STDOUT: %.loc24_4: %ptr.235 = bind_value %p.ref.loc24
  247. // CHECK:STDOUT: %.loc24_3: ref %i32 = deref %.loc24_4
  248. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b]
  249. // CHECK:STDOUT: %impl.elem0.loc24: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  250. // CHECK:STDOUT: %bound_method.loc24: <bound method> = bound_method %int_5, %impl.elem0.loc24 [template = constants.%Convert.bound.4e6]
  251. // CHECK:STDOUT: %specific_fn.loc24: <specific function> = specific_function %bound_method.loc24, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9]
  252. // CHECK:STDOUT: %int.convert_checked.loc24: init %i32 = call %specific_fn.loc24(%int_5) [template = constants.%int_5.0f6]
  253. // CHECK:STDOUT: %.loc24_6: init %i32 = converted %int_5, %int.convert_checked.loc24 [template = constants.%int_5.0f6]
  254. // CHECK:STDOUT: assign %.loc24_3, %.loc24_6
  255. // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true]
  256. // CHECK:STDOUT: if %true br !if.expr.then else br !if.expr.else
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: !if.expr.then:
  259. // CHECK:STDOUT: %p.ref.loc26: ref %ptr.235 = name_ref p, %p
  260. // CHECK:STDOUT: %.loc26_18: %ptr.235 = bind_value %p.ref.loc26
  261. // CHECK:STDOUT: br !if.expr.result(%.loc26_18)
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: !if.expr.else:
  264. // CHECK:STDOUT: %a.ref.loc26: ref %i32 = name_ref a, %a
  265. // CHECK:STDOUT: %addr.loc26: %ptr.235 = addr_of %a.ref.loc26
  266. // CHECK:STDOUT: br !if.expr.result(%addr.loc26)
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: !if.expr.result:
  269. // CHECK:STDOUT: %.loc26_5: %ptr.235 = block_arg !if.expr.result
  270. // CHECK:STDOUT: %.loc26_3: ref %i32 = deref %.loc26_5
  271. // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [template = constants.%int_10.64f]
  272. // CHECK:STDOUT: %impl.elem0.loc26: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  273. // CHECK:STDOUT: %bound_method.loc26: <bound method> = bound_method %int_10, %impl.elem0.loc26 [template = constants.%Convert.bound.491]
  274. // CHECK:STDOUT: %specific_fn.loc26: <specific function> = specific_function %bound_method.loc26, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.e67]
  275. // CHECK:STDOUT: %int.convert_checked.loc26: init %i32 = call %specific_fn.loc26(%int_10) [template = constants.%int_10.265]
  276. // CHECK:STDOUT: %.loc26_29: init %i32 = converted %int_10, %int.convert_checked.loc26 [template = constants.%int_10.265]
  277. // CHECK:STDOUT: assign %.loc26_3, %.loc26_29
  278. // CHECK:STDOUT: return
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT: