assignment.carbon 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/builtin/assignment.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/builtin/assignment.carbon
  13. fn Main() {
  14. var a: i32 = 12;
  15. a = 9;
  16. var b: (i32, i32) = (1, 2);
  17. b.0 = 3;
  18. b.1 = 4;
  19. var c: {.a: i32, .b: i32} = {.a = 1, .b = 2};
  20. c.a = 3;
  21. c.b = 4;
  22. var p: i32* = &a;
  23. *p = 5;
  24. *(if true then p else &a) = 10;
  25. }
  26. // CHECK:STDOUT: --- assignment.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  30. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  31. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  32. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  33. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  34. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  35. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  36. // CHECK:STDOUT: %int_12.6a3: Core.IntLiteral = int_value 12 [concrete]
  37. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  38. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  39. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  40. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  41. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  42. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.3, @impl.4f9(%To.c80) [symbolic]
  43. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  44. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  45. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  46. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.3, @impl.4f9(%int_32) [concrete]
  47. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  48. // CHECK:STDOUT: %ImplicitAs.facet.921: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  49. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet.921 [concrete]
  50. // CHECK:STDOUT: %Convert.bound.221: <bound method> = bound_method %int_12.6a3, %Convert.956 [concrete]
  51. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.3(%int_32) [concrete]
  52. // CHECK:STDOUT: %bound_method.dae: <bound method> = bound_method %int_12.6a3, %Convert.specific_fn [concrete]
  53. // CHECK:STDOUT: %int_12.1e1: %i32 = int_value 12 [concrete]
  54. // CHECK:STDOUT: %int_9.988: Core.IntLiteral = int_value 9 [concrete]
  55. // CHECK:STDOUT: %Convert.bound.9e2: <bound method> = bound_method %int_9.988, %Convert.956 [concrete]
  56. // CHECK:STDOUT: %bound_method.cd3: <bound method> = bound_method %int_9.988, %Convert.specific_fn [concrete]
  57. // CHECK:STDOUT: %int_9.f88: %i32 = int_value 9 [concrete]
  58. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  59. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete]
  60. // CHECK:STDOUT: %pattern_type.511: type = pattern_type %tuple.type.d07 [concrete]
  61. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  62. // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [concrete]
  63. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  64. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  65. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  66. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  67. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  68. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  69. // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_1.5d2, %int_2.ef8) [concrete]
  70. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  71. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  72. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [concrete]
  73. // CHECK:STDOUT: %bound_method.047: <bound method> = bound_method %int_3.1ba, %Convert.specific_fn [concrete]
  74. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  75. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
  76. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [concrete]
  77. // CHECK:STDOUT: %bound_method.1da: <bound method> = bound_method %int_4.0c1, %Convert.specific_fn [concrete]
  78. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
  79. // CHECK:STDOUT: %struct_type.a.b.501: type = struct_type {.a: %i32, .b: %i32} [concrete]
  80. // CHECK:STDOUT: %pattern_type.851: type = pattern_type %struct_type.a.b.501 [concrete]
  81. // CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [concrete]
  82. // CHECK:STDOUT: %struct: %struct_type.a.b.501 = struct_value (%int_1.5d2, %int_2.ef8) [concrete]
  83. // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
  84. // CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %ptr.235 [concrete]
  85. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [concrete]
  86. // CHECK:STDOUT: %Convert.bound.4e6: <bound method> = bound_method %int_5.64b, %Convert.956 [concrete]
  87. // CHECK:STDOUT: %bound_method.a25: <bound method> = bound_method %int_5.64b, %Convert.specific_fn [concrete]
  88. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [concrete]
  89. // CHECK:STDOUT: %true: bool = bool_literal true [concrete]
  90. // CHECK:STDOUT: %int_10.64f: Core.IntLiteral = int_value 10 [concrete]
  91. // CHECK:STDOUT: %Convert.bound.491: <bound method> = bound_method %int_10.64f, %Convert.956 [concrete]
  92. // CHECK:STDOUT: %bound_method.5ba: <bound method> = bound_method %int_10.64f, %Convert.specific_fn [concrete]
  93. // CHECK:STDOUT: %int_10.265: %i32 = int_value 10 [concrete]
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: imports {
  97. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  98. // CHECK:STDOUT: .Int = %Core.Int
  99. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  100. // CHECK:STDOUT: import Core//prelude
  101. // CHECK:STDOUT: import Core//prelude/...
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  104. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  105. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  106. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: file {
  110. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  111. // CHECK:STDOUT: .Core = imports.%Core
  112. // CHECK:STDOUT: .Main = %Main.decl
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %Core.import = import Core
  115. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: fn @Main() {
  119. // CHECK:STDOUT: !entry:
  120. // CHECK:STDOUT: name_binding_decl {
  121. // CHECK:STDOUT: %a.patt: %pattern_type.7ce = binding_pattern a [concrete]
  122. // CHECK:STDOUT: %a.var_patt: %pattern_type.7ce = var_pattern %a.patt [concrete]
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %a.var: ref %i32 = var %a.var_patt
  125. // CHECK:STDOUT: %int_12: Core.IntLiteral = int_value 12 [concrete = constants.%int_12.6a3]
  126. // CHECK:STDOUT: %impl.elem0.loc15: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  127. // CHECK:STDOUT: %bound_method.loc15_3.1: <bound method> = bound_method %int_12, %impl.elem0.loc15 [concrete = constants.%Convert.bound.221]
  128. // CHECK:STDOUT: %specific_fn.loc15: <specific function> = specific_function %impl.elem0.loc15, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  129. // CHECK:STDOUT: %bound_method.loc15_3.2: <bound method> = bound_method %int_12, %specific_fn.loc15 [concrete = constants.%bound_method.dae]
  130. // CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %bound_method.loc15_3.2(%int_12) [concrete = constants.%int_12.1e1]
  131. // CHECK:STDOUT: %.loc15_3: init %i32 = converted %int_12, %int.convert_checked.loc15 [concrete = constants.%int_12.1e1]
  132. // CHECK:STDOUT: assign %a.var, %.loc15_3
  133. // CHECK:STDOUT: %.loc15_10: type = splice_block %i32.loc15 [concrete = constants.%i32] {
  134. // CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  135. // CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: %a: ref %i32 = bind_name a, %a.var
  138. // CHECK:STDOUT: %a.ref.loc16: ref %i32 = name_ref a, %a
  139. // CHECK:STDOUT: %int_9: Core.IntLiteral = int_value 9 [concrete = constants.%int_9.988]
  140. // CHECK:STDOUT: %impl.elem0.loc16: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  141. // CHECK:STDOUT: %bound_method.loc16_5.1: <bound method> = bound_method %int_9, %impl.elem0.loc16 [concrete = constants.%Convert.bound.9e2]
  142. // CHECK:STDOUT: %specific_fn.loc16: <specific function> = specific_function %impl.elem0.loc16, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  143. // CHECK:STDOUT: %bound_method.loc16_5.2: <bound method> = bound_method %int_9, %specific_fn.loc16 [concrete = constants.%bound_method.cd3]
  144. // CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %bound_method.loc16_5.2(%int_9) [concrete = constants.%int_9.f88]
  145. // CHECK:STDOUT: %.loc16: init %i32 = converted %int_9, %int.convert_checked.loc16 [concrete = constants.%int_9.f88]
  146. // CHECK:STDOUT: assign %a.ref.loc16, %.loc16
  147. // CHECK:STDOUT: name_binding_decl {
  148. // CHECK:STDOUT: %b.patt: %pattern_type.511 = binding_pattern b [concrete]
  149. // CHECK:STDOUT: %b.var_patt: %pattern_type.511 = var_pattern %b.patt [concrete]
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT: %b.var: ref %tuple.type.d07 = var %b.var_patt
  152. // CHECK:STDOUT: %int_1.loc18: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  153. // CHECK:STDOUT: %int_2.loc18: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  154. // CHECK:STDOUT: %.loc18_28.1: %tuple.type.f94 = tuple_literal (%int_1.loc18, %int_2.loc18)
  155. // CHECK:STDOUT: %impl.elem0.loc18_28.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  156. // CHECK:STDOUT: %bound_method.loc18_28.1: <bound method> = bound_method %int_1.loc18, %impl.elem0.loc18_28.1 [concrete = constants.%Convert.bound.ab5]
  157. // CHECK:STDOUT: %specific_fn.loc18_28.1: <specific function> = specific_function %impl.elem0.loc18_28.1, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  158. // CHECK:STDOUT: %bound_method.loc18_28.2: <bound method> = bound_method %int_1.loc18, %specific_fn.loc18_28.1 [concrete = constants.%bound_method.9a1]
  159. // CHECK:STDOUT: %int.convert_checked.loc18_28.1: init %i32 = call %bound_method.loc18_28.2(%int_1.loc18) [concrete = constants.%int_1.5d2]
  160. // CHECK:STDOUT: %.loc18_28.2: init %i32 = converted %int_1.loc18, %int.convert_checked.loc18_28.1 [concrete = constants.%int_1.5d2]
  161. // CHECK:STDOUT: %tuple.elem0.loc18: ref %i32 = tuple_access %b.var, element0
  162. // CHECK:STDOUT: %.loc18_28.3: init %i32 = initialize_from %.loc18_28.2 to %tuple.elem0.loc18 [concrete = constants.%int_1.5d2]
  163. // CHECK:STDOUT: %impl.elem0.loc18_28.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  164. // CHECK:STDOUT: %bound_method.loc18_28.3: <bound method> = bound_method %int_2.loc18, %impl.elem0.loc18_28.2 [concrete = constants.%Convert.bound.ef9]
  165. // CHECK:STDOUT: %specific_fn.loc18_28.2: <specific function> = specific_function %impl.elem0.loc18_28.2, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  166. // CHECK:STDOUT: %bound_method.loc18_28.4: <bound method> = bound_method %int_2.loc18, %specific_fn.loc18_28.2 [concrete = constants.%bound_method.b92]
  167. // CHECK:STDOUT: %int.convert_checked.loc18_28.2: init %i32 = call %bound_method.loc18_28.4(%int_2.loc18) [concrete = constants.%int_2.ef8]
  168. // CHECK:STDOUT: %.loc18_28.4: init %i32 = converted %int_2.loc18, %int.convert_checked.loc18_28.2 [concrete = constants.%int_2.ef8]
  169. // CHECK:STDOUT: %tuple.elem1.loc18: ref %i32 = tuple_access %b.var, element1
  170. // CHECK:STDOUT: %.loc18_28.5: init %i32 = initialize_from %.loc18_28.4 to %tuple.elem1.loc18 [concrete = constants.%int_2.ef8]
  171. // CHECK:STDOUT: %.loc18_28.6: init %tuple.type.d07 = tuple_init (%.loc18_28.3, %.loc18_28.5) to %b.var [concrete = constants.%tuple]
  172. // CHECK:STDOUT: %.loc18_3: init %tuple.type.d07 = converted %.loc18_28.1, %.loc18_28.6 [concrete = constants.%tuple]
  173. // CHECK:STDOUT: assign %b.var, %.loc18_3
  174. // CHECK:STDOUT: %.loc18_19.1: type = splice_block %.loc18_19.3 [concrete = constants.%tuple.type.d07] {
  175. // CHECK:STDOUT: %int_32.loc18_11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  176. // CHECK:STDOUT: %i32.loc18_11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  177. // CHECK:STDOUT: %int_32.loc18_16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  178. // CHECK:STDOUT: %i32.loc18_16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  179. // CHECK:STDOUT: %.loc18_19.2: %tuple.type.24b = tuple_literal (%i32.loc18_11, %i32.loc18_16)
  180. // CHECK:STDOUT: %.loc18_19.3: type = converted %.loc18_19.2, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT: %b: ref %tuple.type.d07 = bind_name b, %b.var
  183. // CHECK:STDOUT: %b.ref.loc19: ref %tuple.type.d07 = name_ref b, %b
  184. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  185. // CHECK:STDOUT: %tuple.elem0.loc19: ref %i32 = tuple_access %b.ref.loc19, element0
  186. // CHECK:STDOUT: %int_3.loc19: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  187. // CHECK:STDOUT: %impl.elem0.loc19: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  188. // CHECK:STDOUT: %bound_method.loc19_7.1: <bound method> = bound_method %int_3.loc19, %impl.elem0.loc19 [concrete = constants.%Convert.bound.b30]
  189. // CHECK:STDOUT: %specific_fn.loc19: <specific function> = specific_function %impl.elem0.loc19, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  190. // CHECK:STDOUT: %bound_method.loc19_7.2: <bound method> = bound_method %int_3.loc19, %specific_fn.loc19 [concrete = constants.%bound_method.047]
  191. // CHECK:STDOUT: %int.convert_checked.loc19: init %i32 = call %bound_method.loc19_7.2(%int_3.loc19) [concrete = constants.%int_3.822]
  192. // CHECK:STDOUT: %.loc19: init %i32 = converted %int_3.loc19, %int.convert_checked.loc19 [concrete = constants.%int_3.822]
  193. // CHECK:STDOUT: assign %tuple.elem0.loc19, %.loc19
  194. // CHECK:STDOUT: %b.ref.loc20: ref %tuple.type.d07 = name_ref b, %b
  195. // CHECK:STDOUT: %int_1.loc20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  196. // CHECK:STDOUT: %tuple.elem1.loc20: ref %i32 = tuple_access %b.ref.loc20, element1
  197. // CHECK:STDOUT: %int_4.loc20: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  198. // CHECK:STDOUT: %impl.elem0.loc20: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  199. // CHECK:STDOUT: %bound_method.loc20_7.1: <bound method> = bound_method %int_4.loc20, %impl.elem0.loc20 [concrete = constants.%Convert.bound.ac3]
  200. // CHECK:STDOUT: %specific_fn.loc20: <specific function> = specific_function %impl.elem0.loc20, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  201. // CHECK:STDOUT: %bound_method.loc20_7.2: <bound method> = bound_method %int_4.loc20, %specific_fn.loc20 [concrete = constants.%bound_method.1da]
  202. // CHECK:STDOUT: %int.convert_checked.loc20: init %i32 = call %bound_method.loc20_7.2(%int_4.loc20) [concrete = constants.%int_4.940]
  203. // CHECK:STDOUT: %.loc20: init %i32 = converted %int_4.loc20, %int.convert_checked.loc20 [concrete = constants.%int_4.940]
  204. // CHECK:STDOUT: assign %tuple.elem1.loc20, %.loc20
  205. // CHECK:STDOUT: name_binding_decl {
  206. // CHECK:STDOUT: %c.patt: %pattern_type.851 = binding_pattern c [concrete]
  207. // CHECK:STDOUT: %c.var_patt: %pattern_type.851 = var_pattern %c.patt [concrete]
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: %c.var: ref %struct_type.a.b.501 = var %c.var_patt
  210. // CHECK:STDOUT: %int_1.loc22: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  211. // CHECK:STDOUT: %int_2.loc22: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  212. // CHECK:STDOUT: %.loc22_46.1: %struct_type.a.b.cfd = struct_literal (%int_1.loc22, %int_2.loc22)
  213. // CHECK:STDOUT: %impl.elem0.loc22_46.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  214. // CHECK:STDOUT: %bound_method.loc22_46.1: <bound method> = bound_method %int_1.loc22, %impl.elem0.loc22_46.1 [concrete = constants.%Convert.bound.ab5]
  215. // CHECK:STDOUT: %specific_fn.loc22_46.1: <specific function> = specific_function %impl.elem0.loc22_46.1, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  216. // CHECK:STDOUT: %bound_method.loc22_46.2: <bound method> = bound_method %int_1.loc22, %specific_fn.loc22_46.1 [concrete = constants.%bound_method.9a1]
  217. // CHECK:STDOUT: %int.convert_checked.loc22_46.1: init %i32 = call %bound_method.loc22_46.2(%int_1.loc22) [concrete = constants.%int_1.5d2]
  218. // CHECK:STDOUT: %.loc22_46.2: init %i32 = converted %int_1.loc22, %int.convert_checked.loc22_46.1 [concrete = constants.%int_1.5d2]
  219. // CHECK:STDOUT: %.loc22_46.3: ref %i32 = struct_access %c.var, element0
  220. // CHECK:STDOUT: %.loc22_46.4: init %i32 = initialize_from %.loc22_46.2 to %.loc22_46.3 [concrete = constants.%int_1.5d2]
  221. // CHECK:STDOUT: %impl.elem0.loc22_46.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  222. // CHECK:STDOUT: %bound_method.loc22_46.3: <bound method> = bound_method %int_2.loc22, %impl.elem0.loc22_46.2 [concrete = constants.%Convert.bound.ef9]
  223. // CHECK:STDOUT: %specific_fn.loc22_46.2: <specific function> = specific_function %impl.elem0.loc22_46.2, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  224. // CHECK:STDOUT: %bound_method.loc22_46.4: <bound method> = bound_method %int_2.loc22, %specific_fn.loc22_46.2 [concrete = constants.%bound_method.b92]
  225. // CHECK:STDOUT: %int.convert_checked.loc22_46.2: init %i32 = call %bound_method.loc22_46.4(%int_2.loc22) [concrete = constants.%int_2.ef8]
  226. // CHECK:STDOUT: %.loc22_46.5: init %i32 = converted %int_2.loc22, %int.convert_checked.loc22_46.2 [concrete = constants.%int_2.ef8]
  227. // CHECK:STDOUT: %.loc22_46.6: ref %i32 = struct_access %c.var, element1
  228. // CHECK:STDOUT: %.loc22_46.7: init %i32 = initialize_from %.loc22_46.5 to %.loc22_46.6 [concrete = constants.%int_2.ef8]
  229. // CHECK:STDOUT: %.loc22_46.8: init %struct_type.a.b.501 = struct_init (%.loc22_46.4, %.loc22_46.7) to %c.var [concrete = constants.%struct]
  230. // CHECK:STDOUT: %.loc22_3: init %struct_type.a.b.501 = converted %.loc22_46.1, %.loc22_46.8 [concrete = constants.%struct]
  231. // CHECK:STDOUT: assign %c.var, %.loc22_3
  232. // CHECK:STDOUT: %.loc22_27: type = splice_block %struct_type.a.b [concrete = constants.%struct_type.a.b.501] {
  233. // CHECK:STDOUT: %int_32.loc22_15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  234. // CHECK:STDOUT: %i32.loc22_15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  235. // CHECK:STDOUT: %int_32.loc22_24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  236. // CHECK:STDOUT: %i32.loc22_24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  237. // CHECK:STDOUT: %struct_type.a.b: type = struct_type {.a: %i32, .b: %i32} [concrete = constants.%struct_type.a.b.501]
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT: %c: ref %struct_type.a.b.501 = bind_name c, %c.var
  240. // CHECK:STDOUT: %c.ref.loc23: ref %struct_type.a.b.501 = name_ref c, %c
  241. // CHECK:STDOUT: %.loc23_4: ref %i32 = struct_access %c.ref.loc23, element0
  242. // CHECK:STDOUT: %int_3.loc23: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  243. // CHECK:STDOUT: %impl.elem0.loc23: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  244. // CHECK:STDOUT: %bound_method.loc23_7.1: <bound method> = bound_method %int_3.loc23, %impl.elem0.loc23 [concrete = constants.%Convert.bound.b30]
  245. // CHECK:STDOUT: %specific_fn.loc23: <specific function> = specific_function %impl.elem0.loc23, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  246. // CHECK:STDOUT: %bound_method.loc23_7.2: <bound method> = bound_method %int_3.loc23, %specific_fn.loc23 [concrete = constants.%bound_method.047]
  247. // CHECK:STDOUT: %int.convert_checked.loc23: init %i32 = call %bound_method.loc23_7.2(%int_3.loc23) [concrete = constants.%int_3.822]
  248. // CHECK:STDOUT: %.loc23_7: init %i32 = converted %int_3.loc23, %int.convert_checked.loc23 [concrete = constants.%int_3.822]
  249. // CHECK:STDOUT: assign %.loc23_4, %.loc23_7
  250. // CHECK:STDOUT: %c.ref.loc24: ref %struct_type.a.b.501 = name_ref c, %c
  251. // CHECK:STDOUT: %.loc24_4: ref %i32 = struct_access %c.ref.loc24, element1
  252. // CHECK:STDOUT: %int_4.loc24: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  253. // CHECK:STDOUT: %impl.elem0.loc24: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  254. // CHECK:STDOUT: %bound_method.loc24_7.1: <bound method> = bound_method %int_4.loc24, %impl.elem0.loc24 [concrete = constants.%Convert.bound.ac3]
  255. // CHECK:STDOUT: %specific_fn.loc24: <specific function> = specific_function %impl.elem0.loc24, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  256. // CHECK:STDOUT: %bound_method.loc24_7.2: <bound method> = bound_method %int_4.loc24, %specific_fn.loc24 [concrete = constants.%bound_method.1da]
  257. // CHECK:STDOUT: %int.convert_checked.loc24: init %i32 = call %bound_method.loc24_7.2(%int_4.loc24) [concrete = constants.%int_4.940]
  258. // CHECK:STDOUT: %.loc24_7: init %i32 = converted %int_4.loc24, %int.convert_checked.loc24 [concrete = constants.%int_4.940]
  259. // CHECK:STDOUT: assign %.loc24_4, %.loc24_7
  260. // CHECK:STDOUT: name_binding_decl {
  261. // CHECK:STDOUT: %p.patt: %pattern_type.fe8 = binding_pattern p [concrete]
  262. // CHECK:STDOUT: %p.var_patt: %pattern_type.fe8 = var_pattern %p.patt [concrete]
  263. // CHECK:STDOUT: }
  264. // CHECK:STDOUT: %p.var: ref %ptr.235 = var %p.var_patt
  265. // CHECK:STDOUT: %a.ref.loc26: ref %i32 = name_ref a, %a
  266. // CHECK:STDOUT: %addr.loc26: %ptr.235 = addr_of %a.ref.loc26
  267. // CHECK:STDOUT: assign %p.var, %addr.loc26
  268. // CHECK:STDOUT: %.loc26: type = splice_block %ptr [concrete = constants.%ptr.235] {
  269. // CHECK:STDOUT: %int_32.loc26: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  270. // CHECK:STDOUT: %i32.loc26: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  271. // CHECK:STDOUT: %ptr: type = ptr_type %i32.loc26 [concrete = constants.%ptr.235]
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT: %p: ref %ptr.235 = bind_name p, %p.var
  274. // CHECK:STDOUT: %p.ref.loc27: ref %ptr.235 = name_ref p, %p
  275. // CHECK:STDOUT: %.loc27_4: %ptr.235 = bind_value %p.ref.loc27
  276. // CHECK:STDOUT: %.loc27_3: ref %i32 = deref %.loc27_4
  277. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  278. // CHECK:STDOUT: %impl.elem0.loc27: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  279. // CHECK:STDOUT: %bound_method.loc27_6.1: <bound method> = bound_method %int_5, %impl.elem0.loc27 [concrete = constants.%Convert.bound.4e6]
  280. // CHECK:STDOUT: %specific_fn.loc27: <specific function> = specific_function %impl.elem0.loc27, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  281. // CHECK:STDOUT: %bound_method.loc27_6.2: <bound method> = bound_method %int_5, %specific_fn.loc27 [concrete = constants.%bound_method.a25]
  282. // CHECK:STDOUT: %int.convert_checked.loc27: init %i32 = call %bound_method.loc27_6.2(%int_5) [concrete = constants.%int_5.0f6]
  283. // CHECK:STDOUT: %.loc27_6: init %i32 = converted %int_5, %int.convert_checked.loc27 [concrete = constants.%int_5.0f6]
  284. // CHECK:STDOUT: assign %.loc27_3, %.loc27_6
  285. // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
  286. // CHECK:STDOUT: if %true br !if.expr.then else br !if.expr.else
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: !if.expr.then:
  289. // CHECK:STDOUT: %p.ref.loc29: ref %ptr.235 = name_ref p, %p
  290. // CHECK:STDOUT: %.loc29_18: %ptr.235 = bind_value %p.ref.loc29
  291. // CHECK:STDOUT: br !if.expr.result(%.loc29_18)
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: !if.expr.else:
  294. // CHECK:STDOUT: %a.ref.loc29: ref %i32 = name_ref a, %a
  295. // CHECK:STDOUT: %addr.loc29: %ptr.235 = addr_of %a.ref.loc29
  296. // CHECK:STDOUT: br !if.expr.result(%addr.loc29)
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: !if.expr.result:
  299. // CHECK:STDOUT: %.loc29_5: %ptr.235 = block_arg !if.expr.result
  300. // CHECK:STDOUT: %.loc29_3: ref %i32 = deref %.loc29_5
  301. // CHECK:STDOUT: %int_10: Core.IntLiteral = int_value 10 [concrete = constants.%int_10.64f]
  302. // CHECK:STDOUT: %impl.elem0.loc29: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  303. // CHECK:STDOUT: %bound_method.loc29_29.1: <bound method> = bound_method %int_10, %impl.elem0.loc29 [concrete = constants.%Convert.bound.491]
  304. // CHECK:STDOUT: %specific_fn.loc29: <specific function> = specific_function %impl.elem0.loc29, @Convert.3(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  305. // CHECK:STDOUT: %bound_method.loc29_29.2: <bound method> = bound_method %int_10, %specific_fn.loc29 [concrete = constants.%bound_method.5ba]
  306. // CHECK:STDOUT: %int.convert_checked.loc29: init %i32 = call %bound_method.loc29_29.2(%int_10) [concrete = constants.%int_10.265]
  307. // CHECK:STDOUT: %.loc29_29: init %i32 = converted %int_10, %int.convert_checked.loc29 [concrete = constants.%int_10.265]
  308. // CHECK:STDOUT: assign %.loc29_3, %.loc29_29
  309. // CHECK:STDOUT: return
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT: