index.carbon 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/index.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/index.carbon
  13. // --- overloaded_index.carbon
  14. library "[[@TEST_NAME]]";
  15. class C {}
  16. class ElementType {}
  17. class SubscriptType {}
  18. impl C as Core.IndexWith(SubscriptType, ElementType) {
  19. fn At[self: Self](subscript: SubscriptType) -> ElementType {
  20. return {};
  21. }
  22. }
  23. let s: SubscriptType = {};
  24. let c: C = {};
  25. let x: ElementType = c[s];
  26. // --- overloaded_builtin.carbon
  27. library "[[@TEST_NAME]]";
  28. impl (i32, i32) as Core.IndexWith(i32, i32) {
  29. fn At[self: Self](subscript: i32) -> i32 {
  30. return self.0;
  31. }
  32. }
  33. let s: (i32, i32) = (1, 5);
  34. let e: i32 = s[0];
  35. // --- fail_invalid_subscript_type.carbon
  36. library "[[@TEST_NAME]]";
  37. class C { }
  38. class ElementType {}
  39. class SubscriptType {}
  40. impl C as Core.IndexWith(SubscriptType, ElementType) {
  41. fn At[self: Self](subscript: SubscriptType) -> ElementType {
  42. return {};
  43. }
  44. }
  45. let c: C = {};
  46. // CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+7]]:22: error: cannot implicitly convert expression of type `Core.IntLiteral` to `SubscriptType` [ConversionFailure]
  47. // CHECK:STDERR: let x: ElementType = c[0];
  48. // CHECK:STDERR: ^~~~
  49. // CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+4]]:22: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(SubscriptType)` [MissingImplInMemberAccessNote]
  50. // CHECK:STDERR: let x: ElementType = c[0];
  51. // CHECK:STDERR: ^~~~
  52. // CHECK:STDERR:
  53. let x: ElementType = c[0];
  54. // --- fail_index_with_not_implemented.carbon
  55. library "[[@TEST_NAME]]";
  56. class C { }
  57. let c: C = {};
  58. // CHECK:STDERR: fail_index_with_not_implemented.carbon:[[@LINE+4]]:14: error: type `C` does not support indexing [TypeNotIndexable]
  59. // CHECK:STDERR: let x: i32 = c[0];
  60. // CHECK:STDERR: ^~~~
  61. // CHECK:STDERR:
  62. let x: i32 = c[0];
  63. // CHECK:STDOUT: --- overloaded_index.carbon
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: constants {
  66. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  67. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  68. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  69. // CHECK:STDOUT: %ElementType.e6b: type = class_type @ElementType [concrete]
  70. // CHECK:STDOUT: %SubscriptType.8ee: type = class_type @SubscriptType [concrete]
  71. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  72. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  73. // CHECK:STDOUT: %IndexWith.type.e80: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee, %ElementType.e6b)> [concrete]
  74. // CHECK:STDOUT: %At.type.b3f: type = fn_type @At.1, @IndexWith(%SubscriptType.8ee, %ElementType.e6b) [concrete]
  75. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness file.%IndexWith.impl_witness_table [concrete]
  76. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  77. // CHECK:STDOUT: %pattern_type.df7: type = pattern_type %SubscriptType.8ee [concrete]
  78. // CHECK:STDOUT: %pattern_type.c39: type = pattern_type %ElementType.e6b [concrete]
  79. // CHECK:STDOUT: %At.type.178: type = fn_type @At.2 [concrete]
  80. // CHECK:STDOUT: %At.d43: %At.type.178 = struct_value () [concrete]
  81. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.e80 = facet_value %C, (%IndexWith.impl_witness) [concrete]
  82. // CHECK:STDOUT: %ElementType.val: %ElementType.e6b = struct_value () [concrete]
  83. // CHECK:STDOUT: %SubscriptType.val: %SubscriptType.8ee = struct_value () [concrete]
  84. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  85. // CHECK:STDOUT: %.d94: type = fn_type_with_self_type %At.type.b3f, %IndexWith.facet [concrete]
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: imports {
  89. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  90. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  91. // CHECK:STDOUT: import Core//prelude
  92. // CHECK:STDOUT: import Core//prelude/...
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: file {
  98. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  99. // CHECK:STDOUT: .Core = imports.%Core
  100. // CHECK:STDOUT: .C = %C.decl
  101. // CHECK:STDOUT: .ElementType = %ElementType.decl
  102. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  103. // CHECK:STDOUT: .s = %s
  104. // CHECK:STDOUT: .c = %c
  105. // CHECK:STDOUT: .x = %x
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT: %Core.import = import Core
  108. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  109. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [concrete = constants.%ElementType.e6b] {} {}
  110. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [concrete = constants.%SubscriptType.8ee] {} {}
  111. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  112. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  113. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  114. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  115. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee]
  116. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b]
  117. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [concrete = constants.%IndexWith.type.e80]
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@impl.%At.decl), @impl [concrete]
  120. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  121. // CHECK:STDOUT: name_binding_decl {
  122. // CHECK:STDOUT: %s.patt: %pattern_type.df7 = binding_pattern s [concrete]
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, %SubscriptType.decl [concrete = constants.%SubscriptType.8ee]
  125. // CHECK:STDOUT: %.loc14_25.1: ref %SubscriptType.8ee = temporary_storage
  126. // CHECK:STDOUT: %.loc14_25.2: init %SubscriptType.8ee = class_init (), %.loc14_25.1 [concrete = constants.%SubscriptType.val]
  127. // CHECK:STDOUT: %.loc14_25.3: ref %SubscriptType.8ee = temporary %.loc14_25.1, %.loc14_25.2
  128. // CHECK:STDOUT: %.loc14_25.4: ref %SubscriptType.8ee = converted @__global_init.%.loc14, %.loc14_25.3
  129. // CHECK:STDOUT: %s: ref %SubscriptType.8ee = bind_name s, %.loc14_25.4
  130. // CHECK:STDOUT: name_binding_decl {
  131. // CHECK:STDOUT: %c.patt: %pattern_type.c48 = binding_pattern c [concrete]
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  134. // CHECK:STDOUT: %.loc15_13.1: ref %C = temporary_storage
  135. // CHECK:STDOUT: %.loc15_13.2: init %C = class_init (), %.loc15_13.1 [concrete = constants.%C.val]
  136. // CHECK:STDOUT: %.loc15_13.3: ref %C = temporary %.loc15_13.1, %.loc15_13.2
  137. // CHECK:STDOUT: %.loc15_13.4: ref %C = converted @__global_init.%.loc15, %.loc15_13.3
  138. // CHECK:STDOUT: %c: ref %C = bind_name c, %.loc15_13.4
  139. // CHECK:STDOUT: name_binding_decl {
  140. // CHECK:STDOUT: %x.patt: %pattern_type.c39 = binding_pattern x [concrete]
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType.e6b]
  143. // CHECK:STDOUT: %.loc16: ref %ElementType.e6b = temporary @__global_init.%.loc16_25, @__global_init.%At.call
  144. // CHECK:STDOUT: %x: ref %ElementType.e6b = bind_name x, %.loc16
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type {
  148. // CHECK:STDOUT: %At.decl: %At.type.178 = fn_decl @At.2 [concrete = constants.%At.d43] {
  149. // CHECK:STDOUT: %self.patt: %pattern_type.c48 = binding_pattern self [concrete]
  150. // CHECK:STDOUT: %self.param_patt: %pattern_type.c48 = value_param_pattern %self.patt, call_param0 [concrete]
  151. // CHECK:STDOUT: %subscript.patt: %pattern_type.df7 = binding_pattern subscript [concrete]
  152. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.df7 = value_param_pattern %subscript.patt, call_param1 [concrete]
  153. // CHECK:STDOUT: %return.patt: %pattern_type.c39 = return_slot_pattern [concrete]
  154. // CHECK:STDOUT: %return.param_patt: %pattern_type.c39 = out_param_pattern %return.patt, call_param2 [concrete]
  155. // CHECK:STDOUT: } {
  156. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b]
  157. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  158. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%C.ref [concrete = constants.%C]
  159. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  160. // CHECK:STDOUT: %subscript.param: %SubscriptType.8ee = value_param call_param1
  161. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee]
  162. // CHECK:STDOUT: %subscript: %SubscriptType.8ee = bind_name subscript, %subscript.param
  163. // CHECK:STDOUT: %return.param: ref %ElementType.e6b = out_param call_param2
  164. // CHECK:STDOUT: %return: ref %ElementType.e6b = return_slot %return.param
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: !members:
  168. // CHECK:STDOUT: .SubscriptType = <poisoned>
  169. // CHECK:STDOUT: .ElementType = <poisoned>
  170. // CHECK:STDOUT: .At = %At.decl
  171. // CHECK:STDOUT: witness = file.%IndexWith.impl_witness
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: class @C {
  175. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  176. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  177. // CHECK:STDOUT: complete_type_witness = %complete_type
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: !members:
  180. // CHECK:STDOUT: .Self = constants.%C
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: class @ElementType {
  184. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  185. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  186. // CHECK:STDOUT: complete_type_witness = %complete_type
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !members:
  189. // CHECK:STDOUT: .Self = constants.%ElementType.e6b
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: class @SubscriptType {
  193. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  194. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  195. // CHECK:STDOUT: complete_type_witness = %complete_type
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: !members:
  198. // CHECK:STDOUT: .Self = constants.%SubscriptType.8ee
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: fn @At.2(%self.param: %C, %subscript.param: %SubscriptType.8ee) -> %return.param: %ElementType.e6b {
  202. // CHECK:STDOUT: !entry:
  203. // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal ()
  204. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.e6b = class_init (), %return [concrete = constants.%ElementType.val]
  205. // CHECK:STDOUT: %.loc10_14: init %ElementType.e6b = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val]
  206. // CHECK:STDOUT: return %.loc10_14 to %return
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: fn @__global_init() {
  210. // CHECK:STDOUT: !entry:
  211. // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal ()
  212. // CHECK:STDOUT: %.loc15: %empty_struct_type = struct_literal ()
  213. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
  214. // CHECK:STDOUT: %s.ref: ref %SubscriptType.8ee = name_ref s, file.%s
  215. // CHECK:STDOUT: %.loc16_24: %SubscriptType.8ee = bind_value %s.ref
  216. // CHECK:STDOUT: %impl.elem0: %.d94 = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%At.d43]
  217. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %c.ref, %impl.elem0
  218. // CHECK:STDOUT: %.loc16_25: ref %ElementType.e6b = temporary_storage
  219. // CHECK:STDOUT: %.loc16_22: %C = bind_value %c.ref
  220. // CHECK:STDOUT: %At.call: init %ElementType.e6b = call %bound_method(%.loc16_22, %.loc16_24) to %.loc16_25
  221. // CHECK:STDOUT: return
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: --- overloaded_builtin.carbon
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: constants {
  227. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  228. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  229. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  230. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  231. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  232. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete]
  233. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  234. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  235. // CHECK:STDOUT: %IndexWith.type.917: type = facet_type <@IndexWith, @IndexWith(%i32, %i32)> [concrete]
  236. // CHECK:STDOUT: %At.type.d77: type = fn_type @At.1, @IndexWith(%i32, %i32) [concrete]
  237. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness file.%IndexWith.impl_witness_table [concrete]
  238. // CHECK:STDOUT: %pattern_type.511: type = pattern_type %tuple.type.d07 [concrete]
  239. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  240. // CHECK:STDOUT: %At.type.9ac: type = fn_type @At.2 [concrete]
  241. // CHECK:STDOUT: %At.642: %At.type.9ac = struct_value () [concrete]
  242. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.917 = facet_value %tuple.type.d07, (%IndexWith.impl_witness) [concrete]
  243. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
  244. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  245. // CHECK:STDOUT: %int_5.64b: Core.IntLiteral = int_value 5 [concrete]
  246. // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [concrete]
  247. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  248. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  249. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  250. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  251. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  252. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  253. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  254. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  255. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  256. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  257. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  258. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  259. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  260. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  261. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  262. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  263. // CHECK:STDOUT: %Convert.bound.4e6: <bound method> = bound_method %int_5.64b, %Convert.956 [concrete]
  264. // CHECK:STDOUT: %bound_method.a25: <bound method> = bound_method %int_5.64b, %Convert.specific_fn [concrete]
  265. // CHECK:STDOUT: %int_5.0f6: %i32 = int_value 5 [concrete]
  266. // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%int_1.5d2, %int_5.0f6) [concrete]
  267. // CHECK:STDOUT: %Convert.bound.d04: <bound method> = bound_method %int_0.5c6, %Convert.956 [concrete]
  268. // CHECK:STDOUT: %bound_method.b6e: <bound method> = bound_method %int_0.5c6, %Convert.specific_fn [concrete]
  269. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
  270. // CHECK:STDOUT: %.2dc: type = fn_type_with_self_type %At.type.d77, %IndexWith.facet [concrete]
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: imports {
  274. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  275. // CHECK:STDOUT: .Int = %Core.Int
  276. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  277. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  278. // CHECK:STDOUT: import Core//prelude
  279. // CHECK:STDOUT: import Core//prelude/...
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  282. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  283. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  284. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  285. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: file {
  289. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  290. // CHECK:STDOUT: .Core = imports.%Core
  291. // CHECK:STDOUT: .s = %s
  292. // CHECK:STDOUT: .e = %e
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT: %Core.import = import Core
  295. // CHECK:STDOUT: impl_decl @impl.18b [concrete] {} {
  296. // CHECK:STDOUT: %int_32.loc4_7: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  297. // CHECK:STDOUT: %i32.loc4_7: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  298. // CHECK:STDOUT: %int_32.loc4_12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  299. // CHECK:STDOUT: %i32.loc4_12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  300. // CHECK:STDOUT: %.loc4_15.1: %tuple.type.24b = tuple_literal (%i32.loc4_7, %i32.loc4_12)
  301. // CHECK:STDOUT: %.loc4_15.2: type = converted %.loc4_15.1, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
  302. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  303. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  304. // CHECK:STDOUT: %int_32.loc4_35: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  305. // CHECK:STDOUT: %i32.loc4_35: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  306. // CHECK:STDOUT: %int_32.loc4_40: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  307. // CHECK:STDOUT: %i32.loc4_40: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  308. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%i32, constants.%i32)> [concrete = constants.%IndexWith.type.917]
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@impl.18b.%At.decl), @impl.18b [concrete]
  311. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  312. // CHECK:STDOUT: name_binding_decl {
  313. // CHECK:STDOUT: %s.patt: %pattern_type.511 = binding_pattern s [concrete]
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT: %.loc10_17.1: type = splice_block %.loc10_17.3 [concrete = constants.%tuple.type.d07] {
  316. // CHECK:STDOUT: %int_32.loc10_9: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  317. // CHECK:STDOUT: %i32.loc10_9: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  318. // CHECK:STDOUT: %int_32.loc10_14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  319. // CHECK:STDOUT: %i32.loc10_14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  320. // CHECK:STDOUT: %.loc10_17.2: %tuple.type.24b = tuple_literal (%i32.loc10_9, %i32.loc10_14)
  321. // CHECK:STDOUT: %.loc10_17.3: type = converted %.loc10_17.2, constants.%tuple.type.d07 [concrete = constants.%tuple.type.d07]
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT: %impl.elem0.loc10_26.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  324. // CHECK:STDOUT: %bound_method.loc10_26.1: <bound method> = bound_method @__global_init.%int_1, %impl.elem0.loc10_26.1 [concrete = constants.%Convert.bound.ab5]
  325. // CHECK:STDOUT: %specific_fn.loc10_26.1: <specific function> = specific_function %impl.elem0.loc10_26.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  326. // CHECK:STDOUT: %bound_method.loc10_26.2: <bound method> = bound_method @__global_init.%int_1, %specific_fn.loc10_26.1 [concrete = constants.%bound_method.9a1]
  327. // CHECK:STDOUT: %int.convert_checked.loc10_26.1: init %i32 = call %bound_method.loc10_26.2(@__global_init.%int_1) [concrete = constants.%int_1.5d2]
  328. // CHECK:STDOUT: %.loc10_26.1: %i32 = value_of_initializer %int.convert_checked.loc10_26.1 [concrete = constants.%int_1.5d2]
  329. // CHECK:STDOUT: %.loc10_26.2: %i32 = converted @__global_init.%int_1, %.loc10_26.1 [concrete = constants.%int_1.5d2]
  330. // CHECK:STDOUT: %impl.elem0.loc10_26.2: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  331. // CHECK:STDOUT: %bound_method.loc10_26.3: <bound method> = bound_method @__global_init.%int_5, %impl.elem0.loc10_26.2 [concrete = constants.%Convert.bound.4e6]
  332. // CHECK:STDOUT: %specific_fn.loc10_26.2: <specific function> = specific_function %impl.elem0.loc10_26.2, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  333. // CHECK:STDOUT: %bound_method.loc10_26.4: <bound method> = bound_method @__global_init.%int_5, %specific_fn.loc10_26.2 [concrete = constants.%bound_method.a25]
  334. // CHECK:STDOUT: %int.convert_checked.loc10_26.2: init %i32 = call %bound_method.loc10_26.4(@__global_init.%int_5) [concrete = constants.%int_5.0f6]
  335. // CHECK:STDOUT: %.loc10_26.3: %i32 = value_of_initializer %int.convert_checked.loc10_26.2 [concrete = constants.%int_5.0f6]
  336. // CHECK:STDOUT: %.loc10_26.4: %i32 = converted @__global_init.%int_5, %.loc10_26.3 [concrete = constants.%int_5.0f6]
  337. // CHECK:STDOUT: %tuple: %tuple.type.d07 = tuple_value (%.loc10_26.2, %.loc10_26.4) [concrete = constants.%tuple]
  338. // CHECK:STDOUT: %.loc10_26.5: %tuple.type.d07 = converted @__global_init.%.loc10, %tuple [concrete = constants.%tuple]
  339. // CHECK:STDOUT: %s: %tuple.type.d07 = bind_name s, %.loc10_26.5
  340. // CHECK:STDOUT: name_binding_decl {
  341. // CHECK:STDOUT: %e.patt: %pattern_type.7ce = binding_pattern e [concrete]
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT: %.loc11_8: type = splice_block %i32.loc11 [concrete = constants.%i32] {
  344. // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  345. // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: %.loc11_17.1: ref %i32 = temporary_storage
  348. // CHECK:STDOUT: %.loc11_17.2: ref %i32 = temporary %.loc11_17.1, @__global_init.%At.call
  349. // CHECK:STDOUT: %e: ref %i32 = bind_name e, %.loc11_17.2
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: impl @impl.18b: %.loc4_15.2 as %IndexWith.type {
  353. // CHECK:STDOUT: %At.decl: %At.type.9ac = fn_decl @At.2 [concrete = constants.%At.642] {
  354. // CHECK:STDOUT: %self.patt: %pattern_type.511 = binding_pattern self [concrete]
  355. // CHECK:STDOUT: %self.param_patt: %pattern_type.511 = value_param_pattern %self.patt, call_param0 [concrete]
  356. // CHECK:STDOUT: %subscript.patt: %pattern_type.7ce = binding_pattern subscript [concrete]
  357. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.7ce = value_param_pattern %subscript.patt, call_param1 [concrete]
  358. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  359. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param2 [concrete]
  360. // CHECK:STDOUT: } {
  361. // CHECK:STDOUT: %int_32.loc5_40: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  362. // CHECK:STDOUT: %i32.loc5_40: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  363. // CHECK:STDOUT: %self.param: %tuple.type.d07 = value_param call_param0
  364. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.18b.%.loc4_15.2 [concrete = constants.%tuple.type.d07]
  365. // CHECK:STDOUT: %self: %tuple.type.d07 = bind_name self, %self.param
  366. // CHECK:STDOUT: %subscript.param: %i32 = value_param call_param1
  367. // CHECK:STDOUT: %.loc5: type = splice_block %i32.loc5_32 [concrete = constants.%i32] {
  368. // CHECK:STDOUT: %int_32.loc5_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  369. // CHECK:STDOUT: %i32.loc5_32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT: %subscript: %i32 = bind_name subscript, %subscript.param
  372. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
  373. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: !members:
  377. // CHECK:STDOUT: .At = %At.decl
  378. // CHECK:STDOUT: witness = file.%IndexWith.impl_witness
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: fn @At.2(%self.param: %tuple.type.d07, %subscript.param: %i32) -> %i32 {
  382. // CHECK:STDOUT: !entry:
  383. // CHECK:STDOUT: %self.ref: %tuple.type.d07 = name_ref self, %self
  384. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
  385. // CHECK:STDOUT: %tuple.elem0: %i32 = tuple_access %self.ref, element0
  386. // CHECK:STDOUT: return %tuple.elem0
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: fn @__global_init() {
  390. // CHECK:STDOUT: !entry:
  391. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  392. // CHECK:STDOUT: %int_5: Core.IntLiteral = int_value 5 [concrete = constants.%int_5.64b]
  393. // CHECK:STDOUT: %.loc10: %tuple.type.f94 = tuple_literal (%int_1, %int_5)
  394. // CHECK:STDOUT: %s.ref: %tuple.type.d07 = name_ref s, file.%s
  395. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
  396. // CHECK:STDOUT: %impl.elem0.loc11_17.1: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  397. // CHECK:STDOUT: %bound_method.loc11_17.1: <bound method> = bound_method %int_0, %impl.elem0.loc11_17.1 [concrete = constants.%Convert.bound.d04]
  398. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0.loc11_17.1, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  399. // CHECK:STDOUT: %bound_method.loc11_17.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method.b6e]
  400. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc11_17.2(%int_0) [concrete = constants.%int_0.6a9]
  401. // CHECK:STDOUT: %.loc11_17.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_0.6a9]
  402. // CHECK:STDOUT: %.loc11_17.2: %i32 = converted %int_0, %.loc11_17.1 [concrete = constants.%int_0.6a9]
  403. // CHECK:STDOUT: %impl.elem0.loc11_17.2: %.2dc = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%At.642]
  404. // CHECK:STDOUT: %bound_method.loc11_17.3: <bound method> = bound_method %s.ref, %impl.elem0.loc11_17.2
  405. // CHECK:STDOUT: %At.call: init %i32 = call %bound_method.loc11_17.3(%s.ref, %.loc11_17.2)
  406. // CHECK:STDOUT: return
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: --- fail_invalid_subscript_type.carbon
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: constants {
  412. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  413. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  414. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  415. // CHECK:STDOUT: %ElementType.e6b: type = class_type @ElementType [concrete]
  416. // CHECK:STDOUT: %SubscriptType.8ee: type = class_type @SubscriptType [concrete]
  417. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  418. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  419. // CHECK:STDOUT: %IndexWith.type.e80: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.8ee, %ElementType.e6b)> [concrete]
  420. // CHECK:STDOUT: %At.type.b3f: type = fn_type @At.1, @IndexWith(%SubscriptType.8ee, %ElementType.e6b) [concrete]
  421. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness file.%IndexWith.impl_witness_table [concrete]
  422. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  423. // CHECK:STDOUT: %pattern_type.df7: type = pattern_type %SubscriptType.8ee [concrete]
  424. // CHECK:STDOUT: %pattern_type.c39: type = pattern_type %ElementType.e6b [concrete]
  425. // CHECK:STDOUT: %At.type.178: type = fn_type @At.2 [concrete]
  426. // CHECK:STDOUT: %At.d43: %At.type.178 = struct_value () [concrete]
  427. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.e80 = facet_value %C, (%IndexWith.impl_witness) [concrete]
  428. // CHECK:STDOUT: %ElementType.val: %ElementType.e6b = struct_value () [concrete]
  429. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  430. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  431. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  432. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  433. // CHECK:STDOUT: %.d94: type = fn_type_with_self_type %At.type.b3f, %IndexWith.facet [concrete]
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: imports {
  437. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  438. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  439. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  440. // CHECK:STDOUT: import Core//prelude
  441. // CHECK:STDOUT: import Core//prelude/...
  442. // CHECK:STDOUT: }
  443. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  444. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT:
  447. // CHECK:STDOUT: file {
  448. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  449. // CHECK:STDOUT: .Core = imports.%Core
  450. // CHECK:STDOUT: .C = %C.decl
  451. // CHECK:STDOUT: .ElementType = %ElementType.decl
  452. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  453. // CHECK:STDOUT: .c = %c
  454. // CHECK:STDOUT: .x = %x
  455. // CHECK:STDOUT: }
  456. // CHECK:STDOUT: %Core.import = import Core
  457. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  458. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [concrete = constants.%ElementType.e6b] {} {}
  459. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [concrete = constants.%SubscriptType.8ee] {} {}
  460. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  461. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  462. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  463. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  464. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee]
  465. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b]
  466. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.8ee, constants.%ElementType.e6b)> [concrete = constants.%IndexWith.type.e80]
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@impl.%At.decl), @impl [concrete]
  469. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  470. // CHECK:STDOUT: name_binding_decl {
  471. // CHECK:STDOUT: %c.patt: %pattern_type.c48 = binding_pattern c [concrete]
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  474. // CHECK:STDOUT: %.loc14_13.1: ref %C = temporary_storage
  475. // CHECK:STDOUT: %.loc14_13.2: init %C = class_init (), %.loc14_13.1 [concrete = constants.%C.val]
  476. // CHECK:STDOUT: %.loc14_13.3: ref %C = temporary %.loc14_13.1, %.loc14_13.2
  477. // CHECK:STDOUT: %.loc14_13.4: ref %C = converted @__global_init.%.loc14, %.loc14_13.3
  478. // CHECK:STDOUT: %c: ref %C = bind_name c, %.loc14_13.4
  479. // CHECK:STDOUT: name_binding_decl {
  480. // CHECK:STDOUT: %x.patt: %pattern_type.c39 = binding_pattern x [concrete]
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType.e6b]
  483. // CHECK:STDOUT: %.loc22: ref %ElementType.e6b = temporary @__global_init.%.loc22_25.2, @__global_init.%At.call
  484. // CHECK:STDOUT: %x: ref %ElementType.e6b = bind_name x, %.loc22
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type {
  488. // CHECK:STDOUT: %At.decl: %At.type.178 = fn_decl @At.2 [concrete = constants.%At.d43] {
  489. // CHECK:STDOUT: %self.patt: %pattern_type.c48 = binding_pattern self [concrete]
  490. // CHECK:STDOUT: %self.param_patt: %pattern_type.c48 = value_param_pattern %self.patt, call_param0 [concrete]
  491. // CHECK:STDOUT: %subscript.patt: %pattern_type.df7 = binding_pattern subscript [concrete]
  492. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.df7 = value_param_pattern %subscript.patt, call_param1 [concrete]
  493. // CHECK:STDOUT: %return.patt: %pattern_type.c39 = return_slot_pattern [concrete]
  494. // CHECK:STDOUT: %return.param_patt: %pattern_type.c39 = out_param_pattern %return.patt, call_param2 [concrete]
  495. // CHECK:STDOUT: } {
  496. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType.e6b]
  497. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  498. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%C.ref [concrete = constants.%C]
  499. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  500. // CHECK:STDOUT: %subscript.param: %SubscriptType.8ee = value_param call_param1
  501. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.8ee]
  502. // CHECK:STDOUT: %subscript: %SubscriptType.8ee = bind_name subscript, %subscript.param
  503. // CHECK:STDOUT: %return.param: ref %ElementType.e6b = out_param call_param2
  504. // CHECK:STDOUT: %return: ref %ElementType.e6b = return_slot %return.param
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: !members:
  508. // CHECK:STDOUT: .SubscriptType = <poisoned>
  509. // CHECK:STDOUT: .ElementType = <poisoned>
  510. // CHECK:STDOUT: .At = %At.decl
  511. // CHECK:STDOUT: witness = file.%IndexWith.impl_witness
  512. // CHECK:STDOUT: }
  513. // CHECK:STDOUT:
  514. // CHECK:STDOUT: class @C {
  515. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  516. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  517. // CHECK:STDOUT: complete_type_witness = %complete_type
  518. // CHECK:STDOUT:
  519. // CHECK:STDOUT: !members:
  520. // CHECK:STDOUT: .Self = constants.%C
  521. // CHECK:STDOUT: }
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: class @ElementType {
  524. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  525. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  526. // CHECK:STDOUT: complete_type_witness = %complete_type
  527. // CHECK:STDOUT:
  528. // CHECK:STDOUT: !members:
  529. // CHECK:STDOUT: .Self = constants.%ElementType.e6b
  530. // CHECK:STDOUT: }
  531. // CHECK:STDOUT:
  532. // CHECK:STDOUT: class @SubscriptType {
  533. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  534. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  535. // CHECK:STDOUT: complete_type_witness = %complete_type
  536. // CHECK:STDOUT:
  537. // CHECK:STDOUT: !members:
  538. // CHECK:STDOUT: .Self = constants.%SubscriptType.8ee
  539. // CHECK:STDOUT: }
  540. // CHECK:STDOUT:
  541. // CHECK:STDOUT: fn @At.2(%self.param: %C, %subscript.param: %SubscriptType.8ee) -> %return.param: %ElementType.e6b {
  542. // CHECK:STDOUT: !entry:
  543. // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal ()
  544. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.e6b = class_init (), %return [concrete = constants.%ElementType.val]
  545. // CHECK:STDOUT: %.loc10_14: init %ElementType.e6b = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val]
  546. // CHECK:STDOUT: return %.loc10_14 to %return
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: fn @__global_init() {
  550. // CHECK:STDOUT: !entry:
  551. // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal ()
  552. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
  553. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  554. // CHECK:STDOUT: %.loc22_25.1: %SubscriptType.8ee = converted %int_0, <error> [concrete = <error>]
  555. // CHECK:STDOUT: %impl.elem0: %.d94 = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%At.d43]
  556. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %c.ref, %impl.elem0
  557. // CHECK:STDOUT: %.loc22_25.2: ref %ElementType.e6b = temporary_storage
  558. // CHECK:STDOUT: %.loc22_22: %C = bind_value %c.ref
  559. // CHECK:STDOUT: %At.call: init %ElementType.e6b = call %bound_method(%.loc22_22, <error>) to %.loc22_25.2
  560. // CHECK:STDOUT: return
  561. // CHECK:STDOUT: }
  562. // CHECK:STDOUT:
  563. // CHECK:STDOUT: --- fail_index_with_not_implemented.carbon
  564. // CHECK:STDOUT:
  565. // CHECK:STDOUT: constants {
  566. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  567. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  568. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  569. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  570. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  571. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  572. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  573. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  574. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  575. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  576. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  577. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  578. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  579. // CHECK:STDOUT: }
  580. // CHECK:STDOUT:
  581. // CHECK:STDOUT: imports {
  582. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  583. // CHECK:STDOUT: .Int = %Core.Int
  584. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  585. // CHECK:STDOUT: import Core//prelude
  586. // CHECK:STDOUT: import Core//prelude/...
  587. // CHECK:STDOUT: }
  588. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  589. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  590. // CHECK:STDOUT: }
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: file {
  593. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  594. // CHECK:STDOUT: .Core = imports.%Core
  595. // CHECK:STDOUT: .C = %C.decl
  596. // CHECK:STDOUT: .c = %c
  597. // CHECK:STDOUT: .x = %x
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT: %Core.import = import Core
  600. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  601. // CHECK:STDOUT: name_binding_decl {
  602. // CHECK:STDOUT: %c.patt: %pattern_type.c48 = binding_pattern c [concrete]
  603. // CHECK:STDOUT: }
  604. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  605. // CHECK:STDOUT: %.loc6_13.1: ref %C = temporary_storage
  606. // CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), %.loc6_13.1 [concrete = constants.%C.val]
  607. // CHECK:STDOUT: %.loc6_13.3: ref %C = temporary %.loc6_13.1, %.loc6_13.2
  608. // CHECK:STDOUT: %.loc6_13.4: ref %C = converted @__global_init.%.loc6, %.loc6_13.3
  609. // CHECK:STDOUT: %c: ref %C = bind_name c, %.loc6_13.4
  610. // CHECK:STDOUT: name_binding_decl {
  611. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = binding_pattern x [concrete]
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT: %.loc11: type = splice_block %i32 [concrete = constants.%i32] {
  614. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  615. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  616. // CHECK:STDOUT: }
  617. // CHECK:STDOUT: %x: %i32 = bind_name x, <error> [concrete = <error>]
  618. // CHECK:STDOUT: }
  619. // CHECK:STDOUT:
  620. // CHECK:STDOUT: class @C {
  621. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  622. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type.357]
  623. // CHECK:STDOUT: complete_type_witness = %complete_type
  624. // CHECK:STDOUT:
  625. // CHECK:STDOUT: !members:
  626. // CHECK:STDOUT: .Self = constants.%C
  627. // CHECK:STDOUT: }
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: fn @__global_init() {
  630. // CHECK:STDOUT: !entry:
  631. // CHECK:STDOUT: %.loc6: %empty_struct_type = struct_literal ()
  632. // CHECK:STDOUT: %c.ref: ref %C = name_ref c, file.%c
  633. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  634. // CHECK:STDOUT: return
  635. // CHECK:STDOUT: }
  636. // CHECK:STDOUT: