index_with_prelude.carbon 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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/full.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_with_prelude.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_with_prelude.carbon
  14. // --- overloaded_index.carbon
  15. library "[[@TEST_NAME]]";
  16. class C {}
  17. class ElementType {}
  18. class SubscriptType {}
  19. impl C as Core.IndexWith(SubscriptType) where .ElementType = ElementType {
  20. fn At[unused self: Self](unused subscript: SubscriptType) -> ElementType {
  21. return {};
  22. }
  23. }
  24. let s: SubscriptType = {};
  25. let c: C = {};
  26. let x: ElementType = c[s];
  27. // --- overloaded_builtin.carbon
  28. library "[[@TEST_NAME]]";
  29. class C {
  30. adapt ();
  31. }
  32. impl (C, C) as Core.IndexWith(Core.IntLiteral()) where .ElementType = C {
  33. fn At[self: Self](unused subscript: Core.IntLiteral()) -> C {
  34. return self.0;
  35. }
  36. }
  37. let s: (C, C) = (() as C, () as C);
  38. let e: C = s[0];
  39. // --- fail_invalid_subscript_type.carbon
  40. library "[[@TEST_NAME]]";
  41. class C { }
  42. class ElementType {}
  43. class SubscriptType {}
  44. impl C as Core.IndexWith(SubscriptType) where .ElementType = ElementType {
  45. fn At[unused self: Self](unused subscript: SubscriptType) -> ElementType {
  46. return {};
  47. }
  48. }
  49. let c: C = {};
  50. // CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+4]]:22: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `C` that does not implement that interface [MissingImplInMemberAccess]
  51. // CHECK:STDERR: let x: ElementType = c[0];
  52. // CHECK:STDERR: ^~~~
  53. // CHECK:STDERR:
  54. let x: ElementType = c[0];
  55. // --- fail_index_with_not_implemented.carbon
  56. library "[[@TEST_NAME]]";
  57. class C { }
  58. let c: C = {};
  59. // CHECK:STDERR: fail_index_with_not_implemented.carbon:[[@LINE+4]]:14: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `C` that does not implement that interface [MissingImplInMemberAccess]
  60. // CHECK:STDERR: let x: i32 = c[0];
  61. // CHECK:STDERR: ^~~~
  62. // CHECK:STDERR:
  63. let x: i32 = c[0];
  64. // CHECK:STDOUT: --- overloaded_index.carbon
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: constants {
  67. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  68. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  69. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  70. // CHECK:STDOUT: %ElementType: type = class_type @ElementType.loc5 [concrete]
  71. // CHECK:STDOUT: %SubscriptType.9ec: type = class_type @SubscriptType [concrete]
  72. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  73. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  74. // CHECK:STDOUT: %SubscriptType.67d: type = symbolic_binding SubscriptType, 0 [symbolic]
  75. // CHECK:STDOUT: %IndexWith.assoc_type.a96: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.67d) [symbolic]
  76. // CHECK:STDOUT: %IndexWith.type.bbe: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.9ec)> [concrete]
  77. // CHECK:STDOUT: %.Self: %IndexWith.type.bbe = symbolic_binding .Self [symbolic_self]
  78. // CHECK:STDOUT: %IndexWith.assoc_type.b14: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.9ec) [concrete]
  79. // CHECK:STDOUT: %assoc0.ab8: %IndexWith.assoc_type.b14 = assoc_entity element0, imports.%Core.import_ref.434 [concrete]
  80. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
  81. // CHECK:STDOUT: %assoc0.f5a: %IndexWith.assoc_type.a96 = assoc_entity element0, imports.%Core.import_ref.d9b [symbolic]
  82. // CHECK:STDOUT: %IndexWith.lookup_impl_witness.407: <witness> = lookup_impl_witness %.Self, @IndexWith, @IndexWith(%SubscriptType.9ec) [symbolic_self]
  83. // CHECK:STDOUT: %impl.elem0.9d3: type = impl_witness_access %IndexWith.lookup_impl_witness.407, element0 [symbolic_self]
  84. // CHECK:STDOUT: %IndexWith_where.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.9ec) where %impl.elem0.9d3 = %ElementType> [concrete]
  85. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness @C.as.IndexWith.impl.%IndexWith.impl_witness_table [concrete]
  86. // CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
  87. // CHECK:STDOUT: %pattern_type.541: type = pattern_type %SubscriptType.9ec [concrete]
  88. // CHECK:STDOUT: %.312: Core.Form = init_form %ElementType [concrete]
  89. // CHECK:STDOUT: %pattern_type.fde: type = pattern_type %ElementType [concrete]
  90. // CHECK:STDOUT: %C.as.IndexWith.impl.At.type: type = fn_type @C.as.IndexWith.impl.At [concrete]
  91. // CHECK:STDOUT: %C.as.IndexWith.impl.At: %C.as.IndexWith.impl.At.type = struct_value () [concrete]
  92. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.bbe = facet_value %C, (%IndexWith.impl_witness) [concrete]
  93. // CHECK:STDOUT: %IndexWith.WithSelf.At.type.cc5: type = fn_type @IndexWith.WithSelf.At, @IndexWith.WithSelf(%SubscriptType.9ec, %IndexWith.facet) [concrete]
  94. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  95. // CHECK:STDOUT: %ElementType.val: %ElementType = struct_value () [concrete]
  96. // CHECK:STDOUT: %SubscriptType.val: %SubscriptType.9ec = struct_value () [concrete]
  97. // CHECK:STDOUT: %.e36: ref %SubscriptType.9ec = temporary invalid, %SubscriptType.val [concrete]
  98. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  99. // CHECK:STDOUT: %.5ea: ref %C = temporary invalid, %C.val [concrete]
  100. // CHECK:STDOUT: %.8f0: type = fn_type_with_self_type %IndexWith.WithSelf.At.type.cc5, %IndexWith.facet [concrete]
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: imports {
  104. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  105. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  106. // CHECK:STDOUT: import Core//prelude
  107. // CHECK:STDOUT: import Core//prelude/...
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  110. // CHECK:STDOUT: %Core.import_ref.c44: @IndexWith.WithSelf.%IndexWith.assoc_type (%IndexWith.assoc_type.a96) = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, loaded [symbolic = @IndexWith.WithSelf.%assoc0 (constants.%assoc0.f5a)]
  111. // CHECK:STDOUT: %Core.import_ref.434: type = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, loaded [concrete = %ElementType]
  112. // CHECK:STDOUT: %Core.import_ref.d9b = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, unloaded
  113. // CHECK:STDOUT: %ElementType: type = assoc_const_decl @ElementType.1 [concrete] {}
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: file {
  117. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  118. // CHECK:STDOUT: .Core = imports.%Core
  119. // CHECK:STDOUT: .C = %C.decl
  120. // CHECK:STDOUT: .ElementType = %ElementType.decl
  121. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  122. // CHECK:STDOUT: .s = %s
  123. // CHECK:STDOUT: .c = %c
  124. // CHECK:STDOUT: .x = %x
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: %Core.import = import Core
  127. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  128. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType.loc5 [concrete = constants.%ElementType] {} {}
  129. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [concrete = constants.%SubscriptType.9ec] {} {}
  130. // CHECK:STDOUT: impl_decl @C.as.IndexWith.impl [concrete] {} {
  131. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  132. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  133. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  134. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.9ec]
  135. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.9ec)> [concrete = constants.%IndexWith.type.bbe]
  136. // CHECK:STDOUT: %.Self: %IndexWith.type.bbe = symbolic_binding .Self [symbolic_self = constants.%.Self]
  137. // CHECK:STDOUT: %.Self.ref: %IndexWith.type.bbe = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  138. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
  139. // CHECK:STDOUT: %.loc8_47.1: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
  140. // CHECK:STDOUT: %.loc8_47.2: %IndexWith.assoc_type.b14 = specific_constant imports.%Core.import_ref.c44, @IndexWith.WithSelf(constants.%SubscriptType.9ec, constants.%.Self) [concrete = constants.%assoc0.ab8]
  141. // CHECK:STDOUT: %ElementType.ref.loc8_47: %IndexWith.assoc_type.b14 = name_ref ElementType, %.loc8_47.2 [concrete = constants.%assoc0.ab8]
  142. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%IndexWith.lookup_impl_witness.407, element0 [symbolic_self = constants.%impl.elem0.9d3]
  143. // CHECK:STDOUT: %ElementType.ref.loc8_62: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType]
  144. // CHECK:STDOUT: %.loc8_41: type = where_expr [concrete = constants.%IndexWith_where.type] {
  145. // CHECK:STDOUT: requirement_base_facet_type %IndexWith.type
  146. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %ElementType.ref.loc8_62
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT: name_binding_decl {
  150. // CHECK:STDOUT: %s.patt: %pattern_type.541 = value_binding_pattern s [concrete]
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, %SubscriptType.decl [concrete = constants.%SubscriptType.9ec]
  153. // CHECK:STDOUT: %.loc14_25.1: ref %SubscriptType.9ec = temporary_storage
  154. // CHECK:STDOUT: %.loc14_25.2: init %SubscriptType.9ec to %.loc14_25.1 = class_init () [concrete = constants.%SubscriptType.val]
  155. // CHECK:STDOUT: %.loc14_25.3: init %SubscriptType.9ec = converted @__global_init.%.loc14, %.loc14_25.2 [concrete = constants.%SubscriptType.val]
  156. // CHECK:STDOUT: %.loc14_25.4: ref %SubscriptType.9ec = temporary %.loc14_25.1, %.loc14_25.3 [concrete = constants.%.e36]
  157. // CHECK:STDOUT: %.loc14_25.5: %SubscriptType.9ec = acquire_value %.loc14_25.4 [concrete = constants.%SubscriptType.val]
  158. // CHECK:STDOUT: %s: %SubscriptType.9ec = value_binding s, %.loc14_25.5
  159. // CHECK:STDOUT: name_binding_decl {
  160. // CHECK:STDOUT: %c.patt: %pattern_type.7c7 = value_binding_pattern c [concrete]
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  163. // CHECK:STDOUT: %.loc15_13.1: ref %C = temporary_storage
  164. // CHECK:STDOUT: %.loc15_13.2: init %C to %.loc15_13.1 = class_init () [concrete = constants.%C.val]
  165. // CHECK:STDOUT: %.loc15_13.3: init %C = converted @__global_init.%.loc15, %.loc15_13.2 [concrete = constants.%C.val]
  166. // CHECK:STDOUT: %.loc15_13.4: ref %C = temporary %.loc15_13.1, %.loc15_13.3 [concrete = constants.%.5ea]
  167. // CHECK:STDOUT: %.loc15_13.5: %C = acquire_value %.loc15_13.4 [concrete = constants.%C.val]
  168. // CHECK:STDOUT: %c: %C = value_binding c, %.loc15_13.5
  169. // CHECK:STDOUT: name_binding_decl {
  170. // CHECK:STDOUT: %x.patt: %pattern_type.fde = value_binding_pattern x [concrete]
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType]
  173. // CHECK:STDOUT: %.loc16_25.1: ref %ElementType = temporary @__global_init.%.loc16, @__global_init.%C.as.IndexWith.impl.At.call
  174. // CHECK:STDOUT: %.loc16_25.2: %ElementType = acquire_value %.loc16_25.1
  175. // CHECK:STDOUT: %x: %ElementType = value_binding x, %.loc16_25.2
  176. // CHECK:STDOUT: }
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: impl @C.as.IndexWith.impl: %C.ref as %.loc8_41 {
  179. // CHECK:STDOUT: %C.as.IndexWith.impl.At.decl: %C.as.IndexWith.impl.At.type = fn_decl @C.as.IndexWith.impl.At [concrete = constants.%C.as.IndexWith.impl.At] {
  180. // CHECK:STDOUT: %self.param_patt: %pattern_type.7c7 = value_param_pattern [concrete]
  181. // CHECK:STDOUT: %self.patt: %pattern_type.7c7 = at_binding_pattern self, %self.param_patt [concrete]
  182. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.541 = value_param_pattern [concrete]
  183. // CHECK:STDOUT: %subscript.patt: %pattern_type.541 = at_binding_pattern subscript, %subscript.param_patt [concrete]
  184. // CHECK:STDOUT: %return.param_patt: %pattern_type.fde = out_param_pattern [concrete]
  185. // CHECK:STDOUT: %return.patt: %pattern_type.fde = return_slot_pattern %return.param_patt, %ElementType.ref [concrete]
  186. // CHECK:STDOUT: } {
  187. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType]
  188. // CHECK:STDOUT: %.loc9: Core.Form = init_form %ElementType.ref [concrete = constants.%.312]
  189. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  190. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @C.as.IndexWith.impl.%C.ref [concrete = constants.%C]
  191. // CHECK:STDOUT: %self: %C = value_binding self, %self.param
  192. // CHECK:STDOUT: %subscript.param: %SubscriptType.9ec = value_param call_param1
  193. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.9ec]
  194. // CHECK:STDOUT: %subscript: %SubscriptType.9ec = value_binding subscript, %subscript.param
  195. // CHECK:STDOUT: %return.param: ref %ElementType = out_param call_param2
  196. // CHECK:STDOUT: %return: ref %ElementType = return_slot %return.param
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (%impl_witness_assoc_constant, %C.as.IndexWith.impl.At.decl), @C.as.IndexWith.impl [concrete]
  199. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  200. // CHECK:STDOUT: %impl_witness_assoc_constant: type = impl_witness_assoc_constant constants.%ElementType [concrete = constants.%ElementType]
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: !members:
  203. // CHECK:STDOUT: .SubscriptType = <poisoned>
  204. // CHECK:STDOUT: .ElementType = <poisoned>
  205. // CHECK:STDOUT: .At = %C.as.IndexWith.impl.At.decl
  206. // CHECK:STDOUT: witness = %IndexWith.impl_witness
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: class @C {
  210. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  211. // CHECK:STDOUT: complete_type_witness = %complete_type
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: !members:
  214. // CHECK:STDOUT: .Self = constants.%C
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: class @ElementType.loc5 {
  218. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  219. // CHECK:STDOUT: complete_type_witness = %complete_type
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: !members:
  222. // CHECK:STDOUT: .Self = constants.%ElementType
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: class @SubscriptType {
  226. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  227. // CHECK:STDOUT: complete_type_witness = %complete_type
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: !members:
  230. // CHECK:STDOUT: .Self = constants.%SubscriptType.9ec
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: fn @C.as.IndexWith.impl.At(%self.param: %C, %subscript.param: %SubscriptType.9ec) -> out %return.param: %ElementType {
  234. // CHECK:STDOUT: !entry:
  235. // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  236. // CHECK:STDOUT: %.loc10_13.2: init %ElementType to %return.param = class_init () [concrete = constants.%ElementType.val]
  237. // CHECK:STDOUT: %.loc10_14: init %ElementType = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val]
  238. // CHECK:STDOUT: return %.loc10_14 to %return.param
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: fn @__global_init() {
  242. // CHECK:STDOUT: !entry:
  243. // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  244. // CHECK:STDOUT: %.loc15: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  245. // CHECK:STDOUT: %c.ref: %C = name_ref c, file.%c
  246. // CHECK:STDOUT: %s.ref: %SubscriptType.9ec = name_ref s, file.%s
  247. // CHECK:STDOUT: %impl.elem1: %.8f0 = impl_witness_access constants.%IndexWith.impl_witness, element1 [concrete = constants.%C.as.IndexWith.impl.At]
  248. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %c.ref, %impl.elem1
  249. // CHECK:STDOUT: %.loc16: ref %ElementType = temporary_storage
  250. // CHECK:STDOUT: %C.as.IndexWith.impl.At.call: init %ElementType to %.loc16 = call %bound_method(%c.ref, %s.ref)
  251. // CHECK:STDOUT: return
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: --- overloaded_builtin.carbon
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: constants {
  257. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  258. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  259. // CHECK:STDOUT: %empty_tuple.af4: %empty_tuple.type = tuple_value () [concrete]
  260. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_tuple.type [concrete]
  261. // CHECK:STDOUT: %tuple.type.24b: type = tuple_type (type, type) [concrete]
  262. // CHECK:STDOUT: %tuple.6f4: %tuple.type.24b = tuple_value (%C, %C) [concrete]
  263. // CHECK:STDOUT: %tuple.type.d23: type = tuple_type (%C, %C) [concrete]
  264. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  265. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  266. // CHECK:STDOUT: %SubscriptType: type = symbolic_binding SubscriptType, 0 [symbolic]
  267. // CHECK:STDOUT: %IndexWith.assoc_type.a96: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType) [symbolic]
  268. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [concrete]
  269. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [concrete]
  270. // CHECK:STDOUT: %IndexWith.type.d54: type = facet_type <@IndexWith, @IndexWith(Core.IntLiteral)> [concrete]
  271. // CHECK:STDOUT: %.Self: %IndexWith.type.d54 = symbolic_binding .Self [symbolic_self]
  272. // CHECK:STDOUT: %IndexWith.assoc_type.972: type = assoc_entity_type @IndexWith, @IndexWith(Core.IntLiteral) [concrete]
  273. // CHECK:STDOUT: %assoc0.b00: %IndexWith.assoc_type.972 = assoc_entity element0, imports.%Core.import_ref.434 [concrete]
  274. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
  275. // CHECK:STDOUT: %assoc0.f5a: %IndexWith.assoc_type.a96 = assoc_entity element0, imports.%Core.import_ref.d9b [symbolic]
  276. // CHECK:STDOUT: %IndexWith.lookup_impl_witness.6f5: <witness> = lookup_impl_witness %.Self, @IndexWith, @IndexWith(Core.IntLiteral) [symbolic_self]
  277. // CHECK:STDOUT: %impl.elem0.d7c: type = impl_witness_access %IndexWith.lookup_impl_witness.6f5, element0 [symbolic_self]
  278. // CHECK:STDOUT: %IndexWith_where.type: type = facet_type <@IndexWith, @IndexWith(Core.IntLiteral) where %impl.elem0.d7c = %C> [concrete]
  279. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness @tuple.type.as.IndexWith.impl.%IndexWith.impl_witness_table [concrete]
  280. // CHECK:STDOUT: %pattern_type.c3b: type = pattern_type %tuple.type.d23 [concrete]
  281. // CHECK:STDOUT: %pattern_type.dc0: type = pattern_type Core.IntLiteral [concrete]
  282. // CHECK:STDOUT: %.a69: Core.Form = init_form %C [concrete]
  283. // CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
  284. // CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At.type: type = fn_type @tuple.type.as.IndexWith.impl.At [concrete]
  285. // CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At: %tuple.type.as.IndexWith.impl.At.type = struct_value () [concrete]
  286. // CHECK:STDOUT: %IndexWith.facet: %IndexWith.type.d54 = facet_value %tuple.type.d23, (%IndexWith.impl_witness) [concrete]
  287. // CHECK:STDOUT: %IndexWith.WithSelf.At.type.4d2: type = fn_type @IndexWith.WithSelf.At, @IndexWith.WithSelf(Core.IntLiteral, %IndexWith.facet) [concrete]
  288. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  289. // CHECK:STDOUT: %empty_tuple.bfb: %C = tuple_value () [concrete]
  290. // CHECK:STDOUT: %tuple.d21: %tuple.type.d23 = tuple_value (%empty_tuple.bfb, %empty_tuple.bfb) [concrete]
  291. // CHECK:STDOUT: %.0a8: type = fn_type_with_self_type %IndexWith.WithSelf.At.type.4d2, %IndexWith.facet [concrete]
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: imports {
  295. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  296. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  297. // CHECK:STDOUT: .IntLiteral = %Core.IntLiteral
  298. // CHECK:STDOUT: import Core//prelude
  299. // CHECK:STDOUT: import Core//prelude/...
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  302. // CHECK:STDOUT: %Core.import_ref.c44: @IndexWith.WithSelf.%IndexWith.assoc_type (%IndexWith.assoc_type.a96) = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, loaded [symbolic = @IndexWith.WithSelf.%assoc0 (constants.%assoc0.f5a)]
  303. // CHECK:STDOUT: %Core.import_ref.434: type = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, loaded [concrete = %ElementType]
  304. // CHECK:STDOUT: %Core.IntLiteral: %IntLiteral.type = import_ref Core//prelude/types/int_literal, IntLiteral, loaded [concrete = constants.%IntLiteral]
  305. // CHECK:STDOUT: %Core.import_ref.d9b = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, unloaded
  306. // CHECK:STDOUT: %ElementType: type = assoc_const_decl @ElementType [concrete] {}
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: file {
  310. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  311. // CHECK:STDOUT: .Core = imports.%Core
  312. // CHECK:STDOUT: .C = %C.decl
  313. // CHECK:STDOUT: .s = %s
  314. // CHECK:STDOUT: .e = %e
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT: %Core.import = import Core
  317. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  318. // CHECK:STDOUT: impl_decl @tuple.type.as.IndexWith.impl [concrete] {} {
  319. // CHECK:STDOUT: %C.ref.loc8_7: type = name_ref C, file.%C.decl [concrete = constants.%C]
  320. // CHECK:STDOUT: %C.ref.loc8_10: type = name_ref C, file.%C.decl [concrete = constants.%C]
  321. // CHECK:STDOUT: %.loc8_11.1: %tuple.type.24b = tuple_literal (%C.ref.loc8_7, %C.ref.loc8_10) [concrete = constants.%tuple.6f4]
  322. // CHECK:STDOUT: %.loc8_11.2: type = converted %.loc8_11.1, constants.%tuple.type.d23 [concrete = constants.%tuple.type.d23]
  323. // CHECK:STDOUT: %Core.ref.loc8_16: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  324. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  325. // CHECK:STDOUT: %Core.ref.loc8_31: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  326. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [concrete = constants.%IntLiteral]
  327. // CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral]
  328. // CHECK:STDOUT: %.loc8_48.1: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral]
  329. // CHECK:STDOUT: %.loc8_48.2: type = converted %IntLiteral.call, %.loc8_48.1 [concrete = Core.IntLiteral]
  330. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(Core.IntLiteral)> [concrete = constants.%IndexWith.type.d54]
  331. // CHECK:STDOUT: %.Self: %IndexWith.type.d54 = symbolic_binding .Self [symbolic_self = constants.%.Self]
  332. // CHECK:STDOUT: %.Self.ref: %IndexWith.type.d54 = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  333. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
  334. // CHECK:STDOUT: %.loc8_56.1: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
  335. // CHECK:STDOUT: %.loc8_56.2: %IndexWith.assoc_type.972 = specific_constant imports.%Core.import_ref.c44, @IndexWith.WithSelf(Core.IntLiteral, constants.%.Self) [concrete = constants.%assoc0.b00]
  336. // CHECK:STDOUT: %ElementType.ref: %IndexWith.assoc_type.972 = name_ref ElementType, %.loc8_56.2 [concrete = constants.%assoc0.b00]
  337. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%IndexWith.lookup_impl_witness.6f5, element0 [symbolic_self = constants.%impl.elem0.d7c]
  338. // CHECK:STDOUT: %C.ref.loc8_71: type = name_ref C, file.%C.decl [concrete = constants.%C]
  339. // CHECK:STDOUT: %.loc8_50: type = where_expr [concrete = constants.%IndexWith_where.type] {
  340. // CHECK:STDOUT: requirement_base_facet_type %IndexWith.type
  341. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %C.ref.loc8_71
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT: name_binding_decl {
  345. // CHECK:STDOUT: %s.patt: %pattern_type.c3b = value_binding_pattern s [concrete]
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: %.loc14_13.1: type = splice_block %.loc14_13.3 [concrete = constants.%tuple.type.d23] {
  348. // CHECK:STDOUT: %C.ref.loc14_9: type = name_ref C, %C.decl [concrete = constants.%C]
  349. // CHECK:STDOUT: %C.ref.loc14_12: type = name_ref C, %C.decl [concrete = constants.%C]
  350. // CHECK:STDOUT: %.loc14_13.2: %tuple.type.24b = tuple_literal (%C.ref.loc14_9, %C.ref.loc14_12) [concrete = constants.%tuple.6f4]
  351. // CHECK:STDOUT: %.loc14_13.3: type = converted %.loc14_13.2, constants.%tuple.type.d23 [concrete = constants.%tuple.type.d23]
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: %tuple.loc14: %tuple.type.d23 = tuple_value (@__global_init.%.loc14_21.2, @__global_init.%.loc14_30.2) [concrete = constants.%tuple.d21]
  354. // CHECK:STDOUT: %.loc14_34: %tuple.type.d23 = converted @__global_init.%.loc14_34, %tuple.loc14 [concrete = constants.%tuple.d21]
  355. // CHECK:STDOUT: %s: %tuple.type.d23 = value_binding s, %.loc14_34
  356. // CHECK:STDOUT: name_binding_decl {
  357. // CHECK:STDOUT: %e.patt: %pattern_type.7c7 = value_binding_pattern e [concrete]
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT: %C.ref.loc15: type = name_ref C, %C.decl [concrete = constants.%C]
  360. // CHECK:STDOUT: %.loc15_15.1: init %empty_tuple.type = as_compatible @__global_init.%tuple.type.as.IndexWith.impl.At.call
  361. // CHECK:STDOUT: %.loc15_15.2: ref %empty_tuple.type = temporary_storage
  362. // CHECK:STDOUT: %.loc15_15.3: ref %empty_tuple.type = temporary %.loc15_15.2, %.loc15_15.1
  363. // CHECK:STDOUT: %tuple.loc15: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple.af4]
  364. // CHECK:STDOUT: %.loc15_15.4: %C = as_compatible %tuple.loc15 [concrete = constants.%empty_tuple.bfb]
  365. // CHECK:STDOUT: %.loc15_15.5: %C = converted @__global_init.%tuple.type.as.IndexWith.impl.At.call, %.loc15_15.4 [concrete = constants.%empty_tuple.bfb]
  366. // CHECK:STDOUT: %e: %C = value_binding e, %.loc15_15.5
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT:
  369. // CHECK:STDOUT: impl @tuple.type.as.IndexWith.impl: %.loc8_11.2 as %.loc8_50 {
  370. // CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At.decl: %tuple.type.as.IndexWith.impl.At.type = fn_decl @tuple.type.as.IndexWith.impl.At [concrete = constants.%tuple.type.as.IndexWith.impl.At] {
  371. // CHECK:STDOUT: %self.param_patt: %pattern_type.c3b = value_param_pattern [concrete]
  372. // CHECK:STDOUT: %self.patt: %pattern_type.c3b = at_binding_pattern self, %self.param_patt [concrete]
  373. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.dc0 = value_param_pattern [concrete]
  374. // CHECK:STDOUT: %subscript.patt: %pattern_type.dc0 = at_binding_pattern subscript, %subscript.param_patt [concrete]
  375. // CHECK:STDOUT: %return.param_patt: %pattern_type.7c7 = out_param_pattern [concrete]
  376. // CHECK:STDOUT: %return.patt: %pattern_type.7c7 = return_slot_pattern %return.param_patt, %C.ref [concrete]
  377. // CHECK:STDOUT: } {
  378. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  379. // CHECK:STDOUT: %.loc9_61: Core.Form = init_form %C.ref [concrete = constants.%.a69]
  380. // CHECK:STDOUT: %self.param: %tuple.type.d23 = value_param call_param0
  381. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @tuple.type.as.IndexWith.impl.%.loc8_11.2 [concrete = constants.%tuple.type.d23]
  382. // CHECK:STDOUT: %self: %tuple.type.d23 = value_binding self, %self.param
  383. // CHECK:STDOUT: %subscript.param: Core.IntLiteral = value_param call_param1
  384. // CHECK:STDOUT: %.loc9_55.1: type = splice_block %.loc9_55.3 [concrete = Core.IntLiteral] {
  385. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  386. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [concrete = constants.%IntLiteral]
  387. // CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral]
  388. // CHECK:STDOUT: %.loc9_55.2: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral]
  389. // CHECK:STDOUT: %.loc9_55.3: type = converted %IntLiteral.call, %.loc9_55.2 [concrete = Core.IntLiteral]
  390. // CHECK:STDOUT: }
  391. // CHECK:STDOUT: %subscript: Core.IntLiteral = value_binding subscript, %subscript.param
  392. // CHECK:STDOUT: %return.param: ref %C = out_param call_param2
  393. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (%impl_witness_assoc_constant, %tuple.type.as.IndexWith.impl.At.decl), @tuple.type.as.IndexWith.impl [concrete]
  396. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  397. // CHECK:STDOUT: %impl_witness_assoc_constant: type = impl_witness_assoc_constant constants.%C [concrete = constants.%C]
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: !members:
  400. // CHECK:STDOUT: .C = <poisoned>
  401. // CHECK:STDOUT: .At = %tuple.type.as.IndexWith.impl.At.decl
  402. // CHECK:STDOUT: witness = %IndexWith.impl_witness
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: class @C {
  406. // CHECK:STDOUT: %.loc5_10: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple.af4]
  407. // CHECK:STDOUT: %.loc5_11: type = converted %.loc5_10, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  408. // CHECK:STDOUT: adapt_decl %.loc5_11 [concrete]
  409. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_tuple.type [concrete = constants.%complete_type]
  410. // CHECK:STDOUT: complete_type_witness = %complete_type
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: !members:
  413. // CHECK:STDOUT: .Self = constants.%C
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: fn @tuple.type.as.IndexWith.impl.At(%self.param: %tuple.type.d23, %subscript.param: Core.IntLiteral) -> out %return.param: %C {
  417. // CHECK:STDOUT: !entry:
  418. // CHECK:STDOUT: %self.ref: %tuple.type.d23 = name_ref self, %self
  419. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  420. // CHECK:STDOUT: %tuple.elem0: %C = tuple_access %self.ref, element0
  421. // CHECK:STDOUT: %.loc10_18.1: %empty_tuple.type = as_compatible %tuple.elem0
  422. // CHECK:STDOUT: %.loc10_18.2: init %empty_tuple.type = tuple_init () [concrete = constants.%empty_tuple.af4]
  423. // CHECK:STDOUT: %.loc10_18.3: init %C = as_compatible %.loc10_18.2 [concrete = constants.%empty_tuple.bfb]
  424. // CHECK:STDOUT: %.loc10_18.4: init %C = converted %tuple.elem0, %.loc10_18.3 [concrete = constants.%empty_tuple.bfb]
  425. // CHECK:STDOUT: return %.loc10_18.4
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT:
  428. // CHECK:STDOUT: fn @__global_init() {
  429. // CHECK:STDOUT: !entry:
  430. // CHECK:STDOUT: %.loc14_19: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple.af4]
  431. // CHECK:STDOUT: %C.ref.loc14_24: type = name_ref C, file.%C.decl [concrete = constants.%C]
  432. // CHECK:STDOUT: %empty_tuple.loc14_19: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple.af4]
  433. // CHECK:STDOUT: %.loc14_21.1: %C = as_compatible %empty_tuple.loc14_19 [concrete = constants.%empty_tuple.bfb]
  434. // CHECK:STDOUT: %.loc14_21.2: %C = converted %.loc14_19, %.loc14_21.1 [concrete = constants.%empty_tuple.bfb]
  435. // CHECK:STDOUT: %.loc14_28: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple.af4]
  436. // CHECK:STDOUT: %C.ref.loc14_33: type = name_ref C, file.%C.decl [concrete = constants.%C]
  437. // CHECK:STDOUT: %empty_tuple.loc14_28: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple.af4]
  438. // CHECK:STDOUT: %.loc14_30.1: %C = as_compatible %empty_tuple.loc14_28 [concrete = constants.%empty_tuple.bfb]
  439. // CHECK:STDOUT: %.loc14_30.2: %C = converted %.loc14_28, %.loc14_30.1 [concrete = constants.%empty_tuple.bfb]
  440. // CHECK:STDOUT: %.loc14_34: %tuple.type.d23 = tuple_literal (%.loc14_21.2, %.loc14_30.2) [concrete = constants.%tuple.d21]
  441. // CHECK:STDOUT: %s.ref: %tuple.type.d23 = name_ref s, file.%s
  442. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  443. // CHECK:STDOUT: %impl.elem1: %.0a8 = impl_witness_access constants.%IndexWith.impl_witness, element1 [concrete = constants.%tuple.type.as.IndexWith.impl.At]
  444. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %s.ref, %impl.elem1
  445. // CHECK:STDOUT: %tuple.type.as.IndexWith.impl.At.call: init %C = call %bound_method(%s.ref, %int_0)
  446. // CHECK:STDOUT: return
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: --- fail_invalid_subscript_type.carbon
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: constants {
  452. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  453. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  454. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  455. // CHECK:STDOUT: %ElementType: type = class_type @ElementType.loc5 [concrete]
  456. // CHECK:STDOUT: %SubscriptType.9ec: type = class_type @SubscriptType [concrete]
  457. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  458. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  459. // CHECK:STDOUT: %SubscriptType.67d: type = symbolic_binding SubscriptType, 0 [symbolic]
  460. // CHECK:STDOUT: %IndexWith.assoc_type.a96: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.67d) [symbolic]
  461. // CHECK:STDOUT: %IndexWith.type.bbe: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.9ec)> [concrete]
  462. // CHECK:STDOUT: %.Self: %IndexWith.type.bbe = symbolic_binding .Self [symbolic_self]
  463. // CHECK:STDOUT: %IndexWith.assoc_type.b14: type = assoc_entity_type @IndexWith, @IndexWith(%SubscriptType.9ec) [concrete]
  464. // CHECK:STDOUT: %assoc0.ab8: %IndexWith.assoc_type.b14 = assoc_entity element0, imports.%Core.import_ref.434 [concrete]
  465. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self [symbolic_self]
  466. // CHECK:STDOUT: %assoc0.f5a: %IndexWith.assoc_type.a96 = assoc_entity element0, imports.%Core.import_ref.d9b [symbolic]
  467. // CHECK:STDOUT: %IndexWith.lookup_impl_witness.407: <witness> = lookup_impl_witness %.Self, @IndexWith, @IndexWith(%SubscriptType.9ec) [symbolic_self]
  468. // CHECK:STDOUT: %impl.elem0.9d3: type = impl_witness_access %IndexWith.lookup_impl_witness.407, element0 [symbolic_self]
  469. // CHECK:STDOUT: %IndexWith_where.type: type = facet_type <@IndexWith, @IndexWith(%SubscriptType.9ec) where %impl.elem0.9d3 = %ElementType> [concrete]
  470. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness @C.as.IndexWith.impl.%IndexWith.impl_witness_table [concrete]
  471. // CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
  472. // CHECK:STDOUT: %pattern_type.541: type = pattern_type %SubscriptType.9ec [concrete]
  473. // CHECK:STDOUT: %.312: Core.Form = init_form %ElementType [concrete]
  474. // CHECK:STDOUT: %pattern_type.fde: type = pattern_type %ElementType [concrete]
  475. // CHECK:STDOUT: %C.as.IndexWith.impl.At.type: type = fn_type @C.as.IndexWith.impl.At [concrete]
  476. // CHECK:STDOUT: %C.as.IndexWith.impl.At: %C.as.IndexWith.impl.At.type = struct_value () [concrete]
  477. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  478. // CHECK:STDOUT: %ElementType.val: %ElementType = struct_value () [concrete]
  479. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  480. // CHECK:STDOUT: %.5ea: ref %C = temporary invalid, %C.val [concrete]
  481. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: imports {
  485. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  486. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  487. // CHECK:STDOUT: import Core//prelude
  488. // CHECK:STDOUT: import Core//prelude/...
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  491. // CHECK:STDOUT: %Core.import_ref.c44: @IndexWith.WithSelf.%IndexWith.assoc_type (%IndexWith.assoc_type.a96) = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, loaded [symbolic = @IndexWith.WithSelf.%assoc0 (constants.%assoc0.f5a)]
  492. // CHECK:STDOUT: %Core.import_ref.434: type = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, loaded [concrete = %ElementType]
  493. // CHECK:STDOUT: %Core.import_ref.d9b = import_ref Core//prelude/operators/index, loc{{\d+_\d+}}, unloaded
  494. // CHECK:STDOUT: %ElementType: type = assoc_const_decl @ElementType.1 [concrete] {}
  495. // CHECK:STDOUT: }
  496. // CHECK:STDOUT:
  497. // CHECK:STDOUT: file {
  498. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  499. // CHECK:STDOUT: .Core = imports.%Core
  500. // CHECK:STDOUT: .C = %C.decl
  501. // CHECK:STDOUT: .ElementType = %ElementType.decl
  502. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  503. // CHECK:STDOUT: .c = %c
  504. // CHECK:STDOUT: .x = %x
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT: %Core.import = import Core
  507. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  508. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType.loc5 [concrete = constants.%ElementType] {} {}
  509. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [concrete = constants.%SubscriptType.9ec] {} {}
  510. // CHECK:STDOUT: impl_decl @C.as.IndexWith.impl [concrete] {} {
  511. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  512. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  513. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.504 = name_ref IndexWith, imports.%Core.IndexWith [concrete = constants.%IndexWith.generic]
  514. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.9ec]
  515. // CHECK:STDOUT: %IndexWith.type: type = facet_type <@IndexWith, @IndexWith(constants.%SubscriptType.9ec)> [concrete = constants.%IndexWith.type.bbe]
  516. // CHECK:STDOUT: %.Self: %IndexWith.type.bbe = symbolic_binding .Self [symbolic_self = constants.%.Self]
  517. // CHECK:STDOUT: %.Self.ref: %IndexWith.type.bbe = name_ref .Self, %.Self [symbolic_self = constants.%.Self]
  518. // CHECK:STDOUT: %.Self.as_type: type = facet_access_type %.Self.ref [symbolic_self = constants.%.Self.as_type]
  519. // CHECK:STDOUT: %.loc8_47.1: type = converted %.Self.ref, %.Self.as_type [symbolic_self = constants.%.Self.as_type]
  520. // CHECK:STDOUT: %.loc8_47.2: %IndexWith.assoc_type.b14 = specific_constant imports.%Core.import_ref.c44, @IndexWith.WithSelf(constants.%SubscriptType.9ec, constants.%.Self) [concrete = constants.%assoc0.ab8]
  521. // CHECK:STDOUT: %ElementType.ref.loc8_47: %IndexWith.assoc_type.b14 = name_ref ElementType, %.loc8_47.2 [concrete = constants.%assoc0.ab8]
  522. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access constants.%IndexWith.lookup_impl_witness.407, element0 [symbolic_self = constants.%impl.elem0.9d3]
  523. // CHECK:STDOUT: %ElementType.ref.loc8_62: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType]
  524. // CHECK:STDOUT: %.loc8_41: type = where_expr [concrete = constants.%IndexWith_where.type] {
  525. // CHECK:STDOUT: requirement_base_facet_type %IndexWith.type
  526. // CHECK:STDOUT: requirement_rewrite %impl.elem0, %ElementType.ref.loc8_62
  527. // CHECK:STDOUT: }
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT: name_binding_decl {
  530. // CHECK:STDOUT: %c.patt: %pattern_type.7c7 = value_binding_pattern c [concrete]
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  533. // CHECK:STDOUT: %.loc14_13.1: ref %C = temporary_storage
  534. // CHECK:STDOUT: %.loc14_13.2: init %C to %.loc14_13.1 = class_init () [concrete = constants.%C.val]
  535. // CHECK:STDOUT: %.loc14_13.3: init %C = converted @__global_init.%.loc14, %.loc14_13.2 [concrete = constants.%C.val]
  536. // CHECK:STDOUT: %.loc14_13.4: ref %C = temporary %.loc14_13.1, %.loc14_13.3 [concrete = constants.%.5ea]
  537. // CHECK:STDOUT: %.loc14_13.5: %C = acquire_value %.loc14_13.4 [concrete = constants.%C.val]
  538. // CHECK:STDOUT: %c: %C = value_binding c, %.loc14_13.5
  539. // CHECK:STDOUT: name_binding_decl {
  540. // CHECK:STDOUT: %x.patt: %pattern_type.fde = value_binding_pattern x [concrete]
  541. // CHECK:STDOUT: }
  542. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [concrete = constants.%ElementType]
  543. // CHECK:STDOUT: %x: %ElementType = value_binding x, <error> [concrete = <error>]
  544. // CHECK:STDOUT: }
  545. // CHECK:STDOUT:
  546. // CHECK:STDOUT: impl @C.as.IndexWith.impl: %C.ref as %.loc8_41 {
  547. // CHECK:STDOUT: %C.as.IndexWith.impl.At.decl: %C.as.IndexWith.impl.At.type = fn_decl @C.as.IndexWith.impl.At [concrete = constants.%C.as.IndexWith.impl.At] {
  548. // CHECK:STDOUT: %self.param_patt: %pattern_type.7c7 = value_param_pattern [concrete]
  549. // CHECK:STDOUT: %self.patt: %pattern_type.7c7 = at_binding_pattern self, %self.param_patt [concrete]
  550. // CHECK:STDOUT: %subscript.param_patt: %pattern_type.541 = value_param_pattern [concrete]
  551. // CHECK:STDOUT: %subscript.patt: %pattern_type.541 = at_binding_pattern subscript, %subscript.param_patt [concrete]
  552. // CHECK:STDOUT: %return.param_patt: %pattern_type.fde = out_param_pattern [concrete]
  553. // CHECK:STDOUT: %return.patt: %pattern_type.fde = return_slot_pattern %return.param_patt, %ElementType.ref [concrete]
  554. // CHECK:STDOUT: } {
  555. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [concrete = constants.%ElementType]
  556. // CHECK:STDOUT: %.loc9: Core.Form = init_form %ElementType.ref [concrete = constants.%.312]
  557. // CHECK:STDOUT: %self.param: %C = value_param call_param0
  558. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @C.as.IndexWith.impl.%C.ref [concrete = constants.%C]
  559. // CHECK:STDOUT: %self: %C = value_binding self, %self.param
  560. // CHECK:STDOUT: %subscript.param: %SubscriptType.9ec = value_param call_param1
  561. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [concrete = constants.%SubscriptType.9ec]
  562. // CHECK:STDOUT: %subscript: %SubscriptType.9ec = value_binding subscript, %subscript.param
  563. // CHECK:STDOUT: %return.param: ref %ElementType = out_param call_param2
  564. // CHECK:STDOUT: %return: ref %ElementType = return_slot %return.param
  565. // CHECK:STDOUT: }
  566. // CHECK:STDOUT: %IndexWith.impl_witness_table = impl_witness_table (%impl_witness_assoc_constant, %C.as.IndexWith.impl.At.decl), @C.as.IndexWith.impl [concrete]
  567. // CHECK:STDOUT: %IndexWith.impl_witness: <witness> = impl_witness %IndexWith.impl_witness_table [concrete = constants.%IndexWith.impl_witness]
  568. // CHECK:STDOUT: %impl_witness_assoc_constant: type = impl_witness_assoc_constant constants.%ElementType [concrete = constants.%ElementType]
  569. // CHECK:STDOUT:
  570. // CHECK:STDOUT: !members:
  571. // CHECK:STDOUT: .SubscriptType = <poisoned>
  572. // CHECK:STDOUT: .ElementType = <poisoned>
  573. // CHECK:STDOUT: .At = %C.as.IndexWith.impl.At.decl
  574. // CHECK:STDOUT: witness = %IndexWith.impl_witness
  575. // CHECK:STDOUT: }
  576. // CHECK:STDOUT:
  577. // CHECK:STDOUT: class @C {
  578. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  579. // CHECK:STDOUT: complete_type_witness = %complete_type
  580. // CHECK:STDOUT:
  581. // CHECK:STDOUT: !members:
  582. // CHECK:STDOUT: .Self = constants.%C
  583. // CHECK:STDOUT: }
  584. // CHECK:STDOUT:
  585. // CHECK:STDOUT: class @ElementType.loc5 {
  586. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  587. // CHECK:STDOUT: complete_type_witness = %complete_type
  588. // CHECK:STDOUT:
  589. // CHECK:STDOUT: !members:
  590. // CHECK:STDOUT: .Self = constants.%ElementType
  591. // CHECK:STDOUT: }
  592. // CHECK:STDOUT:
  593. // CHECK:STDOUT: class @SubscriptType {
  594. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  595. // CHECK:STDOUT: complete_type_witness = %complete_type
  596. // CHECK:STDOUT:
  597. // CHECK:STDOUT: !members:
  598. // CHECK:STDOUT: .Self = constants.%SubscriptType.9ec
  599. // CHECK:STDOUT: }
  600. // CHECK:STDOUT:
  601. // CHECK:STDOUT: fn @C.as.IndexWith.impl.At(%self.param: %C, %subscript.param: %SubscriptType.9ec) -> out %return.param: %ElementType {
  602. // CHECK:STDOUT: !entry:
  603. // CHECK:STDOUT: %.loc10_13.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  604. // CHECK:STDOUT: %.loc10_13.2: init %ElementType to %return.param = class_init () [concrete = constants.%ElementType.val]
  605. // CHECK:STDOUT: %.loc10_14: init %ElementType = converted %.loc10_13.1, %.loc10_13.2 [concrete = constants.%ElementType.val]
  606. // CHECK:STDOUT: return %.loc10_14 to %return.param
  607. // CHECK:STDOUT: }
  608. // CHECK:STDOUT:
  609. // CHECK:STDOUT: fn @__global_init() {
  610. // CHECK:STDOUT: !entry:
  611. // CHECK:STDOUT: %.loc14: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  612. // CHECK:STDOUT: %c.ref: %C = name_ref c, file.%c
  613. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  614. // CHECK:STDOUT: return
  615. // CHECK:STDOUT: }
  616. // CHECK:STDOUT:
  617. // CHECK:STDOUT: --- fail_index_with_not_implemented.carbon
  618. // CHECK:STDOUT:
  619. // CHECK:STDOUT: constants {
  620. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  621. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  622. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  623. // CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
  624. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  625. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  626. // CHECK:STDOUT: %.5ea: ref %C = temporary invalid, %C.val [concrete]
  627. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  628. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  629. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  630. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  631. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  632. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  633. // CHECK:STDOUT: %IndexWith.type.504: type = generic_interface_type @IndexWith [concrete]
  634. // CHECK:STDOUT: %IndexWith.generic: %IndexWith.type.504 = struct_value () [concrete]
  635. // CHECK:STDOUT: }
  636. // CHECK:STDOUT:
  637. // CHECK:STDOUT: imports {
  638. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  639. // CHECK:STDOUT: .Int = %Core.Int
  640. // CHECK:STDOUT: .IndexWith = %Core.IndexWith
  641. // CHECK:STDOUT: import Core//prelude
  642. // CHECK:STDOUT: import Core//prelude/...
  643. // CHECK:STDOUT: }
  644. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  645. // CHECK:STDOUT: %Core.IndexWith: %IndexWith.type.504 = import_ref Core//prelude/operators/index, IndexWith, loaded [concrete = constants.%IndexWith.generic]
  646. // CHECK:STDOUT: }
  647. // CHECK:STDOUT:
  648. // CHECK:STDOUT: file {
  649. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  650. // CHECK:STDOUT: .Core = imports.%Core
  651. // CHECK:STDOUT: .C = %C.decl
  652. // CHECK:STDOUT: .c = %c
  653. // CHECK:STDOUT: .x = %x
  654. // CHECK:STDOUT: }
  655. // CHECK:STDOUT: %Core.import = import Core
  656. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  657. // CHECK:STDOUT: name_binding_decl {
  658. // CHECK:STDOUT: %c.patt: %pattern_type.7c7 = value_binding_pattern c [concrete]
  659. // CHECK:STDOUT: }
  660. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [concrete = constants.%C]
  661. // CHECK:STDOUT: %.loc6_13.1: ref %C = temporary_storage
  662. // CHECK:STDOUT: %.loc6_13.2: init %C to %.loc6_13.1 = class_init () [concrete = constants.%C.val]
  663. // CHECK:STDOUT: %.loc6_13.3: init %C = converted @__global_init.%.loc6, %.loc6_13.2 [concrete = constants.%C.val]
  664. // CHECK:STDOUT: %.loc6_13.4: ref %C = temporary %.loc6_13.1, %.loc6_13.3 [concrete = constants.%.5ea]
  665. // CHECK:STDOUT: %.loc6_13.5: %C = acquire_value %.loc6_13.4 [concrete = constants.%C.val]
  666. // CHECK:STDOUT: %c: %C = value_binding c, %.loc6_13.5
  667. // CHECK:STDOUT: name_binding_decl {
  668. // CHECK:STDOUT: %x.patt: %pattern_type.7ce = value_binding_pattern x [concrete]
  669. // CHECK:STDOUT: }
  670. // CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
  671. // CHECK:STDOUT: %x: %i32 = value_binding x, <error> [concrete = <error>]
  672. // CHECK:STDOUT: }
  673. // CHECK:STDOUT:
  674. // CHECK:STDOUT: class @C {
  675. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  676. // CHECK:STDOUT: complete_type_witness = %complete_type
  677. // CHECK:STDOUT:
  678. // CHECK:STDOUT: !members:
  679. // CHECK:STDOUT: .Self = constants.%C
  680. // CHECK:STDOUT: }
  681. // CHECK:STDOUT:
  682. // CHECK:STDOUT: fn @__global_init() {
  683. // CHECK:STDOUT: !entry:
  684. // CHECK:STDOUT: %.loc6: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  685. // CHECK:STDOUT: %c.ref: %C = name_ref c, file.%c
  686. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  687. // CHECK:STDOUT: return
  688. // CHECK:STDOUT: }
  689. // CHECK:STDOUT: