index.carbon 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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/overloaded/index.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/index.carbon
  10. // --- overloaded_index.carbon
  11. library "[[@TEST_NAME]]";
  12. class C {}
  13. class ElementType {}
  14. class SubscriptType {}
  15. impl C as Core.IndexWith(SubscriptType, ElementType) {
  16. fn At[self: Self](subscript: SubscriptType) -> ElementType {
  17. return {};
  18. }
  19. }
  20. let s: SubscriptType = {};
  21. let c: C = {};
  22. let x: ElementType = c[s];
  23. // --- overloaded_builtin.carbon
  24. library "[[@TEST_NAME]]";
  25. impl (i32, i32) as Core.IndexWith(i32, i32) {
  26. fn At[self: Self](subscript: i32) -> i32 {
  27. return self.0;
  28. }
  29. }
  30. let s: (i32, i32) = (1, 5);
  31. let e: i32 = s[0];
  32. // --- fail_invalid_subscript_type.carbon
  33. library "[[@TEST_NAME]]";
  34. class C { }
  35. class ElementType {}
  36. class SubscriptType {}
  37. impl C as Core.IndexWith(SubscriptType, ElementType) {
  38. fn At[self: Self](subscript: SubscriptType) -> ElementType {
  39. return {};
  40. }
  41. }
  42. let c: C = {};
  43. // CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+7]]:22: error: cannot implicitly convert from `Core.IntLiteral` to `SubscriptType` [ImplicitAsConversionFailure]
  44. // CHECK:STDERR: let x: ElementType = c[0];
  45. // CHECK:STDERR: ^~~~
  46. // CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+4]]:22: note: type `Core.IntLiteral` does not implement interface `ImplicitAs(SubscriptType)` [MissingImplInMemberAccessNote]
  47. // CHECK:STDERR: let x: ElementType = c[0];
  48. // CHECK:STDERR: ^~~~
  49. // CHECK:STDERR:
  50. let x: ElementType = c[0];
  51. // --- fail_index_with_not_implemented.carbon
  52. library "[[@TEST_NAME]]";
  53. class C { }
  54. let c: C = {};
  55. // CHECK:STDERR: fail_index_with_not_implemented.carbon:[[@LINE+3]]:14: error: type `C` does not support indexing [TypeNotIndexable]
  56. // CHECK:STDERR: let x: i32 = c[0];
  57. // CHECK:STDERR: ^~~~
  58. let x: i32 = c[0];
  59. // CHECK:STDOUT: --- overloaded_index.carbon
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: constants {
  62. // CHECK:STDOUT: %C: type = class_type @C [template]
  63. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  64. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  65. // CHECK:STDOUT: %ElementType.1: type = class_type @ElementType [template]
  66. // CHECK:STDOUT: %SubscriptType.1: type = class_type @SubscriptType [template]
  67. // CHECK:STDOUT: %IndexWith.type.1: type = generic_interface_type @IndexWith [template]
  68. // CHECK:STDOUT: %IndexWith: %IndexWith.type.1 = struct_value () [template]
  69. // CHECK:STDOUT: %IndexWith.type.3: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.1, %ElementType.1)> [template]
  70. // CHECK:STDOUT: %At.type.2: type = fn_type @At.2 [template]
  71. // CHECK:STDOUT: %At.2: %At.type.2 = struct_value () [template]
  72. // CHECK:STDOUT: %At.type.3: type = fn_type @At.1, @IndexWith(%SubscriptType.1, %ElementType.1) [template]
  73. // CHECK:STDOUT: %.7: <witness> = interface_witness (%At.2) [template]
  74. // CHECK:STDOUT: %struct.1: %ElementType.1 = struct_value () [template]
  75. // CHECK:STDOUT: %struct.2: %SubscriptType.1 = struct_value () [template]
  76. // CHECK:STDOUT: %struct.3: %C = struct_value () [template]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: imports {
  80. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  81. // CHECK:STDOUT: .IndexWith = %import_ref.1
  82. // CHECK:STDOUT: import Core//prelude
  83. // CHECK:STDOUT: import Core//prelude/...
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %import_ref.1: %IndexWith.type.1 = import_ref Core//prelude/operators/index, inst+13, loaded [template = constants.%IndexWith]
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: file {
  89. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  90. // CHECK:STDOUT: .Core = imports.%Core
  91. // CHECK:STDOUT: .C = %C.decl
  92. // CHECK:STDOUT: .ElementType = %ElementType.decl
  93. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  94. // CHECK:STDOUT: .s = @__global_init.%s
  95. // CHECK:STDOUT: .c = @__global_init.%c
  96. // CHECK:STDOUT: .x = @__global_init.%x
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: %Core.import = import Core
  99. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  100. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [template = constants.%ElementType.1] {} {}
  101. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [template = constants.%SubscriptType.1] {} {}
  102. // CHECK:STDOUT: impl_decl @impl [template] {} {
  103. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  104. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  105. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.1 = name_ref IndexWith, imports.%import_ref.1 [template = constants.%IndexWith]
  106. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  107. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  108. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1)> [template = constants.%IndexWith.type.3]
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, %SubscriptType.decl [template = constants.%SubscriptType.1]
  111. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  112. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.1]
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type {
  116. // CHECK:STDOUT: %At.decl: %At.type.2 = fn_decl @At.2 [template = constants.%At.2] {
  117. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  118. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  119. // CHECK:STDOUT: %subscript.patt: %SubscriptType.1 = binding_pattern subscript
  120. // CHECK:STDOUT: %subscript.param_patt: %SubscriptType.1 = value_param_pattern %subscript.patt, runtime_param1
  121. // CHECK:STDOUT: %return.patt: %ElementType.1 = return_slot_pattern
  122. // CHECK:STDOUT: %return.param_patt: %ElementType.1 = out_param_pattern %return.patt, runtime_param2
  123. // CHECK:STDOUT: } {
  124. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%C.ref [template = constants.%C]
  125. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  126. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  127. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  128. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  129. // CHECK:STDOUT: %subscript.param: %SubscriptType.1 = value_param runtime_param1
  130. // CHECK:STDOUT: %subscript: %SubscriptType.1 = bind_name subscript, %subscript.param
  131. // CHECK:STDOUT: %return.param: ref %ElementType.1 = out_param runtime_param2
  132. // CHECK:STDOUT: %return: ref %ElementType.1 = return_slot %return.param
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT: %.loc8: <witness> = interface_witness (%At.decl) [template = constants.%.7]
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: !members:
  137. // CHECK:STDOUT: .At = %At.decl
  138. // CHECK:STDOUT: witness = %.loc8
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: class @C {
  142. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: !members:
  145. // CHECK:STDOUT: .Self = constants.%C
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: class @ElementType {
  149. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: !members:
  152. // CHECK:STDOUT: .Self = constants.%ElementType.1
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: class @SubscriptType {
  156. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.1 [template = constants.%.2]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !members:
  159. // CHECK:STDOUT: .Self = constants.%SubscriptType.1
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: fn @At.2[%self.param_patt: %C](%subscript.param_patt: %SubscriptType.1) -> %return: %ElementType.1 {
  163. // CHECK:STDOUT: !entry:
  164. // CHECK:STDOUT: %.loc10_13.1: %.1 = struct_literal ()
  165. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.1 = class_init (), %return [template = constants.%struct.1]
  166. // CHECK:STDOUT: %.loc10_14: init %ElementType.1 = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.1]
  167. // CHECK:STDOUT: return %.loc10_14 to %return
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: fn @__global_init() {
  171. // CHECK:STDOUT: !entry:
  172. // CHECK:STDOUT: %.loc14_25.1: %.1 = struct_literal ()
  173. // CHECK:STDOUT: %.loc14_25.2: ref %SubscriptType.1 = temporary_storage
  174. // CHECK:STDOUT: %.loc14_25.3: init %SubscriptType.1 = class_init (), %.loc14_25.2 [template = constants.%struct.2]
  175. // CHECK:STDOUT: %.loc14_25.4: ref %SubscriptType.1 = temporary %.loc14_25.2, %.loc14_25.3
  176. // CHECK:STDOUT: %.loc14_26.1: ref %SubscriptType.1 = converted %.loc14_25.1, %.loc14_25.4
  177. // CHECK:STDOUT: %.loc14_26.2: %SubscriptType.1 = bind_value %.loc14_26.1
  178. // CHECK:STDOUT: %s: %SubscriptType.1 = bind_name s, %.loc14_26.2
  179. // CHECK:STDOUT: %.loc15_13.1: %.1 = struct_literal ()
  180. // CHECK:STDOUT: %.loc15_13.2: ref %C = temporary_storage
  181. // CHECK:STDOUT: %.loc15_13.3: init %C = class_init (), %.loc15_13.2 [template = constants.%struct.3]
  182. // CHECK:STDOUT: %.loc15_13.4: ref %C = temporary %.loc15_13.2, %.loc15_13.3
  183. // CHECK:STDOUT: %.loc15_14.1: ref %C = converted %.loc15_13.1, %.loc15_13.4
  184. // CHECK:STDOUT: %.loc15_14.2: %C = bind_value %.loc15_14.1
  185. // CHECK:STDOUT: %c: %C = bind_name c, %.loc15_14.2
  186. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  187. // CHECK:STDOUT: %s.ref: %SubscriptType.1 = name_ref s, %s
  188. // CHECK:STDOUT: %.loc16_25.1: %At.type.3 = interface_witness_access constants.%.7, element0 [template = constants.%At.2]
  189. // CHECK:STDOUT: %.loc16_25.2: <bound method> = bound_method %c.ref, %.loc16_25.1
  190. // CHECK:STDOUT: %.loc16_25.3: ref %ElementType.1 = temporary_storage
  191. // CHECK:STDOUT: %At.call: init %ElementType.1 = call %.loc16_25.2(%c.ref, %s.ref) to %.loc16_25.3
  192. // CHECK:STDOUT: %.loc16_25.4: ref %ElementType.1 = temporary %.loc16_25.3, %At.call
  193. // CHECK:STDOUT: %.loc16_25.5: %ElementType.1 = bind_value %.loc16_25.4
  194. // CHECK:STDOUT: %x: %ElementType.1 = bind_name x, %.loc16_25.5
  195. // CHECK:STDOUT: return
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: --- overloaded_builtin.carbon
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: constants {
  201. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  202. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  203. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  204. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  205. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
  206. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32, %i32) [template]
  207. // CHECK:STDOUT: %IndexWith.type.1: type = generic_interface_type @IndexWith [template]
  208. // CHECK:STDOUT: %IndexWith: %IndexWith.type.1 = struct_value () [template]
  209. // CHECK:STDOUT: %IndexWith.type.3: type = facet_type <@IndexWith, @IndexWith(%i32, %i32)> [template]
  210. // CHECK:STDOUT: %At.type.2: type = fn_type @At.2 [template]
  211. // CHECK:STDOUT: %At.2: %At.type.2 = struct_value () [template]
  212. // CHECK:STDOUT: %At.type.3: type = fn_type @At.1, @IndexWith(%i32, %i32) [template]
  213. // CHECK:STDOUT: %.6: <witness> = interface_witness (%At.2) [template]
  214. // CHECK:STDOUT: %.8: Core.IntLiteral = int_value 0 [template]
  215. // CHECK:STDOUT: %.9: Core.IntLiteral = int_value 1 [template]
  216. // CHECK:STDOUT: %.10: Core.IntLiteral = int_value 5 [template]
  217. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template]
  218. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  219. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.2(%.1) [template]
  220. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  221. // CHECK:STDOUT: %.30: <witness> = interface_witness (%Convert.14) [template]
  222. // CHECK:STDOUT: %.31: <bound method> = bound_method %.9, %Convert.14 [template]
  223. // CHECK:STDOUT: %.32: <specific function> = specific_function %.31, @Convert.2(%.1) [template]
  224. // CHECK:STDOUT: %.33: %i32 = int_value 1 [template]
  225. // CHECK:STDOUT: %.34: <bound method> = bound_method %.10, %Convert.14 [template]
  226. // CHECK:STDOUT: %.35: <specific function> = specific_function %.34, @Convert.2(%.1) [template]
  227. // CHECK:STDOUT: %.36: %i32 = int_value 5 [template]
  228. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.33, %.36) [template]
  229. // CHECK:STDOUT: %.37: <bound method> = bound_method %.8, %Convert.14 [template]
  230. // CHECK:STDOUT: %.38: <specific function> = specific_function %.37, @Convert.2(%.1) [template]
  231. // CHECK:STDOUT: %.39: %i32 = int_value 0 [template]
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: imports {
  235. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  236. // CHECK:STDOUT: .Int = %import_ref.1
  237. // CHECK:STDOUT: .IndexWith = %import_ref.2
  238. // CHECK:STDOUT: .ImplicitAs = %import_ref.7
  239. // CHECK:STDOUT: import Core//prelude
  240. // CHECK:STDOUT: import Core//prelude/...
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT: %import_ref.2: %IndexWith.type.1 = import_ref Core//prelude/operators/index, inst+13, loaded [template = constants.%IndexWith]
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: file {
  246. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  247. // CHECK:STDOUT: .Core = imports.%Core
  248. // CHECK:STDOUT: .s = @__global_init.%s
  249. // CHECK:STDOUT: .e = @__global_init.%e
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT: %Core.import = import Core
  252. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  253. // CHECK:STDOUT: %.loc4_7: Core.IntLiteral = int_value 32 [template = constants.%.1]
  254. // CHECK:STDOUT: %int.make_type_signed.loc4_7: init type = call constants.%Int(%.loc4_7) [template = constants.%i32]
  255. // CHECK:STDOUT: %.loc4_12: Core.IntLiteral = int_value 32 [template = constants.%.1]
  256. // CHECK:STDOUT: %int.make_type_signed.loc4_12: init type = call constants.%Int(%.loc4_12) [template = constants.%i32]
  257. // CHECK:STDOUT: %.loc4_15.1: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc4_7, %int.make_type_signed.loc4_12)
  258. // CHECK:STDOUT: %.loc4_15.2: type = value_of_initializer %int.make_type_signed.loc4_7 [template = constants.%i32]
  259. // CHECK:STDOUT: %.loc4_15.3: type = converted %int.make_type_signed.loc4_7, %.loc4_15.2 [template = constants.%i32]
  260. // CHECK:STDOUT: %.loc4_15.4: type = value_of_initializer %int.make_type_signed.loc4_12 [template = constants.%i32]
  261. // CHECK:STDOUT: %.loc4_15.5: type = converted %int.make_type_signed.loc4_12, %.loc4_15.4 [template = constants.%i32]
  262. // CHECK:STDOUT: %.loc4_15.6: type = converted %.loc4_15.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  263. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  264. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.1 = name_ref IndexWith, imports.%import_ref.2 [template = constants.%IndexWith]
  265. // CHECK:STDOUT: %.loc4_35: Core.IntLiteral = int_value 32 [template = constants.%.1]
  266. // CHECK:STDOUT: %int.make_type_signed.loc4_35: init type = call constants.%Int(%.loc4_35) [template = constants.%i32]
  267. // CHECK:STDOUT: %.loc4_40: Core.IntLiteral = int_value 32 [template = constants.%.1]
  268. // CHECK:STDOUT: %int.make_type_signed.loc4_40: init type = call constants.%Int(%.loc4_40) [template = constants.%i32]
  269. // CHECK:STDOUT: %.loc4_34.1: type = value_of_initializer %int.make_type_signed.loc4_35 [template = constants.%i32]
  270. // CHECK:STDOUT: %.loc4_34.2: type = converted %int.make_type_signed.loc4_35, %.loc4_34.1 [template = constants.%i32]
  271. // CHECK:STDOUT: %.loc4_34.3: type = value_of_initializer %int.make_type_signed.loc4_40 [template = constants.%i32]
  272. // CHECK:STDOUT: %.loc4_34.4: type = converted %int.make_type_signed.loc4_40, %.loc4_34.3 [template = constants.%i32]
  273. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%i32, constants.%i32)> [template = constants.%IndexWith.type.3]
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT: %.loc10_9: Core.IntLiteral = int_value 32 [template = constants.%.1]
  276. // CHECK:STDOUT: %int.make_type_signed.loc10_9: init type = call constants.%Int(%.loc10_9) [template = constants.%i32]
  277. // CHECK:STDOUT: %.loc10_14: Core.IntLiteral = int_value 32 [template = constants.%.1]
  278. // CHECK:STDOUT: %int.make_type_signed.loc10_14: init type = call constants.%Int(%.loc10_14) [template = constants.%i32]
  279. // CHECK:STDOUT: %.loc10_17.1: %tuple.type.1 = tuple_literal (%int.make_type_signed.loc10_9, %int.make_type_signed.loc10_14)
  280. // CHECK:STDOUT: %.loc10_17.2: type = value_of_initializer %int.make_type_signed.loc10_9 [template = constants.%i32]
  281. // CHECK:STDOUT: %.loc10_17.3: type = converted %int.make_type_signed.loc10_9, %.loc10_17.2 [template = constants.%i32]
  282. // CHECK:STDOUT: %.loc10_17.4: type = value_of_initializer %int.make_type_signed.loc10_14 [template = constants.%i32]
  283. // CHECK:STDOUT: %.loc10_17.5: type = converted %int.make_type_signed.loc10_14, %.loc10_17.4 [template = constants.%i32]
  284. // CHECK:STDOUT: %.loc10_17.6: type = converted %.loc10_17.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  285. // CHECK:STDOUT: %.loc11_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  286. // CHECK:STDOUT: %int.make_type_signed.loc11: init type = call constants.%Int(%.loc11_8.1) [template = constants.%i32]
  287. // CHECK:STDOUT: %.loc11_8.2: type = value_of_initializer %int.make_type_signed.loc11 [template = constants.%i32]
  288. // CHECK:STDOUT: %.loc11_8.3: type = converted %int.make_type_signed.loc11, %.loc11_8.2 [template = constants.%i32]
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: impl @impl.1: %.loc4_15.6 as %IndexWith.type {
  292. // CHECK:STDOUT: %At.decl: %At.type.2 = fn_decl @At.2 [template = constants.%At.2] {
  293. // CHECK:STDOUT: %self.patt: %tuple.type.2 = binding_pattern self
  294. // CHECK:STDOUT: %self.param_patt: %tuple.type.2 = value_param_pattern %self.patt, runtime_param0
  295. // CHECK:STDOUT: %subscript.patt: %i32 = binding_pattern subscript
  296. // CHECK:STDOUT: %subscript.param_patt: %i32 = value_param_pattern %subscript.patt, runtime_param1
  297. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  298. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param2
  299. // CHECK:STDOUT: } {
  300. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.1.%.loc4_15.6 [template = constants.%tuple.type.2]
  301. // CHECK:STDOUT: %.loc5_32.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  302. // CHECK:STDOUT: %int.make_type_signed.loc5_32: init type = call constants.%Int(%.loc5_32.1) [template = constants.%i32]
  303. // CHECK:STDOUT: %.loc5_32.2: type = value_of_initializer %int.make_type_signed.loc5_32 [template = constants.%i32]
  304. // CHECK:STDOUT: %.loc5_32.3: type = converted %int.make_type_signed.loc5_32, %.loc5_32.2 [template = constants.%i32]
  305. // CHECK:STDOUT: %.loc5_40.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  306. // CHECK:STDOUT: %int.make_type_signed.loc5_40: init type = call constants.%Int(%.loc5_40.1) [template = constants.%i32]
  307. // CHECK:STDOUT: %.loc5_40.2: type = value_of_initializer %int.make_type_signed.loc5_40 [template = constants.%i32]
  308. // CHECK:STDOUT: %.loc5_40.3: type = converted %int.make_type_signed.loc5_40, %.loc5_40.2 [template = constants.%i32]
  309. // CHECK:STDOUT: %self.param: %tuple.type.2 = value_param runtime_param0
  310. // CHECK:STDOUT: %self: %tuple.type.2 = bind_name self, %self.param
  311. // CHECK:STDOUT: %subscript.param: %i32 = value_param runtime_param1
  312. // CHECK:STDOUT: %subscript: %i32 = bind_name subscript, %subscript.param
  313. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2
  314. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT: %.loc4_45: <witness> = interface_witness (%At.decl) [template = constants.%.6]
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: !members:
  319. // CHECK:STDOUT: .At = %At.decl
  320. // CHECK:STDOUT: witness = %.loc4_45
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: fn @At.2[%self.param_patt: %tuple.type.2](%subscript.param_patt: %i32) -> %i32 {
  324. // CHECK:STDOUT: !entry:
  325. // CHECK:STDOUT: %self.ref: %tuple.type.2 = name_ref self, %self
  326. // CHECK:STDOUT: %.loc6_17: Core.IntLiteral = int_value 0 [template = constants.%.8]
  327. // CHECK:STDOUT: %.loc6_16: %i32 = tuple_access %self.ref, element0
  328. // CHECK:STDOUT: return %.loc6_16
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: fn @__global_init() {
  332. // CHECK:STDOUT: !entry:
  333. // CHECK:STDOUT: %.loc10_22: Core.IntLiteral = int_value 1 [template = constants.%.9]
  334. // CHECK:STDOUT: %.loc10_25: Core.IntLiteral = int_value 5 [template = constants.%.10]
  335. // CHECK:STDOUT: %.loc10_26.1: %tuple.type.3 = tuple_literal (%.loc10_22, %.loc10_25)
  336. // CHECK:STDOUT: %.loc10_26.2: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14]
  337. // CHECK:STDOUT: %.loc10_26.3: <bound method> = bound_method %.loc10_22, %.loc10_26.2 [template = constants.%.31]
  338. // CHECK:STDOUT: %.loc10_26.4: <specific function> = specific_function %.loc10_26.3, @Convert.2(constants.%.1) [template = constants.%.32]
  339. // CHECK:STDOUT: %int.convert_checked.loc10_26.1: init %i32 = call %.loc10_26.4(%.loc10_22) [template = constants.%.33]
  340. // CHECK:STDOUT: %.loc10_26.5: %i32 = value_of_initializer %int.convert_checked.loc10_26.1 [template = constants.%.33]
  341. // CHECK:STDOUT: %.loc10_26.6: %i32 = converted %.loc10_22, %.loc10_26.5 [template = constants.%.33]
  342. // CHECK:STDOUT: %.loc10_26.7: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14]
  343. // CHECK:STDOUT: %.loc10_26.8: <bound method> = bound_method %.loc10_25, %.loc10_26.7 [template = constants.%.34]
  344. // CHECK:STDOUT: %.loc10_26.9: <specific function> = specific_function %.loc10_26.8, @Convert.2(constants.%.1) [template = constants.%.35]
  345. // CHECK:STDOUT: %int.convert_checked.loc10_26.2: init %i32 = call %.loc10_26.9(%.loc10_25) [template = constants.%.36]
  346. // CHECK:STDOUT: %.loc10_26.10: %i32 = value_of_initializer %int.convert_checked.loc10_26.2 [template = constants.%.36]
  347. // CHECK:STDOUT: %.loc10_26.11: %i32 = converted %.loc10_25, %.loc10_26.10 [template = constants.%.36]
  348. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.loc10_26.6, %.loc10_26.11) [template = constants.%tuple]
  349. // CHECK:STDOUT: %.loc10_27: %tuple.type.2 = converted %.loc10_26.1, %tuple [template = constants.%tuple]
  350. // CHECK:STDOUT: %s: %tuple.type.2 = bind_name s, %.loc10_27
  351. // CHECK:STDOUT: %s.ref: %tuple.type.2 = name_ref s, %s
  352. // CHECK:STDOUT: %.loc11_16: Core.IntLiteral = int_value 0 [template = constants.%.8]
  353. // CHECK:STDOUT: %.loc11_17.1: %Convert.type.2 = interface_witness_access constants.%.30, element0 [template = constants.%Convert.14]
  354. // CHECK:STDOUT: %.loc11_17.2: <bound method> = bound_method %.loc11_16, %.loc11_17.1 [template = constants.%.37]
  355. // CHECK:STDOUT: %.loc11_17.3: <specific function> = specific_function %.loc11_17.2, @Convert.2(constants.%.1) [template = constants.%.38]
  356. // CHECK:STDOUT: %int.convert_checked.loc11: init %i32 = call %.loc11_17.3(%.loc11_16) [template = constants.%.39]
  357. // CHECK:STDOUT: %.loc11_17.4: %i32 = value_of_initializer %int.convert_checked.loc11 [template = constants.%.39]
  358. // CHECK:STDOUT: %.loc11_17.5: %i32 = converted %.loc11_16, %.loc11_17.4 [template = constants.%.39]
  359. // CHECK:STDOUT: %.loc11_17.6: %At.type.3 = interface_witness_access constants.%.6, element0 [template = constants.%At.2]
  360. // CHECK:STDOUT: %.loc11_17.7: <bound method> = bound_method %s.ref, %.loc11_17.6
  361. // CHECK:STDOUT: %At.call: init %i32 = call %.loc11_17.7(%s.ref, %.loc11_17.5)
  362. // CHECK:STDOUT: %.loc11_18.1: %i32 = value_of_initializer %At.call
  363. // CHECK:STDOUT: %.loc11_18.2: %i32 = converted %At.call, %.loc11_18.1
  364. // CHECK:STDOUT: %e: %i32 = bind_name e, %.loc11_18.2
  365. // CHECK:STDOUT: return
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: --- fail_invalid_subscript_type.carbon
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: constants {
  371. // CHECK:STDOUT: %C: type = class_type @C [template]
  372. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  373. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  374. // CHECK:STDOUT: %ElementType.1: type = class_type @ElementType [template]
  375. // CHECK:STDOUT: %SubscriptType.1: type = class_type @SubscriptType [template]
  376. // CHECK:STDOUT: %IndexWith.type.1: type = generic_interface_type @IndexWith [template]
  377. // CHECK:STDOUT: %IndexWith: %IndexWith.type.1 = struct_value () [template]
  378. // CHECK:STDOUT: %IndexWith.type.3: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.1, %ElementType.1)> [template]
  379. // CHECK:STDOUT: %At.type.2: type = fn_type @At.2 [template]
  380. // CHECK:STDOUT: %At.2: %At.type.2 = struct_value () [template]
  381. // CHECK:STDOUT: %At.type.3: type = fn_type @At.1, @IndexWith(%SubscriptType.1, %ElementType.1) [template]
  382. // CHECK:STDOUT: %.7: <witness> = interface_witness (%At.2) [template]
  383. // CHECK:STDOUT: %struct.1: %ElementType.1 = struct_value () [template]
  384. // CHECK:STDOUT: %struct.2: %C = struct_value () [template]
  385. // CHECK:STDOUT: %.9: Core.IntLiteral = int_value 0 [template]
  386. // CHECK:STDOUT: }
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: imports {
  389. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  390. // CHECK:STDOUT: .IndexWith = %import_ref.1
  391. // CHECK:STDOUT: .ImplicitAs = %import_ref.6
  392. // CHECK:STDOUT: import Core//prelude
  393. // CHECK:STDOUT: import Core//prelude/...
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT: %import_ref.1: %IndexWith.type.1 = import_ref Core//prelude/operators/index, inst+13, loaded [template = constants.%IndexWith]
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: file {
  399. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  400. // CHECK:STDOUT: .Core = imports.%Core
  401. // CHECK:STDOUT: .C = %C.decl
  402. // CHECK:STDOUT: .ElementType = %ElementType.decl
  403. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  404. // CHECK:STDOUT: .c = @__global_init.%c
  405. // CHECK:STDOUT: .x = @__global_init.%x
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT: %Core.import = import Core
  408. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  409. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [template = constants.%ElementType.1] {} {}
  410. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [template = constants.%SubscriptType.1] {} {}
  411. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  412. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  413. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  414. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.1 = name_ref IndexWith, imports.%import_ref.1 [template = constants.%IndexWith]
  415. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  416. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  417. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1)> [template = constants.%IndexWith.type.3]
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  420. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.1]
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: impl @impl.1: %C.ref as %IndexWith.type {
  424. // CHECK:STDOUT: %At.decl: %At.type.2 = fn_decl @At.2 [template = constants.%At.2] {
  425. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  426. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  427. // CHECK:STDOUT: %subscript.patt: %SubscriptType.1 = binding_pattern subscript
  428. // CHECK:STDOUT: %subscript.param_patt: %SubscriptType.1 = value_param_pattern %subscript.patt, runtime_param1
  429. // CHECK:STDOUT: %return.patt: %ElementType.1 = return_slot_pattern
  430. // CHECK:STDOUT: %return.param_patt: %ElementType.1 = out_param_pattern %return.patt, runtime_param2
  431. // CHECK:STDOUT: } {
  432. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.1.%C.ref [template = constants.%C]
  433. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  434. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  435. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  436. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  437. // CHECK:STDOUT: %subscript.param: %SubscriptType.1 = value_param runtime_param1
  438. // CHECK:STDOUT: %subscript: %SubscriptType.1 = bind_name subscript, %subscript.param
  439. // CHECK:STDOUT: %return.param: ref %ElementType.1 = out_param runtime_param2
  440. // CHECK:STDOUT: %return: ref %ElementType.1 = return_slot %return.param
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT: %.loc8: <witness> = interface_witness (%At.decl) [template = constants.%.7]
  443. // CHECK:STDOUT:
  444. // CHECK:STDOUT: !members:
  445. // CHECK:STDOUT: .At = %At.decl
  446. // CHECK:STDOUT: witness = %.loc8
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: class @C {
  450. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: !members:
  453. // CHECK:STDOUT: .Self = constants.%C
  454. // CHECK:STDOUT: }
  455. // CHECK:STDOUT:
  456. // CHECK:STDOUT: class @ElementType {
  457. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  458. // CHECK:STDOUT:
  459. // CHECK:STDOUT: !members:
  460. // CHECK:STDOUT: .Self = constants.%ElementType.1
  461. // CHECK:STDOUT: }
  462. // CHECK:STDOUT:
  463. // CHECK:STDOUT: class @SubscriptType {
  464. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.1 [template = constants.%.2]
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: !members:
  467. // CHECK:STDOUT: .Self = constants.%SubscriptType.1
  468. // CHECK:STDOUT: }
  469. // CHECK:STDOUT:
  470. // CHECK:STDOUT: fn @At.2[%self.param_patt: %C](%subscript.param_patt: %SubscriptType.1) -> %return: %ElementType.1 {
  471. // CHECK:STDOUT: !entry:
  472. // CHECK:STDOUT: %.loc10_13.1: %.1 = struct_literal ()
  473. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.1 = class_init (), %return [template = constants.%struct.1]
  474. // CHECK:STDOUT: %.loc10_14: init %ElementType.1 = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.1]
  475. // CHECK:STDOUT: return %.loc10_14 to %return
  476. // CHECK:STDOUT: }
  477. // CHECK:STDOUT:
  478. // CHECK:STDOUT: fn @__global_init() {
  479. // CHECK:STDOUT: !entry:
  480. // CHECK:STDOUT: %.loc14_13.1: %.1 = struct_literal ()
  481. // CHECK:STDOUT: %.loc14_13.2: ref %C = temporary_storage
  482. // CHECK:STDOUT: %.loc14_13.3: init %C = class_init (), %.loc14_13.2 [template = constants.%struct.2]
  483. // CHECK:STDOUT: %.loc14_13.4: ref %C = temporary %.loc14_13.2, %.loc14_13.3
  484. // CHECK:STDOUT: %.loc14_14.1: ref %C = converted %.loc14_13.1, %.loc14_13.4
  485. // CHECK:STDOUT: %.loc14_14.2: %C = bind_value %.loc14_14.1
  486. // CHECK:STDOUT: %c: %C = bind_name c, %.loc14_14.2
  487. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  488. // CHECK:STDOUT: %.loc22_24: Core.IntLiteral = int_value 0 [template = constants.%.9]
  489. // CHECK:STDOUT: %.loc22_25.1: %SubscriptType.1 = converted %.loc22_24, <error> [template = <error>]
  490. // CHECK:STDOUT: %.loc22_25.2: %At.type.3 = interface_witness_access constants.%.7, element0 [template = constants.%At.2]
  491. // CHECK:STDOUT: %.loc22_25.3: <bound method> = bound_method %c.ref, %.loc22_25.2
  492. // CHECK:STDOUT: %.loc22_25.4: ref %ElementType.1 = temporary_storage
  493. // CHECK:STDOUT: %At.call: init %ElementType.1 = call %.loc22_25.3(%c.ref, <error>) to %.loc22_25.4
  494. // CHECK:STDOUT: %.loc22_25.5: ref %ElementType.1 = temporary %.loc22_25.4, %At.call
  495. // CHECK:STDOUT: %.loc22_25.6: %ElementType.1 = bind_value %.loc22_25.5
  496. // CHECK:STDOUT: %x: %ElementType.1 = bind_name x, %.loc22_25.6
  497. // CHECK:STDOUT: return
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: --- fail_index_with_not_implemented.carbon
  501. // CHECK:STDOUT:
  502. // CHECK:STDOUT: constants {
  503. // CHECK:STDOUT: %C: type = class_type @C [template]
  504. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  505. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  506. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  507. // CHECK:STDOUT: %.4: Core.IntLiteral = int_value 32 [template]
  508. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  509. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  510. // CHECK:STDOUT: %i32: type = int_type signed, %.4 [template]
  511. // CHECK:STDOUT: %.5: Core.IntLiteral = int_value 0 [template]
  512. // CHECK:STDOUT: }
  513. // CHECK:STDOUT:
  514. // CHECK:STDOUT: imports {
  515. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  516. // CHECK:STDOUT: .Int = %import_ref.1
  517. // CHECK:STDOUT: .IndexWith = %import_ref.2
  518. // CHECK:STDOUT: import Core//prelude
  519. // CHECK:STDOUT: import Core//prelude/...
  520. // CHECK:STDOUT: }
  521. // CHECK:STDOUT: }
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: file {
  524. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  525. // CHECK:STDOUT: .Core = imports.%Core
  526. // CHECK:STDOUT: .C = %C.decl
  527. // CHECK:STDOUT: .c = @__global_init.%c
  528. // CHECK:STDOUT: .x = @__global_init.%x
  529. // CHECK:STDOUT: }
  530. // CHECK:STDOUT: %Core.import = import Core
  531. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  532. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  533. // CHECK:STDOUT: %.loc10_8.1: Core.IntLiteral = int_value 32 [template = constants.%.4]
  534. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc10_8.1) [template = constants.%i32]
  535. // CHECK:STDOUT: %.loc10_8.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  536. // CHECK:STDOUT: %.loc10_8.3: type = converted %int.make_type_signed, %.loc10_8.2 [template = constants.%i32]
  537. // CHECK:STDOUT: }
  538. // CHECK:STDOUT:
  539. // CHECK:STDOUT: class @C {
  540. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: !members:
  543. // CHECK:STDOUT: .Self = constants.%C
  544. // CHECK:STDOUT: }
  545. // CHECK:STDOUT:
  546. // CHECK:STDOUT: fn @__global_init() {
  547. // CHECK:STDOUT: !entry:
  548. // CHECK:STDOUT: %.loc6_13.1: %.1 = struct_literal ()
  549. // CHECK:STDOUT: %.loc6_13.2: ref %C = temporary_storage
  550. // CHECK:STDOUT: %.loc6_13.3: init %C = class_init (), %.loc6_13.2 [template = constants.%struct]
  551. // CHECK:STDOUT: %.loc6_13.4: ref %C = temporary %.loc6_13.2, %.loc6_13.3
  552. // CHECK:STDOUT: %.loc6_14.1: ref %C = converted %.loc6_13.1, %.loc6_13.4
  553. // CHECK:STDOUT: %.loc6_14.2: %C = bind_value %.loc6_14.1
  554. // CHECK:STDOUT: %c: %C = bind_name c, %.loc6_14.2
  555. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  556. // CHECK:STDOUT: %.loc10: Core.IntLiteral = int_value 0 [template = constants.%.5]
  557. // CHECK:STDOUT: %x: %i32 = bind_name x, <error>
  558. // CHECK:STDOUT: return
  559. // CHECK:STDOUT: }
  560. // CHECK:STDOUT: