index.carbon 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/index.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/index.carbon
  14. // --- core_wrong_index_with.carbon
  15. package Core library "[[@TEST_NAME]]";
  16. class IndexWith {}
  17. // --- fail_wrong_index_with.carbon
  18. library "[[@TEST_NAME]]";
  19. import Core library "core_wrong_index_with";
  20. // CHECK:STDERR: fail_wrong_index_with.carbon:[[@LINE+4]]:10: error: type `Core.IntLiteral` does not support indexing [TypeNotIndexable]
  21. // CHECK:STDERR: fn F() { 0[1]; }
  22. // CHECK:STDERR: ^~~~
  23. // CHECK:STDERR:
  24. fn F() { 0[1]; }
  25. // --- fail_missing_index_with.carbon
  26. library "[[@TEST_NAME]]";
  27. // CHECK:STDERR: fail_missing_index_with.carbon:[[@LINE+8]]:10: error: `Core.IndexWith` implicitly referenced here, but package `Core` not found [CoreNotFound]
  28. // CHECK:STDERR: fn F() { 0[1]; }
  29. // CHECK:STDERR: ^~~~
  30. // CHECK:STDERR:
  31. // CHECK:STDERR: fail_missing_index_with.carbon:[[@LINE+4]]:10: error: type `Core.IntLiteral` does not support indexing [TypeNotIndexable]
  32. // CHECK:STDERR: fn F() { 0[1]; }
  33. // CHECK:STDERR: ^~~~
  34. // CHECK:STDERR:
  35. fn F() { 0[1]; }
  36. // --- core_wrong_arg_count.carbon
  37. package Core library "[[@TEST_NAME]]";
  38. interface IndexWith(SubscriptType:! type) {
  39. fn At[self: Self](subscript: SubscriptType) -> ();
  40. }
  41. // --- wrong_arg_count.carbon
  42. library "[[@TEST_NAME]]";
  43. import Core library "core_wrong_arg_count";
  44. impl () as Core.IndexWith(()) {
  45. fn At[self: Self](subscript: ()) -> () {
  46. return ();
  47. }
  48. }
  49. fn F() { ()[()]; }
  50. // CHECK:STDOUT: --- core_wrong_index_with.carbon
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: constants {
  53. // CHECK:STDOUT: %IndexWith: type = class_type @IndexWith [concrete]
  54. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  55. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: file {
  59. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  60. // CHECK:STDOUT: .IndexWith = %IndexWith.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %IndexWith.decl: type = class_decl @IndexWith [concrete = constants.%IndexWith] {} {}
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: class @IndexWith {
  66. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  67. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  68. // CHECK:STDOUT: complete_type_witness = %complete_type
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: !members:
  71. // CHECK:STDOUT: .Self = constants.%IndexWith
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: --- fail_wrong_index_with.carbon
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: constants {
  77. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  78. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  79. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  80. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  81. // CHECK:STDOUT: %IndexWith: type = class_type @IndexWith [concrete]
  82. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  83. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: imports {
  87. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  88. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  89. // CHECK:STDOUT: import Core//core_wrong_index_with
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: %Core.IndexWith: type = import_ref Core//core_wrong_index_with, IndexWith, loaded [concrete = constants.%IndexWith]
  92. // CHECK:STDOUT: %Core.import_ref.8f2: <witness> = import_ref Core//core_wrong_index_with, loc4_18, loaded [concrete = constants.%complete_type]
  93. // CHECK:STDOUT: %Core.import_ref.4c7 = import_ref Core//core_wrong_index_with, inst17 [no loc], unloaded
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: file {
  97. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  98. // CHECK:STDOUT: .Core = imports.%Core
  99. // CHECK:STDOUT: .F = %F.decl
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: %Core.import = import Core
  102. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: class @IndexWith [from "core_wrong_index_with.carbon"] {
  106. // CHECK:STDOUT: complete_type_witness = imports.%Core.import_ref.8f2
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: !members:
  109. // CHECK:STDOUT: .Self = imports.%Core.import_ref.4c7
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: fn @F() {
  113. // CHECK:STDOUT: !entry:
  114. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  115. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  116. // CHECK:STDOUT: return
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: --- fail_missing_index_with.carbon
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: constants {
  122. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  123. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  124. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  125. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: file {
  129. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  130. // CHECK:STDOUT: .F = %F.decl
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: fn @F() {
  136. // CHECK:STDOUT: !entry:
  137. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  138. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  139. // CHECK:STDOUT: return
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: --- core_wrong_arg_count.carbon
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: constants {
  145. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  146. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  147. // CHECK:STDOUT: %IndexWith.type.68b: type = generic_interface_type @IndexWith [concrete]
  148. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  149. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.68b = struct_value () [concrete]
  150. // CHECK:STDOUT: %IndexWith.type.b94: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic]
  151. // CHECK:STDOUT: %Self: %IndexWith.type.b94 = bind_symbolic_name Self, 1 [symbolic]
  152. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  153. // CHECK:STDOUT: %pattern_type.2ad: type = pattern_type %Self.as_type [symbolic]
  154. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %SubscriptType [symbolic]
  155. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  156. // CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType) [symbolic]
  157. // CHECK:STDOUT: %IndexWith.At: %IndexWith.At.type = struct_value () [symbolic]
  158. // CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic]
  159. // CHECK:STDOUT: %assoc0: %IndexWith.assoc_type = assoc_entity element0, @IndexWith.%IndexWith.At.decl [symbolic]
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: file {
  163. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  164. // CHECK:STDOUT: .IndexWith = %IndexWith.decl
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT: %IndexWith.decl: %IndexWith.type.68b = interface_decl @IndexWith [concrete = constants.%IndexWith.generic] {
  167. // CHECK:STDOUT: %SubscriptType.patt: %pattern_type.98f = symbolic_binding_pattern SubscriptType, 0 [concrete]
  168. // CHECK:STDOUT: } {
  169. // CHECK:STDOUT: %SubscriptType.loc4_21.2: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType.loc4_21.1 (constants.%SubscriptType)]
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: generic interface @IndexWith(%SubscriptType.loc4_21.2: type) {
  174. // CHECK:STDOUT: %SubscriptType.loc4_21.1: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType.loc4_21.1 (constants.%SubscriptType)]
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: !definition:
  177. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.loc4_21.1)> [symbolic = %IndexWith.type (constants.%IndexWith.type.b94)]
  178. // CHECK:STDOUT: %Self.2: @IndexWith.%IndexWith.type (%IndexWith.type.b94) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  179. // CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType.loc4_21.1) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type)]
  180. // CHECK:STDOUT: %IndexWith.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type) = struct_value () [symbolic = %IndexWith.At (constants.%IndexWith.At)]
  181. // CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.loc4_21.1) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type)]
  182. // CHECK:STDOUT: %assoc0.loc5_52.2: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_52.2 (constants.%assoc0)]
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: interface {
  185. // CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.b94) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  186. // CHECK:STDOUT: %IndexWith.At.decl: @IndexWith.%IndexWith.At.type (%IndexWith.At.type) = fn_decl @IndexWith.At [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At)] {
  187. // CHECK:STDOUT: %self.patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.2ad) = binding_pattern self [concrete]
  188. // CHECK:STDOUT: %self.param_patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.2ad) = value_param_pattern %self.patt, call_param0 [concrete]
  189. // CHECK:STDOUT: %subscript.patt: @IndexWith.At.%pattern_type.loc5_21 (%pattern_type.7dc) = binding_pattern subscript [concrete]
  190. // CHECK:STDOUT: %subscript.param_patt: @IndexWith.At.%pattern_type.loc5_21 (%pattern_type.7dc) = value_param_pattern %subscript.patt, call_param1 [concrete]
  191. // CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern [concrete]
  192. // CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern %return.patt, call_param2 [concrete]
  193. // CHECK:STDOUT: } {
  194. // CHECK:STDOUT: %.loc5_51.1: %empty_tuple.type = tuple_literal ()
  195. // CHECK:STDOUT: %.loc5_51.2: type = converted %.loc5_51.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  196. // CHECK:STDOUT: %self.param: @IndexWith.At.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param call_param0
  197. // CHECK:STDOUT: %.loc5_15.1: type = splice_block %.loc5_15.3 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] {
  198. // CHECK:STDOUT: %.loc5_15.2: @IndexWith.At.%IndexWith.type (%IndexWith.type.b94) = specific_constant @IndexWith.%Self.1, @IndexWith(constants.%SubscriptType) [symbolic = %Self (constants.%Self)]
  199. // CHECK:STDOUT: %Self.ref: @IndexWith.At.%IndexWith.type (%IndexWith.type.b94) = name_ref Self, %.loc5_15.2 [symbolic = %Self (constants.%Self)]
  200. // CHECK:STDOUT: %Self.as_type.loc5_15.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  201. // CHECK:STDOUT: %.loc5_15.3: type = converted %Self.ref, %Self.as_type.loc5_15.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT: %self: @IndexWith.At.%Self.as_type.loc5_15.1 (%Self.as_type) = bind_name self, %self.param
  204. // CHECK:STDOUT: %subscript.param: @IndexWith.At.%SubscriptType (%SubscriptType) = value_param call_param1
  205. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, @IndexWith.%SubscriptType.loc4_21.2 [symbolic = %SubscriptType (constants.%SubscriptType)]
  206. // CHECK:STDOUT: %subscript: @IndexWith.At.%SubscriptType (%SubscriptType) = bind_name subscript, %subscript.param
  207. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param2
  208. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT: %assoc0.loc5_52.1: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_52.2 (constants.%assoc0)]
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: !members:
  213. // CHECK:STDOUT: .Self = %Self.1
  214. // CHECK:STDOUT: .SubscriptType = <poisoned>
  215. // CHECK:STDOUT: .At = %assoc0.loc5_52.1
  216. // CHECK:STDOUT: witness = (%IndexWith.At.decl)
  217. // CHECK:STDOUT: }
  218. // CHECK:STDOUT: }
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: generic fn @IndexWith.At(@IndexWith.%SubscriptType.loc4_21.2: type, @IndexWith.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.b94)) {
  221. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  222. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.b94)]
  223. // CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.b94) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  224. // CHECK:STDOUT: %Self.as_type.loc5_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  225. // CHECK:STDOUT: %pattern_type.loc5_9: type = pattern_type %Self.as_type.loc5_15.1 [symbolic = %pattern_type.loc5_9 (constants.%pattern_type.2ad)]
  226. // CHECK:STDOUT: %pattern_type.loc5_21: type = pattern_type %SubscriptType [symbolic = %pattern_type.loc5_21 (constants.%pattern_type.7dc)]
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: fn(%self.param: @IndexWith.At.%Self.as_type.loc5_15.1 (%Self.as_type), %subscript.param: @IndexWith.At.%SubscriptType (%SubscriptType)) -> %empty_tuple.type;
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType) {
  232. // CHECK:STDOUT: %SubscriptType.loc4_21.1 => constants.%SubscriptType
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%Self) {
  236. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  237. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.b94
  238. // CHECK:STDOUT: %Self => constants.%Self
  239. // CHECK:STDOUT: %Self.as_type.loc5_15.1 => constants.%Self.as_type
  240. // CHECK:STDOUT: %pattern_type.loc5_9 => constants.%pattern_type.2ad
  241. // CHECK:STDOUT: %pattern_type.loc5_21 => constants.%pattern_type.7dc
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: --- wrong_arg_count.carbon
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: constants {
  247. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  248. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  249. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  250. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  251. // CHECK:STDOUT: %IndexWith.type.bd2: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic]
  252. // CHECK:STDOUT: %Self.30a: %IndexWith.type.bd2 = bind_symbolic_name Self, 1 [symbolic]
  253. // CHECK:STDOUT: %IndexWith.At.type.cf4: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType) [symbolic]
  254. // CHECK:STDOUT: %IndexWith.At.281: %IndexWith.At.type.cf4 = struct_value () [symbolic]
  255. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  256. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.30a [symbolic]
  257. // CHECK:STDOUT: %pattern_type.e1a: type = pattern_type %Self.as_type [symbolic]
  258. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %SubscriptType [symbolic]
  259. // CHECK:STDOUT: %IndexWith.assoc_type.290: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic]
  260. // CHECK:STDOUT: %assoc0.af8: %IndexWith.assoc_type.290 = assoc_entity element0, imports.%Core.import_ref.e99 [symbolic]
  261. // CHECK:STDOUT: %IndexWith.type.a51: type = facet_type <@IndexWith, @IndexWith(%empty_tuple.type)> [concrete]
  262. // CHECK:STDOUT: %Self.8f0: %IndexWith.type.a51 = bind_symbolic_name Self, 1 [symbolic]
  263. // CHECK:STDOUT: %IndexWith.At.type.969: type = fn_type @IndexWith.At, @IndexWith(%empty_tuple.type) [concrete]
  264. // CHECK:STDOUT: %IndexWith.At.9b9: %IndexWith.At.type.969 = struct_value () [concrete]
  265. // CHECK:STDOUT: %IndexWith.assoc_type.3d4: type = assoc_entity_type @IndexWith, @IndexWith(%empty_tuple.type) [concrete]
  266. // CHECK:STDOUT: %assoc0.21b: %IndexWith.assoc_type.3d4 = assoc_entity element0, imports.%Core.import_ref.e99 [concrete]
  267. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness file.%IndexWith.impl_witness_table [concrete]
  268. // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.type: type = fn_type @empty_tuple.type.as.IndexWith.impl.At [concrete]
  269. // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At: %empty_tuple.type.as.IndexWith.impl.At.type = struct_value () [concrete]
  270. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.a51 = facet_value %empty_tuple.type, (%IndexWith.impl_witness) [concrete]
  271. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  272. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  273. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  274. // CHECK:STDOUT: %assoc0.e1e: %IndexWith.assoc_type.290 = assoc_entity element0, imports.%Core.import_ref.981 [symbolic]
  275. // CHECK:STDOUT: %.ffc: type = fn_type_with_self_type %IndexWith.At.type.969, %IndexWith.facet [concrete]
  276. // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.bound: <bound method> = bound_method %empty_tuple, %empty_tuple.type.as.IndexWith.impl.At [concrete]
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: imports {
  280. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  281. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  282. // CHECK:STDOUT: import Core//core_wrong_arg_count
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//core_wrong_arg_count, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  285. // CHECK:STDOUT: %Core.import_ref.5ab3ec.1: type = import_ref Core//core_wrong_arg_count, loc4_21, loaded [symbolic = @IndexWith.%SubscriptType (constants.%SubscriptType)]
  286. // CHECK:STDOUT: %Core.import_ref.68a = import_ref Core//core_wrong_arg_count, inst26 [no loc], unloaded
  287. // CHECK:STDOUT: %Core.import_ref.613: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.290) = import_ref Core//core_wrong_arg_count, loc5_52, loaded [symbolic = @IndexWith.%assoc0 (constants.%assoc0.e1e)]
  288. // CHECK:STDOUT: %Core.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.cf4) = import_ref Core//core_wrong_arg_count, At, loaded [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At.281)]
  289. // CHECK:STDOUT: %Core.import_ref.5ab3ec.2: type = import_ref Core//core_wrong_arg_count, loc4_21, loaded [symbolic = @IndexWith.%SubscriptType (constants.%SubscriptType)]
  290. // CHECK:STDOUT: %Core.import_ref.fb5: @IndexWith.%IndexWith.type (%IndexWith.type.bd2) = import_ref Core//core_wrong_arg_count, inst26 [no loc], loaded [symbolic = @IndexWith.%Self (constants.%Self.30a)]
  291. // CHECK:STDOUT: %Core.import_ref.e99: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.cf4) = import_ref Core//core_wrong_arg_count, loc5_52, loaded [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At.281)]
  292. // CHECK:STDOUT: %Core.import_ref.981 = import_ref Core//core_wrong_arg_count, loc5_52, unloaded
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: file {
  296. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  297. // CHECK:STDOUT: .Core = imports.%Core
  298. // CHECK:STDOUT: .F = %F.decl
  299. // CHECK:STDOUT: }
  300. // CHECK:STDOUT: %Core.import = import Core
  301. // CHECK:STDOUT: impl_decl @empty_tuple.type.as.IndexWith.impl [concrete] {} {
  302. // CHECK:STDOUT: %.loc6_7.1: %empty_tuple.type = tuple_literal ()
  303. // CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  304. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  305. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  306. // CHECK:STDOUT: %.loc6_28: %empty_tuple.type = tuple_literal ()
  307. // CHECK:STDOUT: %.loc6_29: type = converted %.loc6_28, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  308. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%empty_tuple.type)> [concrete = constants.%IndexWith.type.a51]
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (@empty_tuple.type.as.IndexWith.impl.%empty_tuple.type.as.IndexWith.impl.At.decl), @empty_tuple.type.as.IndexWith.impl [concrete]
  311. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  312. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: generic interface @IndexWith(imports.%Core.import_ref.5ab3ec.1: type) [from "core_wrong_arg_count.carbon"] {
  316. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: !definition:
  319. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.bd2)]
  320. // CHECK:STDOUT: %Self: @IndexWith.%IndexWith.type (%IndexWith.type.bd2) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.30a)]
  321. // CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type.cf4)]
  322. // CHECK:STDOUT: %IndexWith.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.cf4) = struct_value () [symbolic = %IndexWith.At (constants.%IndexWith.At.281)]
  323. // CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type.290)]
  324. // CHECK:STDOUT: %assoc0: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.290) = assoc_entity element0, imports.%Core.import_ref.e99 [symbolic = %assoc0 (constants.%assoc0.af8)]
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: interface {
  327. // CHECK:STDOUT: !members:
  328. // CHECK:STDOUT: .Self = imports.%Core.import_ref.68a
  329. // CHECK:STDOUT: .At = imports.%Core.import_ref.613
  330. // CHECK:STDOUT: witness = (imports.%Core.At)
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: impl @empty_tuple.type.as.IndexWith.impl: %.loc6_7.2 as %IndexWith.type {
  335. // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.decl: %empty_tuple.type.as.IndexWith.impl.At.type = fn_decl @empty_tuple.type.as.IndexWith.impl.At [concrete = constants.%empty_tuple.type.as.IndexWith.impl.At] {
  336. // CHECK:STDOUT: %self.patt: %pattern_type.cb1 = binding_pattern self [concrete]
  337. // CHECK:STDOUT: %self.param_patt: %pattern_type.cb1 = value_param_pattern %self.patt, call_param0 [concrete]
  338. // CHECK:STDOUT: %subscript.patt: %pattern_type.cb1 = binding_pattern subscript [concrete]
  339. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.cb1 = value_param_pattern %subscript.patt, call_param1 [concrete]
  340. // CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern [concrete]
  341. // CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern %return.patt, call_param2 [concrete]
  342. // CHECK:STDOUT: } {
  343. // CHECK:STDOUT: %.loc7_40.1: %empty_tuple.type = tuple_literal ()
  344. // CHECK:STDOUT: %.loc7_40.2: type = converted %.loc7_40.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  345. // CHECK:STDOUT: %self.param: %empty_tuple.type = value_param call_param0
  346. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @empty_tuple.type.as.IndexWith.impl.%.loc6_7.2 [concrete = constants.%empty_tuple.type]
  347. // CHECK:STDOUT: %self: %empty_tuple.type = bind_name self, %self.param
  348. // CHECK:STDOUT: %subscript.param: %empty_tuple.type = value_param call_param1
  349. // CHECK:STDOUT: %.loc7_33.1: type = splice_block %.loc7_33.3 [concrete = constants.%empty_tuple.type] {
  350. // CHECK:STDOUT: %.loc7_33.2: %empty_tuple.type = tuple_literal ()
  351. // CHECK:STDOUT: %.loc7_33.3: type = converted %.loc7_33.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: %subscript: %empty_tuple.type = bind_name subscript, %subscript.param
  354. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param2
  355. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: !members:
  359. // CHECK:STDOUT: .At = %empty_tuple.type.as.IndexWith.impl.At.decl
  360. // CHECK:STDOUT: witness = file.%IndexWith.impl_witness
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: generic fn @IndexWith.At(imports.%Core.import_ref.5ab3ec.2: type, imports.%Core.import_ref.fb5: @IndexWith.%IndexWith.type (%IndexWith.type.bd2)) [from "core_wrong_arg_count.carbon"] {
  364. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  365. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.bd2)]
  366. // CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.bd2) = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.30a)]
  367. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type)]
  368. // CHECK:STDOUT: %pattern_type.1: type = pattern_type %Self.as_type [symbolic = %pattern_type.1 (constants.%pattern_type.e1a)]
  369. // CHECK:STDOUT: %pattern_type.2: type = pattern_type %SubscriptType [symbolic = %pattern_type.2 (constants.%pattern_type.7dc)]
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: fn;
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: fn @empty_tuple.type.as.IndexWith.impl.At(%self.param: %empty_tuple.type, %subscript.param: %empty_tuple.type) -> %empty_tuple.type {
  375. // CHECK:STDOUT: !entry:
  376. // CHECK:STDOUT: %.loc8_13: %empty_tuple.type = tuple_literal ()
  377. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  378. // CHECK:STDOUT: %.loc8_14: %empty_tuple.type = converted %.loc8_13, %empty_tuple [concrete = constants.%empty_tuple]
  379. // CHECK:STDOUT: return %.loc8_14
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: fn @F() {
  383. // CHECK:STDOUT: !entry:
  384. // CHECK:STDOUT: %.loc12_11.1: %empty_tuple.type = tuple_literal ()
  385. // CHECK:STDOUT: %.loc12_14: %empty_tuple.type = tuple_literal ()
  386. // CHECK:STDOUT: %empty_tuple.loc12_11: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  387. // CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = converted %.loc12_11.1, %empty_tuple.loc12_11 [concrete = constants.%empty_tuple]
  388. // CHECK:STDOUT: %empty_tuple.loc12_14: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  389. // CHECK:STDOUT: %.loc12_15: %empty_tuple.type = converted %.loc12_14, %empty_tuple.loc12_14 [concrete = constants.%empty_tuple]
  390. // CHECK:STDOUT: %impl.elem0: %.ffc = impl_witness_access constants.%IndexWith.impl_witness, element0 [concrete = constants.%empty_tuple.type.as.IndexWith.impl.At]
  391. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc12_11.2, %impl.elem0 [concrete = constants.%empty_tuple.type.as.IndexWith.impl.At.bound]
  392. // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.call: init %empty_tuple.type = call %bound_method(%.loc12_11.2, %.loc12_15)
  393. // CHECK:STDOUT: return
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType) {
  397. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%Self.30a) {
  401. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  402. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.bd2
  403. // CHECK:STDOUT: %Self => constants.%Self.30a
  404. // CHECK:STDOUT: %Self.as_type => constants.%Self.as_type
  405. // CHECK:STDOUT: %pattern_type.1 => constants.%pattern_type.e1a
  406. // CHECK:STDOUT: %pattern_type.2 => constants.%pattern_type.7dc
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: specific @IndexWith(constants.%empty_tuple.type) {
  410. // CHECK:STDOUT: %SubscriptType => constants.%empty_tuple.type
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: !definition:
  413. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.a51
  414. // CHECK:STDOUT: %Self => constants.%Self.8f0
  415. // CHECK:STDOUT: %IndexWith.At.type => constants.%IndexWith.At.type.969
  416. // CHECK:STDOUT: %IndexWith.At => constants.%IndexWith.At.9b9
  417. // CHECK:STDOUT: %IndexWith.assoc_type => constants.%IndexWith.assoc_type.3d4
  418. // CHECK:STDOUT: %assoc0 => constants.%assoc0.21b
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: specific @IndexWith.At(constants.%empty_tuple.type, constants.%IndexWith.facet) {
  422. // CHECK:STDOUT: %SubscriptType => constants.%empty_tuple.type
  423. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.a51
  424. // CHECK:STDOUT: %Self => constants.%IndexWith.facet
  425. // CHECK:STDOUT: %Self.as_type => constants.%empty_tuple.type
  426. // CHECK:STDOUT: %pattern_type.1 => constants.%pattern_type.cb1
  427. // CHECK:STDOUT: %pattern_type.2 => constants.%pattern_type.cb1
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT: