index.carbon 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  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 `Core.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+4]]:14: error: type `C` does not support indexing [TypeNotIndexable]
  56. // CHECK:STDERR: let x: i32 = c[0];
  57. // CHECK:STDERR: ^~~~
  58. // CHECK:STDERR:
  59. let x: i32 = c[0];
  60. // CHECK:STDOUT: --- overloaded_index.carbon
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: constants {
  63. // CHECK:STDOUT: %C: type = class_type @C [template]
  64. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  65. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  66. // CHECK:STDOUT: %ElementType.e6b: type = class_type @ElementType [template]
  67. // CHECK:STDOUT: %SubscriptType.8ee: type = class_type @SubscriptType [template]
  68. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [template]
  69. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [template]
  70. // CHECK:STDOUT: %IndexWith.type.e80: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee, %ElementType.e6b)> [template]
  71. // CHECK:STDOUT: %At.type.b3f: type = fn_type @At.1, @IndexWith(%SubscriptType.8ee, %ElementType.e6b) [template]
  72. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%At.decl) [template]
  73. // CHECK:STDOUT: %At.type.178: type = fn_type @At.2 [template]
  74. // CHECK:STDOUT: %At.d43: %At.type.178 = struct_value () [template]
  75. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.e80 = facet_value %C, %impl_witness [template]
  76. // CHECK:STDOUT: %ElementType.val: %ElementType.e6b = struct_value () [template]
  77. // CHECK:STDOUT: %SubscriptType.val: %SubscriptType.8ee = struct_value () [template]
  78. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  79. // CHECK:STDOUT: %.1a3: type = fn_type_with_self_type %At.type.b3f, %IndexWith.facet [template]
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: imports {
  83. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  84. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  85. // CHECK:STDOUT: import Core//prelude
  86. // CHECK:STDOUT: import Core//prelude/...
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [template = constants.%IndexWith.generic]
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: file {
  92. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  93. // CHECK:STDOUT: .Core = imports.%Core
  94. // CHECK:STDOUT: .C = %C.decl
  95. // CHECK:STDOUT: .ElementType = %ElementType.decl
  96. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  97. // CHECK:STDOUT: .s = %s
  98. // CHECK:STDOUT: .c = %c
  99. // CHECK:STDOUT: .x = %x
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: %Core.import = import Core
  102. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  103. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [template = constants.%ElementType.e6b] {} {}
  104. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [template = constants.%SubscriptType.8ee] {} {}
  105. // CHECK:STDOUT: impl_decl @impl [template] {} {
  106. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  107. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  108. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [template = constants.%IndexWith.generic]
  109. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.8ee]
  110. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.e6b]
  111. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [template = constants.%IndexWith.type.e80]
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%At.decl) [template = constants.%impl_witness]
  114. // CHECK:STDOUT: name_binding_decl {
  115. // CHECK:STDOUT: %s.patt: %SubscriptType.8ee = binding_pattern s
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, %SubscriptType.decl [template = constants.%SubscriptType.8ee]
  118. // CHECK:STDOUT: %.loc14_25.1: ref %SubscriptType.8ee = temporary_storage
  119. // CHECK:STDOUT: %.loc14_25.2: init %SubscriptType.8ee = class_init (), %.loc14_25.1 [template = constants.%SubscriptType.val]
  120. // CHECK:STDOUT: %.loc14_25.3: ref %SubscriptType.8ee = temporary %.loc14_25.1, %.loc14_25.2
  121. // CHECK:STDOUT: %.loc14_25.4: ref %SubscriptType.8ee = converted @__global_init.%.loc14, %.loc14_25.3
  122. // CHECK:STDOUT: %s: ref %SubscriptType.8ee = bind_name s, %.loc14_25.4
  123. // CHECK:STDOUT: name_binding_decl {
  124. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  127. // CHECK:STDOUT: %.loc15_13.1: ref %C = temporary_storage
  128. // CHECK:STDOUT: %.loc15_13.2: init %C = class_init (), %.loc15_13.1 [template = constants.%C.val]
  129. // CHECK:STDOUT: %.loc15_13.3: ref %C = temporary %.loc15_13.1, %.loc15_13.2
  130. // CHECK:STDOUT: %.loc15_13.4: ref %C = converted @__global_init.%.loc15, %.loc15_13.3
  131. // CHECK:STDOUT: %c: ref %C = bind_name c, %.loc15_13.4
  132. // CHECK:STDOUT: name_binding_decl {
  133. // CHECK:STDOUT: %x.patt: %ElementType.e6b = binding_pattern x
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.e6b]
  136. // CHECK:STDOUT: %.loc16: ref %ElementType.e6b = temporary @__global_init.%.loc16_25, @__global_init.%At.call
  137. // CHECK:STDOUT: %x: ref %ElementType.e6b = bind_name x, %.loc16
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type {
  141. // CHECK:STDOUT: %At.decl: %At.type.178 = fn_decl @At.2 [template = constants.%At.d43] {
  142. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  143. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  144. // CHECK:STDOUT: %subscript.patt: %SubscriptType.8ee = binding_pattern subscript
  145. // CHECK:STDOUT: %subscript.param_patt: %SubscriptType.8ee = value_param_pattern %subscript.patt, runtime_param1
  146. // CHECK:STDOUT: %return.patt: %ElementType.e6b = return_slot_pattern
  147. // CHECK:STDOUT: %return.param_patt: %ElementType.e6b = out_param_pattern %return.patt, runtime_param2
  148. // CHECK:STDOUT: } {
  149. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.e6b]
  150. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  151. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%C.ref [template = constants.%C]
  152. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  153. // CHECK:STDOUT: %subscript.param: %SubscriptType.8ee = value_param runtime_param1
  154. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.8ee]
  155. // CHECK:STDOUT: %subscript: %SubscriptType.8ee = bind_name subscript, %subscript.param
  156. // CHECK:STDOUT: %return.param: ref %ElementType.e6b = out_param runtime_param2
  157. // CHECK:STDOUT: %return: ref %ElementType.e6b = return_slot %return.param
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: !members:
  161. // CHECK:STDOUT: .At = %At.decl
  162. // CHECK:STDOUT: witness = file.%impl_witness
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: class @C {
  166. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  167. // CHECK:STDOUT: complete_type_witness = %complete_type
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: !members:
  170. // CHECK:STDOUT: .Self = constants.%C
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: class @ElementType {
  174. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  175. // CHECK:STDOUT: complete_type_witness = %complete_type
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: !members:
  178. // CHECK:STDOUT: .Self = constants.%ElementType.e6b
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: class @SubscriptType {
  182. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  183. // CHECK:STDOUT: complete_type_witness = %complete_type
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: !members:
  186. // CHECK:STDOUT: .Self = constants.%SubscriptType.8ee
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: fn @At.2[%self.param_patt: %C](%subscript.param_patt: %SubscriptType.8ee) -> %return.param_patt: %ElementType.e6b {
  190. // CHECK:STDOUT: !entry:
  191. // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal ()
  192. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.e6b = class_init (), %return [template = constants.%ElementType.val]
  193. // CHECK:STDOUT: %.loc10_14: init %ElementType.e6b = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%ElementType.val]
  194. // CHECK:STDOUT: return %.loc10_14 to %return
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: fn @__global_init() {
  198. // CHECK:STDOUT: !entry:
  199. // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal ()
  200. // CHECK:STDOUT: %.loc15: %empty_struct_type = struct_literal ()
  201. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
  202. // CHECK:STDOUT: %s.ref: ref %SubscriptType.8ee = name_ref s, file.%s
  203. // CHECK:STDOUT: %.loc16_24: %SubscriptType.8ee = bind_value %s.ref
  204. // CHECK:STDOUT: %impl.elem0: %.1a3 = impl_witness_access constants.%impl_witness, element0 [template = constants.%At.d43]
  205. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %c.ref, %impl.elem0
  206. // CHECK:STDOUT: %.loc16_25: ref %ElementType.e6b = temporary_storage
  207. // CHECK:STDOUT: %.loc16_22: %C = bind_value %c.ref
  208. // CHECK:STDOUT: %At.call: init %ElementType.e6b = call %bound_method(%.loc16_22, %.loc16_24) to %.loc16_25
  209. // CHECK:STDOUT: return
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: --- overloaded_builtin.carbon
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: constants {
  215. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  216. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  217. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [template]
  218. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [template]
  219. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [template]
  220. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [template]
  221. // CHECK:STDOUT: %IndexWith.type.917: type = facet_type <@IndexWith, @IndexWith(%i32, %i32)> [template]
  222. // CHECK:STDOUT: %At.type.d77: type = fn_type @At.1, @IndexWith(%i32, %i32) [template]
  223. // CHECK:STDOUT: %impl_witness.123: <witness> = impl_witness (@impl.1.%At.decl) [template]
  224. // CHECK:STDOUT: %At.type.9ac: type = fn_type @At.2 [template]
  225. // CHECK:STDOUT: %At.642: %At.type.9ac = struct_value () [template]
  226. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.917 = facet_value %tuple.type.d07, %impl_witness.123 [template]
  227. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template]
  228. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  229. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [template]
  230. // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [template]
  231. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  232. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  233. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.2(%int_32) [template]
  234. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.2(%int_32) [template]
  235. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  236. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  237. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  238. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  239. // CHECK:STDOUT: %Convert.specific_fn.70c: <specific function> = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template]
  240. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  241. // CHECK:STDOUT: %Convert.bound.4e6: <bound method> = bound_method %int_5.64b, %Convert.956 [template]
  242. // CHECK:STDOUT: %Convert.specific_fn.ba9: <specific function> = specific_function %Convert.bound.4e6, @Convert.2(%int_32) [template]
  243. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [template]
  244. // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_1.5d2, %int_5.0f6) [template]
  245. // CHECK:STDOUT: %Convert.bound.d04: <bound method> = bound_method %int_0.5c6, %Convert.956 [template]
  246. // CHECK:STDOUT: %Convert.specific_fn.d62: <specific function> = specific_function %Convert.bound.d04, @Convert.2(%int_32) [template]
  247. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template]
  248. // CHECK:STDOUT: %.252: type = fn_type_with_self_type %At.type.d77, %IndexWith.facet [template]
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: imports {
  252. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  253. // CHECK:STDOUT: .Int = %Core.Int
  254. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  255. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  256. // CHECK:STDOUT: import Core//prelude
  257. // CHECK:STDOUT: import Core//prelude/...
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [template = constants.%IndexWith.generic]
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: file {
  263. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  264. // CHECK:STDOUT: .Core = imports.%Core
  265. // CHECK:STDOUT: .s = %s
  266. // CHECK:STDOUT: .e = %e
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT: %Core.import = import Core
  269. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  270. // CHECK:STDOUT: %int_32.loc4_7: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  271. // CHECK:STDOUT: %i32.loc4_7: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  272. // CHECK:STDOUT: %int_32.loc4_12: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  273. // CHECK:STDOUT: %i32.loc4_12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  274. // CHECK:STDOUT: %.loc4_15.1: %tuple.type.24b = tuple_literal (%i32.loc4_7, %i32.loc4_12)
  275. // CHECK:STDOUT: %.loc4_15.2: type = converted %.loc4_15.1, constants.%tuple.type.d07 [template = constants.%tuple.type.d07]
  276. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  277. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [template = constants.%IndexWith.generic]
  278. // CHECK:STDOUT: %int_32.loc4_35: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  279. // CHECK:STDOUT: %i32.loc4_35: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  280. // CHECK:STDOUT: %int_32.loc4_40: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  281. // CHECK:STDOUT: %i32.loc4_40: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  282. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%i32, constants.%i32)> [template = constants.%IndexWith.type.917]
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.1.%At.decl) [template = constants.%impl_witness.123]
  285. // CHECK:STDOUT: name_binding_decl {
  286. // CHECK:STDOUT: %s.patt: %tuple.type.d07 = binding_pattern s
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT: %.loc10_17.1: type = splice_block %.loc10_17.3 [template = constants.%tuple.type.d07] {
  289. // CHECK:STDOUT: %int_32.loc10_9: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  290. // CHECK:STDOUT: %i32.loc10_9: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  291. // CHECK:STDOUT: %int_32.loc10_14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  292. // CHECK:STDOUT: %i32.loc10_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  293. // CHECK:STDOUT: %.loc10_17.2: %tuple.type.24b = tuple_literal (%i32.loc10_9, %i32.loc10_14)
  294. // CHECK:STDOUT: %.loc10_17.3: type = converted %.loc10_17.2, constants.%tuple.type.d07 [template = constants.%tuple.type.d07]
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT: %impl.elem0.loc10_26.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  297. // CHECK:STDOUT: %bound_method.loc10_26.1: <bound method> = bound_method @__global_init.%int_1, %impl.elem0.loc10_26.1 [template = constants.%Convert.bound.ab5]
  298. // CHECK:STDOUT: %specific_fn.loc10_26.1: <specific function> = specific_function %bound_method.loc10_26.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c]
  299. // CHECK:STDOUT: %int.convert_checked.loc10_26.1: init %i32 = call %specific_fn.loc10_26.1(@__global_init.%int_1) [template = constants.%int_1.5d2]
  300. // CHECK:STDOUT: %.loc10_26.1: %i32 = value_of_initializer %int.convert_checked.loc10_26.1 [template = constants.%int_1.5d2]
  301. // CHECK:STDOUT: %.loc10_26.2: %i32 = converted @__global_init.%int_1, %.loc10_26.1 [template = constants.%int_1.5d2]
  302. // CHECK:STDOUT: %impl.elem0.loc10_26.2: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  303. // CHECK:STDOUT: %bound_method.loc10_26.2: <bound method> = bound_method @__global_init.%int_5, %impl.elem0.loc10_26.2 [template = constants.%Convert.bound.4e6]
  304. // CHECK:STDOUT: %specific_fn.loc10_26.2: <specific function> = specific_function %bound_method.loc10_26.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.ba9]
  305. // CHECK:STDOUT: %int.convert_checked.loc10_26.2: init %i32 = call %specific_fn.loc10_26.2(@__global_init.%int_5) [template = constants.%int_5.0f6]
  306. // CHECK:STDOUT: %.loc10_26.3: %i32 = value_of_initializer %int.convert_checked.loc10_26.2 [template = constants.%int_5.0f6]
  307. // CHECK:STDOUT: %.loc10_26.4: %i32 = converted @__global_init.%int_5, %.loc10_26.3 [template = constants.%int_5.0f6]
  308. // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%.loc10_26.2, %.loc10_26.4) [template = constants.%tuple]
  309. // CHECK:STDOUT: %.loc10_26.5: %tuple.type.d07 = converted @__global_init.%.loc10, %tuple [template = constants.%tuple]
  310. // CHECK:STDOUT: %s: %tuple.type.d07 = bind_name s, %.loc10_26.5
  311. // CHECK:STDOUT: name_binding_decl {
  312. // CHECK:STDOUT: %e.patt: %i32 = binding_pattern e
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT: %.loc11_8: type = splice_block %i32.loc11 [template = constants.%i32] {
  315. // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  316. // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  317. // CHECK:STDOUT: }
  318. // CHECK:STDOUT: %.loc11_17.1: ref %i32 = temporary_storage
  319. // CHECK:STDOUT: %.loc11_17.2: ref %i32 = temporary %.loc11_17.1, @__global_init.%At.call
  320. // CHECK:STDOUT: %e: ref %i32 = bind_name e, %.loc11_17.2
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: impl @impl.1: %.loc4_15.2 as %IndexWith.type {
  324. // CHECK:STDOUT: %At.decl: %At.type.9ac = fn_decl @At.2 [template = constants.%At.642] {
  325. // CHECK:STDOUT: %self.patt: %tuple.type.d07 = binding_pattern self
  326. // CHECK:STDOUT: %self.param_patt: %tuple.type.d07 = value_param_pattern %self.patt, runtime_param0
  327. // CHECK:STDOUT: %subscript.patt: %i32 = binding_pattern subscript
  328. // CHECK:STDOUT: %subscript.param_patt: %i32 = value_param_pattern %subscript.patt, runtime_param1
  329. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  330. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param2
  331. // CHECK:STDOUT: } {
  332. // CHECK:STDOUT: %int_32.loc5_40: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  333. // CHECK:STDOUT: %i32.loc5_40: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  334. // CHECK:STDOUT: %self.param: %tuple.type.d07 = value_param runtime_param0
  335. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.1.%.loc4_15.2 [template = constants.%tuple.type.d07]
  336. // CHECK:STDOUT: %self: %tuple.type.d07 = bind_name self, %self.param
  337. // CHECK:STDOUT: %subscript.param: %i32 = value_param runtime_param1
  338. // CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5_32 [template = constants.%i32] {
  339. // CHECK:STDOUT: %int_32.loc5_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  340. // CHECK:STDOUT: %i32.loc5_32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT: %subscript: %i32 = bind_name subscript, %subscript.param
  343. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2
  344. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: !members:
  348. // CHECK:STDOUT: .At = %At.decl
  349. // CHECK:STDOUT: witness = file.%impl_witness
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: fn @At.2[%self.param_patt: %tuple.type.d07](%subscript.param_patt: %i32) -> %i32 {
  353. // CHECK:STDOUT: !entry:
  354. // CHECK:STDOUT: %self.ref: %tuple.type.d07 = name_ref self, %self
  355. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  356. // CHECK:STDOUT: %tuple.elem0: %i32 = tuple_access %self.ref, element0
  357. // CHECK:STDOUT: return %tuple.elem0
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: fn @__global_init() {
  361. // CHECK:STDOUT: !entry:
  362. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  363. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [template = constants.%int_5.64b]
  364. // CHECK:STDOUT: %.loc10: %tuple.type.f94 = tuple_literal (%int_1, %int_5)
  365. // CHECK:STDOUT: %s.ref: %tuple.type.d07 = name_ref s, file.%s
  366. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  367. // CHECK:STDOUT: %impl.elem0.loc11_17.1: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  368. // CHECK:STDOUT: %bound_method.loc11_17.1: <bound method> = bound_method %int_0, %impl.elem0.loc11_17.1 [template = constants.%Convert.bound.d04]
  369. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method.loc11_17.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.d62]
  370. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0) [template = constants.%int_0.6a9]
  371. // CHECK:STDOUT: %.loc11_17.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9]
  372. // CHECK:STDOUT: %.loc11_17.2: %i32 = converted %int_0, %.loc11_17.1 [template = constants.%int_0.6a9]
  373. // CHECK:STDOUT: %impl.elem0.loc11_17.2: %.252 = impl_witness_access constants.%impl_witness.123, element0 [template = constants.%At.642]
  374. // CHECK:STDOUT: %bound_method.loc11_17.2: <bound method> = bound_method %s.ref, %impl.elem0.loc11_17.2
  375. // CHECK:STDOUT: %At.call: init %i32 = call %bound_method.loc11_17.2(%s.ref, %.loc11_17.2)
  376. // CHECK:STDOUT: return
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: --- fail_invalid_subscript_type.carbon
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: constants {
  382. // CHECK:STDOUT: %C: type = class_type @C [template]
  383. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  384. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  385. // CHECK:STDOUT: %ElementType.e6b: type = class_type @ElementType [template]
  386. // CHECK:STDOUT: %SubscriptType.8ee: type = class_type @SubscriptType [template]
  387. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [template]
  388. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [template]
  389. // CHECK:STDOUT: %IndexWith.type.e80: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee, %ElementType.e6b)> [template]
  390. // CHECK:STDOUT: %At.type.b3f: type = fn_type @At.1, @IndexWith(%SubscriptType.8ee, %ElementType.e6b) [template]
  391. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%At.decl) [template]
  392. // CHECK:STDOUT: %At.type.178: type = fn_type @At.2 [template]
  393. // CHECK:STDOUT: %At.d43: %At.type.178 = struct_value () [template]
  394. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.e80 = facet_value %C, %impl_witness [template]
  395. // CHECK:STDOUT: %ElementType.val: %ElementType.e6b = struct_value () [template]
  396. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  397. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  398. // CHECK:STDOUT: %.1a3: type = fn_type_with_self_type %At.type.b3f, %IndexWith.facet [template]
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: imports {
  402. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  403. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  404. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  405. // CHECK:STDOUT: import Core//prelude
  406. // CHECK:STDOUT: import Core//prelude/...
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [template = constants.%IndexWith.generic]
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: file {
  412. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  413. // CHECK:STDOUT: .Core = imports.%Core
  414. // CHECK:STDOUT: .C = %C.decl
  415. // CHECK:STDOUT: .ElementType = %ElementType.decl
  416. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  417. // CHECK:STDOUT: .c = %c
  418. // CHECK:STDOUT: .x = %x
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT: %Core.import = import Core
  421. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  422. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [template = constants.%ElementType.e6b] {} {}
  423. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [template = constants.%SubscriptType.8ee] {} {}
  424. // CHECK:STDOUT: impl_decl @impl [template] {} {
  425. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  426. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  427. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [template = constants.%IndexWith.generic]
  428. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.8ee]
  429. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.e6b]
  430. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [template = constants.%IndexWith.type.e80]
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%At.decl) [template = constants.%impl_witness]
  433. // CHECK:STDOUT: name_binding_decl {
  434. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  437. // CHECK:STDOUT: %.loc14_13.1: ref %C = temporary_storage
  438. // CHECK:STDOUT: %.loc14_13.2: init %C = class_init (), %.loc14_13.1 [template = constants.%C.val]
  439. // CHECK:STDOUT: %.loc14_13.3: ref %C = temporary %.loc14_13.1, %.loc14_13.2
  440. // CHECK:STDOUT: %.loc14_13.4: ref %C = converted @__global_init.%.loc14, %.loc14_13.3
  441. // CHECK:STDOUT: %c: ref %C = bind_name c, %.loc14_13.4
  442. // CHECK:STDOUT: name_binding_decl {
  443. // CHECK:STDOUT: %x.patt: %ElementType.e6b = binding_pattern x
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.e6b]
  446. // CHECK:STDOUT: %.loc22: ref %ElementType.e6b = temporary @__global_init.%.loc22_25.2, @__global_init.%At.call
  447. // CHECK:STDOUT: %x: ref %ElementType.e6b = bind_name x, %.loc22
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type {
  451. // CHECK:STDOUT: %At.decl: %At.type.178 = fn_decl @At.2 [template = constants.%At.d43] {
  452. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  453. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  454. // CHECK:STDOUT: %subscript.patt: %SubscriptType.8ee = binding_pattern subscript
  455. // CHECK:STDOUT: %subscript.param_patt: %SubscriptType.8ee = value_param_pattern %subscript.patt, runtime_param1
  456. // CHECK:STDOUT: %return.patt: %ElementType.e6b = return_slot_pattern
  457. // CHECK:STDOUT: %return.param_patt: %ElementType.e6b = out_param_pattern %return.patt, runtime_param2
  458. // CHECK:STDOUT: } {
  459. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.e6b]
  460. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  461. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%C.ref [template = constants.%C]
  462. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  463. // CHECK:STDOUT: %subscript.param: %SubscriptType.8ee = value_param runtime_param1
  464. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.8ee]
  465. // CHECK:STDOUT: %subscript: %SubscriptType.8ee = bind_name subscript, %subscript.param
  466. // CHECK:STDOUT: %return.param: ref %ElementType.e6b = out_param runtime_param2
  467. // CHECK:STDOUT: %return: ref %ElementType.e6b = return_slot %return.param
  468. // CHECK:STDOUT: }
  469. // CHECK:STDOUT:
  470. // CHECK:STDOUT: !members:
  471. // CHECK:STDOUT: .At = %At.decl
  472. // CHECK:STDOUT: witness = file.%impl_witness
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT:
  475. // CHECK:STDOUT: class @C {
  476. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  477. // CHECK:STDOUT: complete_type_witness = %complete_type
  478. // CHECK:STDOUT:
  479. // CHECK:STDOUT: !members:
  480. // CHECK:STDOUT: .Self = constants.%C
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT:
  483. // CHECK:STDOUT: class @ElementType {
  484. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  485. // CHECK:STDOUT: complete_type_witness = %complete_type
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: !members:
  488. // CHECK:STDOUT: .Self = constants.%ElementType.e6b
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT:
  491. // CHECK:STDOUT: class @SubscriptType {
  492. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  493. // CHECK:STDOUT: complete_type_witness = %complete_type
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: !members:
  496. // CHECK:STDOUT: .Self = constants.%SubscriptType.8ee
  497. // CHECK:STDOUT: }
  498. // CHECK:STDOUT:
  499. // CHECK:STDOUT: fn @At.2[%self.param_patt: %C](%subscript.param_patt: %SubscriptType.8ee) -> %return.param_patt: %ElementType.e6b {
  500. // CHECK:STDOUT: !entry:
  501. // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal ()
  502. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.e6b = class_init (), %return [template = constants.%ElementType.val]
  503. // CHECK:STDOUT: %.loc10_14: init %ElementType.e6b = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%ElementType.val]
  504. // CHECK:STDOUT: return %.loc10_14 to %return
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: fn @__global_init() {
  508. // CHECK:STDOUT: !entry:
  509. // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal ()
  510. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
  511. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  512. // CHECK:STDOUT: %.loc22_25.1: %SubscriptType.8ee = converted %int_0, <error> [template = <error>]
  513. // CHECK:STDOUT: %impl.elem0: %.1a3 = impl_witness_access constants.%impl_witness, element0 [template = constants.%At.d43]
  514. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %c.ref, %impl.elem0
  515. // CHECK:STDOUT: %.loc22_25.2: ref %ElementType.e6b = temporary_storage
  516. // CHECK:STDOUT: %.loc22_22: %C = bind_value %c.ref
  517. // CHECK:STDOUT: %At.call: init %ElementType.e6b = call %bound_method(%.loc22_22, <error>) to %.loc22_25.2
  518. // CHECK:STDOUT: return
  519. // CHECK:STDOUT: }
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: --- fail_index_with_not_implemented.carbon
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: constants {
  524. // CHECK:STDOUT: %C: type = class_type @C [template]
  525. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  526. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  527. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  528. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  529. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  530. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT:
  533. // CHECK:STDOUT: imports {
  534. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  535. // CHECK:STDOUT: .Int = %Core.Int
  536. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  537. // CHECK:STDOUT: import Core//prelude
  538. // CHECK:STDOUT: import Core//prelude/...
  539. // CHECK:STDOUT: }
  540. // CHECK:STDOUT: }
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: file {
  543. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  544. // CHECK:STDOUT: .Core = imports.%Core
  545. // CHECK:STDOUT: .C = %C.decl
  546. // CHECK:STDOUT: .c = %c
  547. // CHECK:STDOUT: .x = %x
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: %Core.import = import Core
  550. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  551. // CHECK:STDOUT: name_binding_decl {
  552. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  553. // CHECK:STDOUT: }
  554. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  555. // CHECK:STDOUT: %.loc6_13.1: ref %C = temporary_storage
  556. // CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), %.loc6_13.1 [template = constants.%C.val]
  557. // CHECK:STDOUT: %.loc6_13.3: ref %C = temporary %.loc6_13.1, %.loc6_13.2
  558. // CHECK:STDOUT: %.loc6_13.4: ref %C = converted @__global_init.%.loc6, %.loc6_13.3
  559. // CHECK:STDOUT: %c: ref %C = bind_name c, %.loc6_13.4
  560. // CHECK:STDOUT: name_binding_decl {
  561. // CHECK:STDOUT: %x.patt: %i32 = binding_pattern x
  562. // CHECK:STDOUT: }
  563. // CHECK:STDOUT: %.loc11: type = splice_block %i32 [template = constants.%i32] {
  564. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  565. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  566. // CHECK:STDOUT: }
  567. // CHECK:STDOUT: %x: %i32 = bind_name x, <error>
  568. // CHECK:STDOUT: }
  569. // CHECK:STDOUT:
  570. // CHECK:STDOUT: class @C {
  571. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  572. // CHECK:STDOUT: complete_type_witness = %complete_type
  573. // CHECK:STDOUT:
  574. // CHECK:STDOUT: !members:
  575. // CHECK:STDOUT: .Self = constants.%C
  576. // CHECK:STDOUT: }
  577. // CHECK:STDOUT:
  578. // CHECK:STDOUT: fn @__global_init() {
  579. // CHECK:STDOUT: !entry:
  580. // CHECK:STDOUT: %.loc6: %empty_struct_type = struct_literal ()
  581. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
  582. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  583. // CHECK:STDOUT: return
  584. // CHECK:STDOUT: }
  585. // CHECK:STDOUT: