index.carbon 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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: value of type `type` is not callable [CallToNonCallable]
  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+4]]: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. fn F() { 0[1]; }
  32. // --- core_wrong_arg_count.carbon
  33. package Core library "[[@TEST_NAME]]";
  34. interface IndexWith(SubscriptType:! type, ElementType:! type) {
  35. fn At[self: Self](subscript: SubscriptType) -> ElementType;
  36. }
  37. // --- fail_wrong_arg_count.carbon
  38. library "[[@TEST_NAME]]";
  39. import Core library "core_wrong_arg_count";
  40. impl () as Core.IndexWith((), ()) {
  41. fn At[self: Self](subscript: ()) -> () {
  42. return ();
  43. }
  44. }
  45. // CHECK:STDERR: fail_wrong_arg_count.carbon:[[@LINE+8]]:10: error: 1 argument passed to generic interface expecting 2 arguments [CallArgCountMismatch]
  46. // CHECK:STDERR: fn F() { ()[()]; }
  47. // CHECK:STDERR: ^~~~~~
  48. // CHECK:STDERR: fail_wrong_arg_count.carbon:[[@LINE-11]]:1: in import [InImport]
  49. // CHECK:STDERR: core_wrong_arg_count.carbon:4:1: note: calling generic interface declared here [InCallToEntity]
  50. // CHECK:STDERR: interface IndexWith(SubscriptType:! type, ElementType:! type) {
  51. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. // CHECK:STDERR:
  53. fn F() { ()[()]; }
  54. // CHECK:STDOUT: --- core_wrong_index_with.carbon
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: constants {
  57. // CHECK:STDOUT: %IndexWith: type = class_type @IndexWith [concrete]
  58. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  59. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: file {
  63. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  64. // CHECK:STDOUT: .IndexWith = %IndexWith.decl
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %IndexWith.decl: type = class_decl @IndexWith [concrete = constants.%IndexWith] {} {}
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: class @IndexWith {
  70. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  71. // CHECK:STDOUT: complete_type_witness = %complete_type
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !members:
  74. // CHECK:STDOUT: .Self = constants.%IndexWith
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: --- fail_wrong_index_with.carbon
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: constants {
  80. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  81. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  82. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  83. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  84. // CHECK:STDOUT: %IndexWith: type = class_type @IndexWith [concrete]
  85. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  86. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: imports {
  90. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  91. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  92. // CHECK:STDOUT: import Core//core_wrong_index_with
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %Core.IndexWith: type = import_ref Core//core_wrong_index_with, IndexWith, loaded [concrete = constants.%IndexWith]
  95. // CHECK:STDOUT: %Core.import_ref.8f2: <witness> = import_ref Core//core_wrong_index_with, loc{{\d+_\d+}}, loaded [concrete = constants.%complete_type]
  96. // CHECK:STDOUT: %Core.import_ref.4c7 = import_ref Core//core_wrong_index_with, inst{{[0-9A-F]+}} [no loc], unloaded
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: file {
  100. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  101. // CHECK:STDOUT: .Core = imports.%Core
  102. // CHECK:STDOUT: .F = %F.decl
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: %Core.import = import Core
  105. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: class @IndexWith [from "core_wrong_index_with.carbon"] {
  109. // CHECK:STDOUT: complete_type_witness = imports.%Core.import_ref.8f2
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: !members:
  112. // CHECK:STDOUT: .Self = imports.%Core.import_ref.4c7
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: fn @F() {
  116. // CHECK:STDOUT: !entry:
  117. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  118. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  119. // CHECK:STDOUT: return
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: --- fail_missing_index_with.carbon
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: constants {
  125. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  126. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  127. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  128. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: file {
  132. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  133. // CHECK:STDOUT: .F = %F.decl
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: fn @F() {
  139. // CHECK:STDOUT: !entry:
  140. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  141. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1]
  142. // CHECK:STDOUT: return
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: --- core_wrong_arg_count.carbon
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: constants {
  148. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  149. // CHECK:STDOUT: %.Self: %type = bind_symbolic_name .Self [symbolic_self]
  150. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  151. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  152. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic]
  153. // CHECK:STDOUT: %IndexWith.type.68b: type = generic_interface_type @IndexWith [concrete]
  154. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.68b = struct_value () [concrete]
  155. // CHECK:STDOUT: %IndexWith.type.472: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic]
  156. // CHECK:STDOUT: %Self: %IndexWith.type.472 = bind_symbolic_name Self, 2 [symbolic]
  157. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 2, %Self [symbolic]
  158. // CHECK:STDOUT: %pattern_type.072: type = pattern_type %Self.binding.as_type [symbolic]
  159. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %SubscriptType [symbolic]
  160. // CHECK:STDOUT: %pattern_type.a32: type = pattern_type %ElementType [symbolic]
  161. // CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  162. // CHECK:STDOUT: %IndexWith.At: %IndexWith.At.type = struct_value () [symbolic]
  163. // CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  164. // CHECK:STDOUT: %assoc0: %IndexWith.assoc_type = assoc_entity element0, @IndexWith.%IndexWith.At.decl [symbolic]
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: file {
  168. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  169. // CHECK:STDOUT: .IndexWith = %IndexWith.decl
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: %IndexWith.decl: %IndexWith.type.68b = interface_decl @IndexWith [concrete = constants.%IndexWith.generic] {
  172. // CHECK:STDOUT: %SubscriptType.patt: %pattern_type.98f = symbolic_binding_pattern SubscriptType, 0 [concrete]
  173. // CHECK:STDOUT: %ElementType.patt: %pattern_type.98f = symbolic_binding_pattern ElementType, 1 [concrete]
  174. // CHECK:STDOUT: } {
  175. // CHECK:STDOUT: %.Self.1: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  176. // CHECK:STDOUT: %SubscriptType.loc4_21.2: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType.loc4_21.1 (constants.%SubscriptType)]
  177. // CHECK:STDOUT: %.Self.2: %type = bind_symbolic_name .Self [symbolic_self = constants.%.Self]
  178. // CHECK:STDOUT: %ElementType.loc4_43.2: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType.loc4_43.1 (constants.%ElementType)]
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: generic interface @IndexWith(%SubscriptType.loc4_21.2: type, %ElementType.loc4_43.2: type) {
  183. // CHECK:STDOUT: %SubscriptType.loc4_21.1: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType.loc4_21.1 (constants.%SubscriptType)]
  184. // CHECK:STDOUT: %ElementType.loc4_43.1: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType.loc4_43.1 (constants.%ElementType)]
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: !definition:
  187. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.loc4_21.1, %ElementType.loc4_43.1)> [symbolic = %IndexWith.type (constants.%IndexWith.type.472)]
  188. // CHECK:STDOUT: %Self.2: @IndexWith.%IndexWith.type (%IndexWith.type.472) = bind_symbolic_name Self, 2 [symbolic = %Self.2 (constants.%Self)]
  189. // CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType.loc4_21.1, %ElementType.loc4_43.1) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type)]
  190. // CHECK:STDOUT: %IndexWith.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type) = struct_value () [symbolic = %IndexWith.At (constants.%IndexWith.At)]
  191. // CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.loc4_21.1, %ElementType.loc4_43.1) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type)]
  192. // CHECK:STDOUT: %assoc0.loc5_61.2: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_61.2 (constants.%assoc0)]
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: interface {
  195. // CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.472) = bind_symbolic_name Self, 2 [symbolic = %Self.2 (constants.%Self)]
  196. // CHECK:STDOUT: %IndexWith.At.decl: @IndexWith.%IndexWith.At.type (%IndexWith.At.type) = fn_decl @IndexWith.At [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At)] {
  197. // CHECK:STDOUT: %self.patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.072) = binding_pattern self [concrete]
  198. // CHECK:STDOUT: %self.param_patt: @IndexWith.At.%pattern_type.loc5_9 (%pattern_type.072) = value_param_pattern %self.patt, call_param0 [concrete]
  199. // CHECK:STDOUT: %subscript.patt: @IndexWith.At.%pattern_type.loc5_21 (%pattern_type.7dc) = binding_pattern subscript [concrete]
  200. // CHECK:STDOUT: %subscript.param_patt: @IndexWith.At.%pattern_type.loc5_21 (%pattern_type.7dc) = value_param_pattern %subscript.patt, call_param1 [concrete]
  201. // CHECK:STDOUT: %return.patt: @IndexWith.At.%pattern_type.loc5_47 (%pattern_type.a32) = return_slot_pattern [concrete]
  202. // CHECK:STDOUT: %return.param_patt: @IndexWith.At.%pattern_type.loc5_47 (%pattern_type.a32) = out_param_pattern %return.patt, call_param2 [concrete]
  203. // CHECK:STDOUT: } {
  204. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, @IndexWith.%ElementType.loc4_43.2 [symbolic = %ElementType (constants.%ElementType)]
  205. // CHECK:STDOUT: %self.param: @IndexWith.At.%Self.binding.as_type (%Self.binding.as_type) = value_param call_param0
  206. // CHECK:STDOUT: %.loc5_15.1: type = splice_block %.loc5_15.3 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)] {
  207. // CHECK:STDOUT: %.loc5_15.2: @IndexWith.At.%IndexWith.type (%IndexWith.type.472) = specific_constant @IndexWith.%Self.1, @IndexWith(constants.%SubscriptType, constants.%ElementType) [symbolic = %Self (constants.%Self)]
  208. // CHECK:STDOUT: %Self.ref: @IndexWith.At.%IndexWith.type (%IndexWith.type.472) = name_ref Self, %.loc5_15.2 [symbolic = %Self (constants.%Self)]
  209. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.ref [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  210. // CHECK:STDOUT: %.loc5_15.3: type = converted %Self.ref, %Self.as_type [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT: %self: @IndexWith.At.%Self.binding.as_type (%Self.binding.as_type) = bind_name self, %self.param
  213. // CHECK:STDOUT: %subscript.param: @IndexWith.At.%SubscriptType (%SubscriptType) = value_param call_param1
  214. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, @IndexWith.%SubscriptType.loc4_21.2 [symbolic = %SubscriptType (constants.%SubscriptType)]
  215. // CHECK:STDOUT: %subscript: @IndexWith.At.%SubscriptType (%SubscriptType) = bind_name subscript, %subscript.param
  216. // CHECK:STDOUT: %return.param: ref @IndexWith.At.%ElementType (%ElementType) = out_param call_param2
  217. // CHECK:STDOUT: %return: ref @IndexWith.At.%ElementType (%ElementType) = return_slot %return.param
  218. // CHECK:STDOUT: }
  219. // CHECK:STDOUT: %assoc0.loc5_61.1: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type) = assoc_entity element0, %IndexWith.At.decl [symbolic = %assoc0.loc5_61.2 (constants.%assoc0)]
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: !members:
  222. // CHECK:STDOUT: .Self = %Self.1
  223. // CHECK:STDOUT: .SubscriptType = <poisoned>
  224. // CHECK:STDOUT: .ElementType = <poisoned>
  225. // CHECK:STDOUT: .At = %assoc0.loc5_61.1
  226. // CHECK:STDOUT: witness = (%IndexWith.At.decl)
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: generic fn @IndexWith.At(@IndexWith.%SubscriptType.loc4_21.2: type, @IndexWith.%ElementType.loc4_43.2: type, @IndexWith.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.472)) {
  231. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  232. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)]
  233. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.472)]
  234. // CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.472) = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self)]
  235. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 2, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  236. // CHECK:STDOUT: %pattern_type.loc5_9: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type.loc5_9 (constants.%pattern_type.072)]
  237. // CHECK:STDOUT: %pattern_type.loc5_21: type = pattern_type %SubscriptType [symbolic = %pattern_type.loc5_21 (constants.%pattern_type.7dc)]
  238. // CHECK:STDOUT: %pattern_type.loc5_47: type = pattern_type %ElementType [symbolic = %pattern_type.loc5_47 (constants.%pattern_type.a32)]
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: fn(%self.param: @IndexWith.At.%Self.binding.as_type (%Self.binding.as_type), %subscript.param: @IndexWith.At.%SubscriptType (%SubscriptType)) -> @IndexWith.At.%ElementType (%ElementType);
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType, constants.%ElementType) {
  244. // CHECK:STDOUT: %SubscriptType.loc4_21.1 => constants.%SubscriptType
  245. // CHECK:STDOUT: %ElementType.loc4_43.1 => constants.%ElementType
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%ElementType, constants.%Self) {
  249. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  250. // CHECK:STDOUT: %ElementType => constants.%ElementType
  251. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.472
  252. // CHECK:STDOUT: %Self => constants.%Self
  253. // CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type
  254. // CHECK:STDOUT: %pattern_type.loc5_9 => constants.%pattern_type.072
  255. // CHECK:STDOUT: %pattern_type.loc5_21 => constants.%pattern_type.7dc
  256. // CHECK:STDOUT: %pattern_type.loc5_47 => constants.%pattern_type.a32
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT:
  259. // CHECK:STDOUT: --- fail_wrong_arg_count.carbon
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: constants {
  262. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  263. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  264. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  265. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic]
  266. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  267. // CHECK:STDOUT: %IndexWith.type.433: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic]
  268. // CHECK:STDOUT: %Self.0d0: %IndexWith.type.433 = bind_symbolic_name Self, 2 [symbolic]
  269. // CHECK:STDOUT: %IndexWith.At.type.8ac: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  270. // CHECK:STDOUT: %IndexWith.At.7c9: %IndexWith.At.type.8ac = struct_value () [symbolic]
  271. // CHECK:STDOUT: %pattern_type.a32: type = pattern_type %ElementType [symbolic]
  272. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 2, %Self.0d0 [symbolic]
  273. // CHECK:STDOUT: %pattern_type.41b: type = pattern_type %Self.binding.as_type [symbolic]
  274. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %SubscriptType [symbolic]
  275. // CHECK:STDOUT: %IndexWith.assoc_type.d60: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  276. // CHECK:STDOUT: %assoc0.b31: %IndexWith.assoc_type.d60 = assoc_entity element0, imports.%Core.import_ref.88c [symbolic]
  277. // CHECK:STDOUT: %IndexWith.type.5ee: type = facet_type <@IndexWith, @IndexWith(%empty_tuple.type, %empty_tuple.type)> [concrete]
  278. // CHECK:STDOUT: %Self.f42: %IndexWith.type.5ee = bind_symbolic_name Self, 2 [symbolic]
  279. // CHECK:STDOUT: %IndexWith.At.type.1a9: type = fn_type @IndexWith.At, @IndexWith(%empty_tuple.type, %empty_tuple.type) [concrete]
  280. // CHECK:STDOUT: %IndexWith.At.721: %IndexWith.At.type.1a9 = struct_value () [concrete]
  281. // CHECK:STDOUT: %IndexWith.assoc_type.d10: type = assoc_entity_type @IndexWith, @IndexWith(%empty_tuple.type, %empty_tuple.type) [concrete]
  282. // CHECK:STDOUT: %assoc0.239: %IndexWith.assoc_type.d10 = assoc_entity element0, imports.%Core.import_ref.88c [concrete]
  283. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness file.%IndexWith.impl_witness_table [concrete]
  284. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  285. // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At.type: type = fn_type @empty_tuple.type.as.IndexWith.impl.At [concrete]
  286. // CHECK:STDOUT: %empty_tuple.type.as.IndexWith.impl.At: %empty_tuple.type.as.IndexWith.impl.At.type = struct_value () [concrete]
  287. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.5ee = facet_value %empty_tuple.type, (%IndexWith.impl_witness) [concrete]
  288. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  289. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  290. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: imports {
  294. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  295. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  296. // CHECK:STDOUT: import Core//core_wrong_arg_count
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//core_wrong_arg_count, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  299. // CHECK:STDOUT: %Core.import_ref.5ab3ec.1: type = import_ref Core//core_wrong_arg_count, loc{{\d+_\d+}}, loaded [symbolic = @IndexWith.%SubscriptType (constants.%SubscriptType)]
  300. // CHECK:STDOUT: %Core.import_ref.9483a2.1: type = import_ref Core//core_wrong_arg_count, loc{{\d+_\d+}}, loaded [symbolic = @IndexWith.%ElementType (constants.%ElementType)]
  301. // CHECK:STDOUT: %Core.import_ref.e1e = import_ref Core//core_wrong_arg_count, inst{{[0-9A-F]+}} [no loc], unloaded
  302. // CHECK:STDOUT: %Core.import_ref.680 = import_ref Core//core_wrong_arg_count, loc{{\d+_\d+}}, unloaded
  303. // CHECK:STDOUT: %Core.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.8ac) = import_ref Core//core_wrong_arg_count, At, loaded [symbolic = @IndexWith.%IndexWith.At (constants.%IndexWith.At.7c9)]
  304. // CHECK:STDOUT: %Core.import_ref.5ab3ec.2: type = import_ref Core//core_wrong_arg_count, loc{{\d+_\d+}}, loaded [symbolic = @IndexWith.%SubscriptType (constants.%SubscriptType)]
  305. // CHECK:STDOUT: %Core.import_ref.9483a2.2: type = import_ref Core//core_wrong_arg_count, loc{{\d+_\d+}}, loaded [symbolic = @IndexWith.%ElementType (constants.%ElementType)]
  306. // CHECK:STDOUT: %Core.import_ref.e58: @IndexWith.%IndexWith.type (%IndexWith.type.433) = import_ref Core//core_wrong_arg_count, inst{{[0-9A-F]+}} [no loc], loaded [symbolic = @IndexWith.%Self (constants.%Self.0d0)]
  307. // CHECK:STDOUT: %Core.import_ref.88c = import_ref Core//core_wrong_arg_count, loc{{\d+_\d+}}, unloaded
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: file {
  311. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  312. // CHECK:STDOUT: .Core = imports.%Core
  313. // CHECK:STDOUT: .F = %F.decl
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT: %Core.import = import Core
  316. // CHECK:STDOUT: impl_decl @empty_tuple.type.as.IndexWith.impl [concrete] {} {
  317. // CHECK:STDOUT: %.loc6_7.1: %empty_tuple.type = tuple_literal ()
  318. // CHECK:STDOUT: %.loc6_7.2: type = converted %.loc6_7.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  319. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  320. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  321. // CHECK:STDOUT: %.loc6_28: %empty_tuple.type = tuple_literal ()
  322. // CHECK:STDOUT: %.loc6_32: %empty_tuple.type = tuple_literal ()
  323. // CHECK:STDOUT: %.loc6_33.1: type = converted %.loc6_28, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  324. // CHECK:STDOUT: %.loc6_33.2: type = converted %.loc6_32, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  325. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%empty_tuple.type, constants.%empty_tuple.type)> [concrete = constants.%IndexWith.type.5ee]
  326. // CHECK:STDOUT: }
  327. // 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]
  328. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  329. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: generic interface @IndexWith(imports.%Core.import_ref.5ab3ec.1: type, imports.%Core.import_ref.9483a2.1: type) [from "core_wrong_arg_count.carbon"] {
  333. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  334. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)]
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: !definition:
  337. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.433)]
  338. // CHECK:STDOUT: %Self: @IndexWith.%IndexWith.type (%IndexWith.type.433) = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.0d0)]
  339. // CHECK:STDOUT: %IndexWith.At.type: type = fn_type @IndexWith.At, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.At.type (constants.%IndexWith.At.type.8ac)]
  340. // CHECK:STDOUT: %IndexWith.At: @IndexWith.%IndexWith.At.type (%IndexWith.At.type.8ac) = struct_value () [symbolic = %IndexWith.At (constants.%IndexWith.At.7c9)]
  341. // CHECK:STDOUT: %IndexWith.assoc_type: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.assoc_type (constants.%IndexWith.assoc_type.d60)]
  342. // CHECK:STDOUT: %assoc0: @IndexWith.%IndexWith.assoc_type (%IndexWith.assoc_type.d60) = assoc_entity element0, imports.%Core.import_ref.88c [symbolic = %assoc0 (constants.%assoc0.b31)]
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: interface {
  345. // CHECK:STDOUT: !members:
  346. // CHECK:STDOUT: .Self = imports.%Core.import_ref.e1e
  347. // CHECK:STDOUT: .At = imports.%Core.import_ref.680
  348. // CHECK:STDOUT: witness = (imports.%Core.At)
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: impl @empty_tuple.type.as.IndexWith.impl: %.loc6_7.2 as %IndexWith.type {
  353. // 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] {
  354. // CHECK:STDOUT: %self.patt: %pattern_type.cb1 = binding_pattern self [concrete]
  355. // CHECK:STDOUT: %self.param_patt: %pattern_type.cb1 = value_param_pattern %self.patt, call_param0 [concrete]
  356. // CHECK:STDOUT: %subscript.patt: %pattern_type.cb1 = binding_pattern subscript [concrete]
  357. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.cb1 = value_param_pattern %subscript.patt, call_param1 [concrete]
  358. // CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern [concrete]
  359. // CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern %return.patt, call_param2 [concrete]
  360. // CHECK:STDOUT: } {
  361. // CHECK:STDOUT: %.loc7_40.1: %empty_tuple.type = tuple_literal ()
  362. // CHECK:STDOUT: %.loc7_40.2: type = converted %.loc7_40.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  363. // CHECK:STDOUT: %self.param: %empty_tuple.type = value_param call_param0
  364. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @empty_tuple.type.as.IndexWith.impl.%.loc6_7.2 [concrete = constants.%empty_tuple.type]
  365. // CHECK:STDOUT: %self: %empty_tuple.type = bind_name self, %self.param
  366. // CHECK:STDOUT: %subscript.param: %empty_tuple.type = value_param call_param1
  367. // CHECK:STDOUT: %.loc7_33.1: type = splice_block %.loc7_33.3 [concrete = constants.%empty_tuple.type] {
  368. // CHECK:STDOUT: %.loc7_33.2: %empty_tuple.type = tuple_literal ()
  369. // CHECK:STDOUT: %.loc7_33.3: type = converted %.loc7_33.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT: %subscript: %empty_tuple.type = bind_name subscript, %subscript.param
  372. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param2
  373. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: !members:
  377. // CHECK:STDOUT: .At = %empty_tuple.type.as.IndexWith.impl.At.decl
  378. // CHECK:STDOUT: witness = file.%IndexWith.impl_witness
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: generic fn @IndexWith.At(imports.%Core.import_ref.5ab3ec.2: type, imports.%Core.import_ref.9483a2.2: type, imports.%Core.import_ref.e58: @IndexWith.%IndexWith.type (%IndexWith.type.433)) [from "core_wrong_arg_count.carbon"] {
  382. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  383. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)]
  384. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType, %ElementType)> [symbolic = %IndexWith.type (constants.%IndexWith.type.433)]
  385. // CHECK:STDOUT: %Self: @IndexWith.At.%IndexWith.type (%IndexWith.type.433) = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.0d0)]
  386. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 2, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  387. // CHECK:STDOUT: %pattern_type.1: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type.1 (constants.%pattern_type.41b)]
  388. // CHECK:STDOUT: %pattern_type.2: type = pattern_type %SubscriptType [symbolic = %pattern_type.2 (constants.%pattern_type.7dc)]
  389. // CHECK:STDOUT: %pattern_type.3: type = pattern_type %ElementType [symbolic = %pattern_type.3 (constants.%pattern_type.a32)]
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: fn;
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: fn @empty_tuple.type.as.IndexWith.impl.At(%self.param: %empty_tuple.type, %subscript.param: %empty_tuple.type) -> %empty_tuple.type {
  395. // CHECK:STDOUT: !entry:
  396. // CHECK:STDOUT: %.loc8_13.1: %empty_tuple.type = tuple_literal ()
  397. // CHECK:STDOUT: %.loc8_13.2: init %empty_tuple.type = tuple_init () to %return [concrete = constants.%empty_tuple]
  398. // CHECK:STDOUT: %.loc8_14: init %empty_tuple.type = converted %.loc8_13.1, %.loc8_13.2 [concrete = constants.%empty_tuple]
  399. // CHECK:STDOUT: return %.loc8_14 to %return
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: fn @F() {
  403. // CHECK:STDOUT: !entry:
  404. // CHECK:STDOUT: %.loc20_11.1: %empty_tuple.type = tuple_literal ()
  405. // CHECK:STDOUT: %.loc20_14: %empty_tuple.type = tuple_literal ()
  406. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  407. // CHECK:STDOUT: %.loc20_11.2: %empty_tuple.type = converted %.loc20_11.1, %empty_tuple [concrete = constants.%empty_tuple]
  408. // CHECK:STDOUT: return
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT:
  411. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType, constants.%ElementType) {
  412. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  413. // CHECK:STDOUT: %ElementType => constants.%ElementType
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: specific @IndexWith.At(constants.%SubscriptType, constants.%ElementType, constants.%Self.0d0) {
  417. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  418. // CHECK:STDOUT: %ElementType => constants.%ElementType
  419. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.433
  420. // CHECK:STDOUT: %Self => constants.%Self.0d0
  421. // CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type
  422. // CHECK:STDOUT: %pattern_type.1 => constants.%pattern_type.41b
  423. // CHECK:STDOUT: %pattern_type.2 => constants.%pattern_type.7dc
  424. // CHECK:STDOUT: %pattern_type.3 => constants.%pattern_type.a32
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: specific @IndexWith(constants.%empty_tuple.type, constants.%empty_tuple.type) {
  428. // CHECK:STDOUT: %SubscriptType => constants.%empty_tuple.type
  429. // CHECK:STDOUT: %ElementType => constants.%empty_tuple.type
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: !definition:
  432. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.5ee
  433. // CHECK:STDOUT: %Self => constants.%Self.f42
  434. // CHECK:STDOUT: %IndexWith.At.type => constants.%IndexWith.At.type.1a9
  435. // CHECK:STDOUT: %IndexWith.At => constants.%IndexWith.At.721
  436. // CHECK:STDOUT: %IndexWith.assoc_type => constants.%IndexWith.assoc_type.d10
  437. // CHECK:STDOUT: %assoc0 => constants.%assoc0.239
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: specific @IndexWith.At(constants.%empty_tuple.type, constants.%empty_tuple.type, constants.%IndexWith.facet) {
  441. // CHECK:STDOUT: %SubscriptType => constants.%empty_tuple.type
  442. // CHECK:STDOUT: %ElementType => constants.%empty_tuple.type
  443. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.5ee
  444. // CHECK:STDOUT: %Self => constants.%IndexWith.facet
  445. // CHECK:STDOUT: %Self.binding.as_type => constants.%empty_tuple.type
  446. // CHECK:STDOUT: %pattern_type.1 => constants.%pattern_type.cb1
  447. // CHECK:STDOUT: %pattern_type.2 => constants.%pattern_type.cb1
  448. // CHECK:STDOUT: %pattern_type.3 => constants.%pattern_type.cb1
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT: