basic.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/uint.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/choice/basic.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/choice/basic.carbon
  12. // --- no_alternative.carbon
  13. library "[[@TEST_NAME]]";
  14. //@dump-sem-ir-begin
  15. choice Never {}
  16. //@dump-sem-ir-end
  17. // --- one_alternative.carbon
  18. library "[[@TEST_NAME]]";
  19. //@dump-sem-ir-begin
  20. choice Always {
  21. Sunny
  22. }
  23. let mood: Always = Always.Sunny;
  24. //@dump-sem-ir-end
  25. // --- multiple_alternatives.carbon
  26. library "[[@TEST_NAME]]";
  27. //@dump-sem-ir-begin
  28. choice Ordering {
  29. Less,
  30. Equivalent,
  31. Greater,
  32. Incomparable
  33. }
  34. let less: Ordering = Ordering.Less;
  35. let equiv: Ordering = Ordering.Equivalent;
  36. let greater: Ordering = Ordering.Greater;
  37. let inc: Ordering = Ordering.Incomparable;
  38. //@dump-sem-ir-end
  39. // --- fail_no_alternative_construct.carbon
  40. library "[[@TEST_NAME]]";
  41. choice Never {}
  42. // TODO: Can we produce a better diagnostic?
  43. // CHECK:STDERR: fail_no_alternative_construct.carbon:[[@LINE+4]]:20: error: cannot initialize class with 1 field from struct with 0 fields [StructInitElementCountMismatch]
  44. // CHECK:STDERR: let never: Never = {};
  45. // CHECK:STDERR: ^~
  46. // CHECK:STDERR:
  47. let never: Never = {};
  48. // CHECK:STDOUT: --- no_alternative.carbon
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: constants {
  51. // CHECK:STDOUT: %Never: type = class_type @Never [concrete]
  52. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  53. // CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %empty_tuple.type} [concrete]
  54. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.discriminant [concrete]
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: imports {
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: file {
  61. // CHECK:STDOUT: %Never.decl: type = class_decl @Never [concrete = constants.%Never] {} {}
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: class @Never {
  65. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type]
  66. // CHECK:STDOUT: complete_type_witness = %complete_type
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !members:
  69. // CHECK:STDOUT: .Self = constants.%Never
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: --- one_alternative.carbon
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: constants {
  75. // CHECK:STDOUT: %Always: type = class_type @Always [concrete]
  76. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  77. // CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %empty_tuple.type} [concrete]
  78. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.discriminant [concrete]
  79. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  80. // CHECK:STDOUT: %struct: %struct_type.discriminant = struct_value (%empty_tuple) [concrete]
  81. // CHECK:STDOUT: %Always.val: %Always = struct_value (%empty_tuple) [concrete]
  82. // CHECK:STDOUT: %pattern_type: type = pattern_type %Always [concrete]
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: imports {
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: file {
  89. // CHECK:STDOUT: %Always.decl: type = class_decl @Always [concrete = constants.%Always] {} {}
  90. // CHECK:STDOUT: name_binding_decl {
  91. // CHECK:STDOUT: %mood.patt: %pattern_type = value_binding_pattern mood [concrete]
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %Always.ref: type = name_ref Always, %Always.decl [concrete = constants.%Always]
  94. // CHECK:STDOUT: %mood: %Always = value_binding mood, @__global_init.%Sunny.ref
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: class @Always {
  98. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type]
  99. // CHECK:STDOUT: %.loc6_1.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  100. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  101. // CHECK:STDOUT: %.loc6_1.2: %empty_tuple.type = converted %.loc6_1.1, %empty_tuple [concrete = constants.%empty_tuple]
  102. // CHECK:STDOUT: %.loc6_1.3: %struct_type.discriminant = struct_literal (%.loc6_1.2) [concrete = constants.%struct]
  103. // CHECK:STDOUT: %.loc6_1.4: ref %Always = temporary_storage
  104. // CHECK:STDOUT: %.loc6_1.5: ref %empty_tuple.type = class_element_access %.loc6_1.4, element0
  105. // CHECK:STDOUT: %.loc6_1.6: init %empty_tuple.type = tuple_init () to %.loc6_1.5 [concrete = constants.%empty_tuple]
  106. // CHECK:STDOUT: %.loc6_1.7: init %empty_tuple.type = converted %.loc6_1.2, %.loc6_1.6 [concrete = constants.%empty_tuple]
  107. // CHECK:STDOUT: %.loc6_1.8: init %Always = class_init (%.loc6_1.7), %.loc6_1.4 [concrete = constants.%Always.val]
  108. // CHECK:STDOUT: %.loc6_1.9: ref %Always = temporary %.loc6_1.4, %.loc6_1.8
  109. // CHECK:STDOUT: %.loc6_1.10: ref %Always = converted %.loc6_1.3, %.loc6_1.9
  110. // CHECK:STDOUT: %.loc6_1.11: %Always = acquire_value %.loc6_1.10
  111. // CHECK:STDOUT: %Sunny: %Always = value_binding Sunny, %.loc6_1.11
  112. // CHECK:STDOUT: complete_type_witness = %complete_type
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: !members:
  115. // CHECK:STDOUT: .Self = constants.%Always
  116. // CHECK:STDOUT: .Sunny = %Sunny
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: fn @__global_init() {
  120. // CHECK:STDOUT: !entry:
  121. // CHECK:STDOUT: %Always.ref: type = name_ref Always, file.%Always.decl [concrete = constants.%Always]
  122. // CHECK:STDOUT: %Sunny.ref: %Always = name_ref Sunny, @Always.%Sunny
  123. // CHECK:STDOUT: <elided>
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: --- multiple_alternatives.carbon
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: constants {
  129. // CHECK:STDOUT: %Ordering: type = class_type @Ordering [concrete]
  130. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  131. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  132. // CHECK:STDOUT: %u2: type = class_type @UInt, @UInt(%int_2.ecc) [concrete]
  133. // CHECK:STDOUT: %struct_type.discriminant: type = struct_type {.discriminant: %u2} [concrete]
  134. // CHECK:STDOUT: %complete_type.de2: <witness> = complete_type_witness %struct_type.discriminant [concrete]
  135. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
  136. // CHECK:STDOUT: %ImplicitAs.type.d83: type = facet_type <@ImplicitAs, @ImplicitAs(%u2)> [concrete]
  137. // CHECK:STDOUT: %ImplicitAs.Convert.type.f0e: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%u2) [concrete]
  138. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  139. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.98f: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  140. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.cde: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.98f = struct_value () [symbolic]
  141. // CHECK:STDOUT: %ImplicitAs.impl_witness.60b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.257, @Core.IntLiteral.as.ImplicitAs.impl(%int_2.ecc) [concrete]
  142. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.a04: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_2.ecc) [concrete]
  143. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.a04 = struct_value () [concrete]
  144. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.d83 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.60b) [concrete]
  145. // CHECK:STDOUT: %.b75: type = fn_type_with_self_type %ImplicitAs.Convert.type.f0e, %ImplicitAs.facet [concrete]
  146. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.b79: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8 [concrete]
  147. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_2.ecc) [concrete]
  148. // CHECK:STDOUT: %bound_method.51a: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  149. // CHECK:STDOUT: %int_0.9fd: %u2 = int_value 0 [concrete]
  150. // CHECK:STDOUT: %struct.559: %struct_type.discriminant = struct_value (%int_0.9fd) [concrete]
  151. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  152. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  153. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.type.f83: type = fn_type @UInt.as.Copy.impl.Op, @UInt.as.Copy.impl(%N) [symbolic]
  154. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.1d8: %UInt.as.Copy.impl.Op.type.f83 = struct_value () [symbolic]
  155. // CHECK:STDOUT: %Copy.impl_witness.5b3: <witness> = impl_witness imports.%Copy.impl_witness_table.7a2, @UInt.as.Copy.impl(%int_2.ecc) [concrete]
  156. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.type.0b6: type = fn_type @UInt.as.Copy.impl.Op, @UInt.as.Copy.impl(%int_2.ecc) [concrete]
  157. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.9e3: %UInt.as.Copy.impl.Op.type.0b6 = struct_value () [concrete]
  158. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %u2, (%Copy.impl_witness.5b3) [concrete]
  159. // CHECK:STDOUT: %.bb5: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet [concrete]
  160. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.bound.dcf: <bound method> = bound_method %int_0.9fd, %UInt.as.Copy.impl.Op.9e3 [concrete]
  161. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %UInt.as.Copy.impl.Op.9e3, @UInt.as.Copy.impl.Op(%int_2.ecc) [concrete]
  162. // CHECK:STDOUT: %bound_method.3f0: <bound method> = bound_method %int_0.9fd, %UInt.as.Copy.impl.Op.specific_fn [concrete]
  163. // CHECK:STDOUT: %Ordering.val.a29: %Ordering = struct_value (%int_0.9fd) [concrete]
  164. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  165. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.237: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8 [concrete]
  166. // CHECK:STDOUT: %bound_method.82b: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  167. // CHECK:STDOUT: %int_1.b2c: %u2 = int_value 1 [concrete]
  168. // CHECK:STDOUT: %struct.0ff: %struct_type.discriminant = struct_value (%int_1.b2c) [concrete]
  169. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.bound.4d3: <bound method> = bound_method %int_1.b2c, %UInt.as.Copy.impl.Op.9e3 [concrete]
  170. // CHECK:STDOUT: %bound_method.0a8: <bound method> = bound_method %int_1.b2c, %UInt.as.Copy.impl.Op.specific_fn [concrete]
  171. // CHECK:STDOUT: %Ordering.val.927: %Ordering = struct_value (%int_1.b2c) [concrete]
  172. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.1a9: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8 [concrete]
  173. // CHECK:STDOUT: %bound_method.6dc: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  174. // CHECK:STDOUT: %int_2.788: %u2 = int_value 2 [concrete]
  175. // CHECK:STDOUT: %struct.6e6: %struct_type.discriminant = struct_value (%int_2.788) [concrete]
  176. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.bound.0bf: <bound method> = bound_method %int_2.788, %UInt.as.Copy.impl.Op.9e3 [concrete]
  177. // CHECK:STDOUT: %bound_method.1b3: <bound method> = bound_method %int_2.788, %UInt.as.Copy.impl.Op.specific_fn [concrete]
  178. // CHECK:STDOUT: %Ordering.val.968: %Ordering = struct_value (%int_2.788) [concrete]
  179. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  180. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.5cc: <bound method> = bound_method %int_3.1ba, %Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8 [concrete]
  181. // CHECK:STDOUT: %bound_method.021: <bound method> = bound_method %int_3.1ba, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  182. // CHECK:STDOUT: %int_3.975: %u2 = int_value 3 [concrete]
  183. // CHECK:STDOUT: %struct.7bd: %struct_type.discriminant = struct_value (%int_3.975) [concrete]
  184. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.bound.4ab: <bound method> = bound_method %int_3.975, %UInt.as.Copy.impl.Op.9e3 [concrete]
  185. // CHECK:STDOUT: %bound_method.264: <bound method> = bound_method %int_3.975, %UInt.as.Copy.impl.Op.specific_fn [concrete]
  186. // CHECK:STDOUT: %Ordering.val.8a7: %Ordering = struct_value (%int_3.975) [concrete]
  187. // CHECK:STDOUT: %pattern_type.308: type = pattern_type %Ordering [concrete]
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: imports {
  191. // CHECK:STDOUT: %Core.import_ref.c72: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.98f) = import_ref Core//prelude/parts/uint, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.cde)]
  192. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.257 = impl_witness_table (%Core.import_ref.c72), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  193. // CHECK:STDOUT: %Core.import_ref.498: @UInt.as.Copy.impl.%UInt.as.Copy.impl.Op.type (%UInt.as.Copy.impl.Op.type.f83) = import_ref Core//prelude/parts/uint, loc{{\d+_\d+}}, loaded [symbolic = @UInt.as.Copy.impl.%UInt.as.Copy.impl.Op (constants.%UInt.as.Copy.impl.Op.1d8)]
  194. // CHECK:STDOUT: %Copy.impl_witness_table.7a2 = impl_witness_table (%Core.import_ref.498), @UInt.as.Copy.impl [concrete]
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: file {
  198. // CHECK:STDOUT: %Ordering.decl: type = class_decl @Ordering [concrete = constants.%Ordering] {} {}
  199. // CHECK:STDOUT: name_binding_decl {
  200. // CHECK:STDOUT: %less.patt: %pattern_type.308 = value_binding_pattern less [concrete]
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %Ordering.ref.loc11: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering]
  203. // CHECK:STDOUT: %less: %Ordering = value_binding less, @__global_init.%Less.ref
  204. // CHECK:STDOUT: name_binding_decl {
  205. // CHECK:STDOUT: %equiv.patt: %pattern_type.308 = value_binding_pattern equiv [concrete]
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT: %Ordering.ref.loc12: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering]
  208. // CHECK:STDOUT: %equiv: %Ordering = value_binding equiv, @__global_init.%Equivalent.ref
  209. // CHECK:STDOUT: name_binding_decl {
  210. // CHECK:STDOUT: %greater.patt: %pattern_type.308 = value_binding_pattern greater [concrete]
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT: %Ordering.ref.loc13: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering]
  213. // CHECK:STDOUT: %greater: %Ordering = value_binding greater, @__global_init.%Greater.ref
  214. // CHECK:STDOUT: name_binding_decl {
  215. // CHECK:STDOUT: %inc.patt: %pattern_type.308 = value_binding_pattern inc [concrete]
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT: %Ordering.ref.loc14: type = name_ref Ordering, %Ordering.decl [concrete = constants.%Ordering]
  218. // CHECK:STDOUT: %inc: %Ordering = value_binding inc, @__global_init.%Incomparable.ref
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: class @Ordering {
  222. // CHECK:STDOUT: %int_2.loc9: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  223. // CHECK:STDOUT: %u2: type = class_type @UInt, @UInt(constants.%int_2.ecc) [concrete = constants.%u2]
  224. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.discriminant [concrete = constants.%complete_type.de2]
  225. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
  226. // CHECK:STDOUT: %impl.elem0.loc5_7.1: %.b75 = impl_witness_access constants.%ImplicitAs.impl_witness.60b, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8]
  227. // CHECK:STDOUT: %bound_method.loc5_7.1: <bound method> = bound_method %int_0, %impl.elem0.loc5_7.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.b79]
  228. // CHECK:STDOUT: %specific_fn.loc5_7.1: <specific function> = specific_function %impl.elem0.loc5_7.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_2.ecc) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  229. // CHECK:STDOUT: %bound_method.loc5_7.2: <bound method> = bound_method %int_0, %specific_fn.loc5_7.1 [concrete = constants.%bound_method.51a]
  230. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5: init %u2 = call %bound_method.loc5_7.2(%int_0) [concrete = constants.%int_0.9fd]
  231. // CHECK:STDOUT: %.loc5_7.1: %u2 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5 [concrete = constants.%int_0.9fd]
  232. // CHECK:STDOUT: %.loc5_7.2: %u2 = converted %int_0, %.loc5_7.1 [concrete = constants.%int_0.9fd]
  233. // CHECK:STDOUT: %.loc5_7.3: %struct_type.discriminant = struct_literal (%.loc5_7.2) [concrete = constants.%struct.559]
  234. // CHECK:STDOUT: %impl.elem0.loc5_7.2: %.bb5 = impl_witness_access constants.%Copy.impl_witness.5b3, element0 [concrete = constants.%UInt.as.Copy.impl.Op.9e3]
  235. // CHECK:STDOUT: %bound_method.loc5_7.3: <bound method> = bound_method %.loc5_7.2, %impl.elem0.loc5_7.2 [concrete = constants.%UInt.as.Copy.impl.Op.bound.dcf]
  236. // CHECK:STDOUT: %specific_fn.loc5_7.2: <specific function> = specific_function %impl.elem0.loc5_7.2, @UInt.as.Copy.impl.Op(constants.%int_2.ecc) [concrete = constants.%UInt.as.Copy.impl.Op.specific_fn]
  237. // CHECK:STDOUT: %bound_method.loc5_7.4: <bound method> = bound_method %.loc5_7.2, %specific_fn.loc5_7.2 [concrete = constants.%bound_method.3f0]
  238. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.call.loc5: init %u2 = call %bound_method.loc5_7.4(%.loc5_7.2) [concrete = constants.%int_0.9fd]
  239. // CHECK:STDOUT: %.loc5_7.4: ref %Ordering = temporary_storage
  240. // CHECK:STDOUT: %.loc5_7.5: ref %u2 = class_element_access %.loc5_7.4, element0
  241. // CHECK:STDOUT: %.loc5_7.6: init %u2 = initialize_from %UInt.as.Copy.impl.Op.call.loc5 to %.loc5_7.5 [concrete = constants.%int_0.9fd]
  242. // CHECK:STDOUT: %.loc5_7.7: init %Ordering = class_init (%.loc5_7.6), %.loc5_7.4 [concrete = constants.%Ordering.val.a29]
  243. // CHECK:STDOUT: %.loc5_7.8: ref %Ordering = temporary %.loc5_7.4, %.loc5_7.7
  244. // CHECK:STDOUT: %.loc5_7.9: ref %Ordering = converted %.loc5_7.3, %.loc5_7.8
  245. // CHECK:STDOUT: %.loc5_7.10: %Ordering = acquire_value %.loc5_7.9
  246. // CHECK:STDOUT: %Less: %Ordering = value_binding Less, %.loc5_7.10
  247. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  248. // CHECK:STDOUT: %impl.elem0.loc6_13.1: %.b75 = impl_witness_access constants.%ImplicitAs.impl_witness.60b, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8]
  249. // CHECK:STDOUT: %bound_method.loc6_13.1: <bound method> = bound_method %int_1, %impl.elem0.loc6_13.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.237]
  250. // CHECK:STDOUT: %specific_fn.loc6_13.1: <specific function> = specific_function %impl.elem0.loc6_13.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_2.ecc) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  251. // CHECK:STDOUT: %bound_method.loc6_13.2: <bound method> = bound_method %int_1, %specific_fn.loc6_13.1 [concrete = constants.%bound_method.82b]
  252. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc6: init %u2 = call %bound_method.loc6_13.2(%int_1) [concrete = constants.%int_1.b2c]
  253. // CHECK:STDOUT: %.loc6_13.1: %u2 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc6 [concrete = constants.%int_1.b2c]
  254. // CHECK:STDOUT: %.loc6_13.2: %u2 = converted %int_1, %.loc6_13.1 [concrete = constants.%int_1.b2c]
  255. // CHECK:STDOUT: %.loc6_13.3: %struct_type.discriminant = struct_literal (%.loc6_13.2) [concrete = constants.%struct.0ff]
  256. // CHECK:STDOUT: %impl.elem0.loc6_13.2: %.bb5 = impl_witness_access constants.%Copy.impl_witness.5b3, element0 [concrete = constants.%UInt.as.Copy.impl.Op.9e3]
  257. // CHECK:STDOUT: %bound_method.loc6_13.3: <bound method> = bound_method %.loc6_13.2, %impl.elem0.loc6_13.2 [concrete = constants.%UInt.as.Copy.impl.Op.bound.4d3]
  258. // CHECK:STDOUT: %specific_fn.loc6_13.2: <specific function> = specific_function %impl.elem0.loc6_13.2, @UInt.as.Copy.impl.Op(constants.%int_2.ecc) [concrete = constants.%UInt.as.Copy.impl.Op.specific_fn]
  259. // CHECK:STDOUT: %bound_method.loc6_13.4: <bound method> = bound_method %.loc6_13.2, %specific_fn.loc6_13.2 [concrete = constants.%bound_method.0a8]
  260. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.call.loc6: init %u2 = call %bound_method.loc6_13.4(%.loc6_13.2) [concrete = constants.%int_1.b2c]
  261. // CHECK:STDOUT: %.loc6_13.4: ref %Ordering = temporary_storage
  262. // CHECK:STDOUT: %.loc6_13.5: ref %u2 = class_element_access %.loc6_13.4, element0
  263. // CHECK:STDOUT: %.loc6_13.6: init %u2 = initialize_from %UInt.as.Copy.impl.Op.call.loc6 to %.loc6_13.5 [concrete = constants.%int_1.b2c]
  264. // CHECK:STDOUT: %.loc6_13.7: init %Ordering = class_init (%.loc6_13.6), %.loc6_13.4 [concrete = constants.%Ordering.val.927]
  265. // CHECK:STDOUT: %.loc6_13.8: ref %Ordering = temporary %.loc6_13.4, %.loc6_13.7
  266. // CHECK:STDOUT: %.loc6_13.9: ref %Ordering = converted %.loc6_13.3, %.loc6_13.8
  267. // CHECK:STDOUT: %.loc6_13.10: %Ordering = acquire_value %.loc6_13.9
  268. // CHECK:STDOUT: %Equivalent: %Ordering = value_binding Equivalent, %.loc6_13.10
  269. // CHECK:STDOUT: %int_2.loc7: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  270. // CHECK:STDOUT: %impl.elem0.loc7_10.1: %.b75 = impl_witness_access constants.%ImplicitAs.impl_witness.60b, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8]
  271. // CHECK:STDOUT: %bound_method.loc7_10.1: <bound method> = bound_method %int_2.loc7, %impl.elem0.loc7_10.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.1a9]
  272. // CHECK:STDOUT: %specific_fn.loc7_10.1: <specific function> = specific_function %impl.elem0.loc7_10.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_2.ecc) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  273. // CHECK:STDOUT: %bound_method.loc7_10.2: <bound method> = bound_method %int_2.loc7, %specific_fn.loc7_10.1 [concrete = constants.%bound_method.6dc]
  274. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc7: init %u2 = call %bound_method.loc7_10.2(%int_2.loc7) [concrete = constants.%int_2.788]
  275. // CHECK:STDOUT: %.loc7_10.1: %u2 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc7 [concrete = constants.%int_2.788]
  276. // CHECK:STDOUT: %.loc7_10.2: %u2 = converted %int_2.loc7, %.loc7_10.1 [concrete = constants.%int_2.788]
  277. // CHECK:STDOUT: %.loc7_10.3: %struct_type.discriminant = struct_literal (%.loc7_10.2) [concrete = constants.%struct.6e6]
  278. // CHECK:STDOUT: %impl.elem0.loc7_10.2: %.bb5 = impl_witness_access constants.%Copy.impl_witness.5b3, element0 [concrete = constants.%UInt.as.Copy.impl.Op.9e3]
  279. // CHECK:STDOUT: %bound_method.loc7_10.3: <bound method> = bound_method %.loc7_10.2, %impl.elem0.loc7_10.2 [concrete = constants.%UInt.as.Copy.impl.Op.bound.0bf]
  280. // CHECK:STDOUT: %specific_fn.loc7_10.2: <specific function> = specific_function %impl.elem0.loc7_10.2, @UInt.as.Copy.impl.Op(constants.%int_2.ecc) [concrete = constants.%UInt.as.Copy.impl.Op.specific_fn]
  281. // CHECK:STDOUT: %bound_method.loc7_10.4: <bound method> = bound_method %.loc7_10.2, %specific_fn.loc7_10.2 [concrete = constants.%bound_method.1b3]
  282. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.call.loc7: init %u2 = call %bound_method.loc7_10.4(%.loc7_10.2) [concrete = constants.%int_2.788]
  283. // CHECK:STDOUT: %.loc7_10.4: ref %Ordering = temporary_storage
  284. // CHECK:STDOUT: %.loc7_10.5: ref %u2 = class_element_access %.loc7_10.4, element0
  285. // CHECK:STDOUT: %.loc7_10.6: init %u2 = initialize_from %UInt.as.Copy.impl.Op.call.loc7 to %.loc7_10.5 [concrete = constants.%int_2.788]
  286. // CHECK:STDOUT: %.loc7_10.7: init %Ordering = class_init (%.loc7_10.6), %.loc7_10.4 [concrete = constants.%Ordering.val.968]
  287. // CHECK:STDOUT: %.loc7_10.8: ref %Ordering = temporary %.loc7_10.4, %.loc7_10.7
  288. // CHECK:STDOUT: %.loc7_10.9: ref %Ordering = converted %.loc7_10.3, %.loc7_10.8
  289. // CHECK:STDOUT: %.loc7_10.10: %Ordering = acquire_value %.loc7_10.9
  290. // CHECK:STDOUT: %Greater: %Ordering = value_binding Greater, %.loc7_10.10
  291. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  292. // CHECK:STDOUT: %impl.elem0.loc9_1.1: %.b75 = impl_witness_access constants.%ImplicitAs.impl_witness.60b, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3e8]
  293. // CHECK:STDOUT: %bound_method.loc9_1.1: <bound method> = bound_method %int_3, %impl.elem0.loc9_1.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.5cc]
  294. // CHECK:STDOUT: %specific_fn.loc9_1.1: <specific function> = specific_function %impl.elem0.loc9_1.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_2.ecc) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  295. // CHECK:STDOUT: %bound_method.loc9_1.2: <bound method> = bound_method %int_3, %specific_fn.loc9_1.1 [concrete = constants.%bound_method.021]
  296. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc9: init %u2 = call %bound_method.loc9_1.2(%int_3) [concrete = constants.%int_3.975]
  297. // CHECK:STDOUT: %.loc9_1.1: %u2 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc9 [concrete = constants.%int_3.975]
  298. // CHECK:STDOUT: %.loc9_1.2: %u2 = converted %int_3, %.loc9_1.1 [concrete = constants.%int_3.975]
  299. // CHECK:STDOUT: %.loc9_1.3: %struct_type.discriminant = struct_literal (%.loc9_1.2) [concrete = constants.%struct.7bd]
  300. // CHECK:STDOUT: %impl.elem0.loc9_1.2: %.bb5 = impl_witness_access constants.%Copy.impl_witness.5b3, element0 [concrete = constants.%UInt.as.Copy.impl.Op.9e3]
  301. // CHECK:STDOUT: %bound_method.loc9_1.3: <bound method> = bound_method %.loc9_1.2, %impl.elem0.loc9_1.2 [concrete = constants.%UInt.as.Copy.impl.Op.bound.4ab]
  302. // CHECK:STDOUT: %specific_fn.loc9_1.2: <specific function> = specific_function %impl.elem0.loc9_1.2, @UInt.as.Copy.impl.Op(constants.%int_2.ecc) [concrete = constants.%UInt.as.Copy.impl.Op.specific_fn]
  303. // CHECK:STDOUT: %bound_method.loc9_1.4: <bound method> = bound_method %.loc9_1.2, %specific_fn.loc9_1.2 [concrete = constants.%bound_method.264]
  304. // CHECK:STDOUT: %UInt.as.Copy.impl.Op.call.loc9: init %u2 = call %bound_method.loc9_1.4(%.loc9_1.2) [concrete = constants.%int_3.975]
  305. // CHECK:STDOUT: %.loc9_1.4: ref %Ordering = temporary_storage
  306. // CHECK:STDOUT: %.loc9_1.5: ref %u2 = class_element_access %.loc9_1.4, element0
  307. // CHECK:STDOUT: %.loc9_1.6: init %u2 = initialize_from %UInt.as.Copy.impl.Op.call.loc9 to %.loc9_1.5 [concrete = constants.%int_3.975]
  308. // CHECK:STDOUT: %.loc9_1.7: init %Ordering = class_init (%.loc9_1.6), %.loc9_1.4 [concrete = constants.%Ordering.val.8a7]
  309. // CHECK:STDOUT: %.loc9_1.8: ref %Ordering = temporary %.loc9_1.4, %.loc9_1.7
  310. // CHECK:STDOUT: %.loc9_1.9: ref %Ordering = converted %.loc9_1.3, %.loc9_1.8
  311. // CHECK:STDOUT: %.loc9_1.10: %Ordering = acquire_value %.loc9_1.9
  312. // CHECK:STDOUT: %Incomparable: %Ordering = value_binding Incomparable, %.loc9_1.10
  313. // CHECK:STDOUT: complete_type_witness = %complete_type
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: !members:
  316. // CHECK:STDOUT: .Self = constants.%Ordering
  317. // CHECK:STDOUT: .Less = %Less
  318. // CHECK:STDOUT: .Equivalent = %Equivalent
  319. // CHECK:STDOUT: .Greater = %Greater
  320. // CHECK:STDOUT: .Incomparable = %Incomparable
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: fn @__global_init() {
  324. // CHECK:STDOUT: !entry:
  325. // CHECK:STDOUT: %Ordering.ref.loc11: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering]
  326. // CHECK:STDOUT: %Less.ref: %Ordering = name_ref Less, @Ordering.%Less
  327. // CHECK:STDOUT: %Ordering.ref.loc12: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering]
  328. // CHECK:STDOUT: %Equivalent.ref: %Ordering = name_ref Equivalent, @Ordering.%Equivalent
  329. // CHECK:STDOUT: %Ordering.ref.loc13: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering]
  330. // CHECK:STDOUT: %Greater.ref: %Ordering = name_ref Greater, @Ordering.%Greater
  331. // CHECK:STDOUT: %Ordering.ref.loc14: type = name_ref Ordering, file.%Ordering.decl [concrete = constants.%Ordering]
  332. // CHECK:STDOUT: %Incomparable.ref: %Ordering = name_ref Incomparable, @Ordering.%Incomparable
  333. // CHECK:STDOUT: <elided>
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT: