index.carbon 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/index.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/index.carbon
  10. // --- overloaded_index.carbon
  11. library "[[@TEST_NAME]]";
  12. class C {}
  13. class ElementType {}
  14. class SubscriptType {}
  15. impl C as Core.IndexWith(SubscriptType, ElementType) {
  16. fn At[self: Self](subscript: SubscriptType) -> ElementType {
  17. return {};
  18. }
  19. }
  20. let s: SubscriptType = {};
  21. let c: C = {};
  22. let x: ElementType = c[s];
  23. // --- overloaded_builtin.carbon
  24. library "[[@TEST_NAME]]";
  25. impl (i32, i32) as Core.IndexWith(i32, i32) {
  26. fn At[self: Self](subscript: i32) -> i32 {
  27. return self.0;
  28. }
  29. }
  30. let s: (i32, i32) = (1, 5);
  31. let e: i32 = s[0];
  32. // --- fail_invalid_subscript_type.carbon
  33. library "[[@TEST_NAME]]";
  34. class C { }
  35. class ElementType {}
  36. class SubscriptType {}
  37. impl C as Core.IndexWith(SubscriptType, ElementType) {
  38. fn At[self: Self](subscript: SubscriptType) -> ElementType {
  39. return {};
  40. }
  41. }
  42. let c: C = {};
  43. // CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+7]]:22: error: cannot implicitly convert from `i32` to `SubscriptType` [ImplicitAsConversionFailure]
  44. // CHECK:STDERR: let x: ElementType = c[0];
  45. // CHECK:STDERR: ^~~~
  46. // CHECK:STDERR: fail_invalid_subscript_type.carbon:[[@LINE+4]]:22: note: type `i32` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote]
  47. // CHECK:STDERR: let x: ElementType = c[0];
  48. // CHECK:STDERR: ^~~~
  49. // CHECK:STDERR:
  50. let x: ElementType = c[0];
  51. // --- fail_index_with_not_implemented.carbon
  52. library "[[@TEST_NAME]]";
  53. class C { }
  54. let c: C = {};
  55. // CHECK:STDERR: fail_index_with_not_implemented.carbon:[[@LINE+3]]:14: error: type `C` does not support indexing [TypeNotIndexable]
  56. // CHECK:STDERR: let x: i32 = c[0];
  57. // CHECK:STDERR: ^~~~
  58. let x: i32 = c[0];
  59. // CHECK:STDOUT: --- overloaded_index.carbon
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: constants {
  62. // CHECK:STDOUT: %C: type = class_type @C [template]
  63. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  64. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  65. // CHECK:STDOUT: %ElementType.1: type = class_type @ElementType [template]
  66. // CHECK:STDOUT: %SubscriptType.1: type = class_type @SubscriptType [template]
  67. // CHECK:STDOUT: %IndexWith.type.1: type = generic_interface_type @IndexWith [template]
  68. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  69. // CHECK:STDOUT: %IndexWith: %IndexWith.type.1 = struct_value () [template]
  70. // CHECK:STDOUT: %ElementType.2: type = bind_symbolic_name ElementType, 1 [symbolic]
  71. // CHECK:STDOUT: %SubscriptType.2: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  72. // CHECK:STDOUT: %IndexWith.type.2: type = interface_type @IndexWith, @IndexWith(%SubscriptType.2, %ElementType.2) [symbolic]
  73. // CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2) = bind_symbolic_name Self, 2 [symbolic]
  74. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic]
  75. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic]
  76. // CHECK:STDOUT: %Self.2: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic]
  77. // CHECK:STDOUT: %At.type.1: type = fn_type @At.1, @IndexWith(%SubscriptType.2, %ElementType.2) [symbolic]
  78. // CHECK:STDOUT: %At.1: %At.type.1 = struct_value () [symbolic]
  79. // CHECK:STDOUT: %.4: type = assoc_entity_type %IndexWith.type.2, %At.type.1 [symbolic]
  80. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  81. // CHECK:STDOUT: %IndexWith.type.3: type = interface_type @IndexWith, @IndexWith(%SubscriptType.1, %ElementType.1) [template]
  82. // CHECK:STDOUT: %At.type.2: type = fn_type @At.2 [template]
  83. // CHECK:STDOUT: %At.2: %At.type.2 = struct_value () [template]
  84. // CHECK:STDOUT: %At.type.3: type = fn_type @At.1, @IndexWith(%SubscriptType.1, %ElementType.1) [template]
  85. // CHECK:STDOUT: %At.3: %At.type.3 = struct_value () [template]
  86. // CHECK:STDOUT: %.6: type = assoc_entity_type %IndexWith.type.3, %At.type.3 [template]
  87. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [template]
  88. // CHECK:STDOUT: %.8: <witness> = interface_witness (%At.2) [template]
  89. // CHECK:STDOUT: %.9: type = ptr_type %.1 [template]
  90. // CHECK:STDOUT: %struct.1: %ElementType.1 = struct_value () [template]
  91. // CHECK:STDOUT: %struct.2: %SubscriptType.1 = struct_value () [template]
  92. // CHECK:STDOUT: %struct.3: %C = struct_value () [template]
  93. // CHECK:STDOUT: %.10: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: imports {
  97. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  98. // CHECK:STDOUT: .IndexWith = %import_ref.1
  99. // CHECK:STDOUT: import Core//prelude
  100. // CHECK:STDOUT: import Core//prelude/...
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: %import_ref.1: %IndexWith.type.1 = import_ref Core//prelude/operators/index, inst+13, loaded [template = constants.%IndexWith]
  103. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/index, inst+22, unloaded
  104. // CHECK:STDOUT: %import_ref.3: @IndexWith.%.1 (%.4) = import_ref Core//prelude/operators/index, inst+50, loaded [symbolic = @IndexWith.%.2 (constants.%.10)]
  105. // CHECK:STDOUT: %import_ref.4: @IndexWith.%At.type (%At.type.1) = import_ref Core//prelude/operators/index, inst+42, loaded [symbolic = @IndexWith.%At (constants.%At.1)]
  106. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/index, inst+42, unloaded
  107. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/index, inst+42, unloaded
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: file {
  111. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  112. // CHECK:STDOUT: .Core = imports.%Core
  113. // CHECK:STDOUT: .C = %C.decl
  114. // CHECK:STDOUT: .ElementType = %ElementType.decl
  115. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  116. // CHECK:STDOUT: .s = @__global_init.%s
  117. // CHECK:STDOUT: .c = @__global_init.%c
  118. // CHECK:STDOUT: .x = @__global_init.%x
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %Core.import = import Core
  121. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  122. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [template = constants.%ElementType.1] {} {}
  123. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [template = constants.%SubscriptType.1] {} {}
  124. // CHECK:STDOUT: impl_decl @impl [template] {} {
  125. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  126. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  127. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.1 = name_ref IndexWith, imports.%import_ref.1 [template = constants.%IndexWith]
  128. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  129. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  130. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) [template = constants.%IndexWith.type.3]
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, %SubscriptType.decl [template = constants.%SubscriptType.1]
  133. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  134. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.1]
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: generic interface @IndexWith(constants.%SubscriptType.2: type, constants.%ElementType.2: type) {
  138. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType.2)]
  139. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic = %SubscriptType.patt (constants.%SubscriptType.patt)]
  140. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType.2)]
  141. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic = %ElementType.patt (constants.%ElementType.patt)]
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: !definition:
  144. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  145. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  146. // CHECK:STDOUT: %At.type: type = fn_type @At.1, @IndexWith(%SubscriptType, %ElementType) [symbolic = %At.type (constants.%At.type.1)]
  147. // CHECK:STDOUT: %At: @IndexWith.%At.type (%At.type.1) = struct_value () [symbolic = %At (constants.%At.1)]
  148. // CHECK:STDOUT: %.1: type = assoc_entity_type @IndexWith.%IndexWith.type (%IndexWith.type.2), @IndexWith.%At.type (%At.type.1) [symbolic = %.1 (constants.%.4)]
  149. // CHECK:STDOUT: %.2: @IndexWith.%.1 (%.4) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.5)]
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: interface {
  152. // CHECK:STDOUT: !members:
  153. // CHECK:STDOUT: .Self = imports.%import_ref.2
  154. // CHECK:STDOUT: .At = imports.%import_ref.3
  155. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type {
  160. // CHECK:STDOUT: %At.decl: %At.type.2 = fn_decl @At.2 [template = constants.%At.2] {
  161. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  162. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  163. // CHECK:STDOUT: %subscript.patt: %SubscriptType.1 = binding_pattern subscript
  164. // CHECK:STDOUT: %subscript.param_patt: %SubscriptType.1 = value_param_pattern %subscript.patt, runtime_param1
  165. // CHECK:STDOUT: %return.patt: %ElementType.1 = return_slot_pattern
  166. // CHECK:STDOUT: %return.param_patt: %ElementType.1 = out_param_pattern %return.patt, runtime_param2
  167. // CHECK:STDOUT: } {
  168. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%C.ref [template = constants.%C]
  169. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  170. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  171. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  172. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  173. // CHECK:STDOUT: %subscript.param: %SubscriptType.1 = value_param runtime_param1
  174. // CHECK:STDOUT: %subscript: %SubscriptType.1 = bind_name subscript, %subscript.param
  175. // CHECK:STDOUT: %return.param: ref %ElementType.1 = out_param runtime_param2
  176. // CHECK:STDOUT: %return: ref %ElementType.1 = return_slot %return.param
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT: %.loc8: <witness> = interface_witness (%At.decl) [template = constants.%.8]
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: !members:
  181. // CHECK:STDOUT: .At = %At.decl
  182. // CHECK:STDOUT: witness = %.loc8
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: class @C {
  186. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !members:
  189. // CHECK:STDOUT: .Self = constants.%C
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: class @ElementType {
  193. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: !members:
  196. // CHECK:STDOUT: .Self = constants.%ElementType.1
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: class @SubscriptType {
  200. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.1 [template = constants.%.2]
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: !members:
  203. // CHECK:STDOUT: .Self = constants.%SubscriptType.1
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: generic fn @At.1(constants.%SubscriptType.2: type, constants.%ElementType.2: type, constants.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2)) {
  207. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType.2)]
  208. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType.2)]
  209. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  210. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: fn[%self.param_patt: @At.1.%Self (%Self.2)](%subscript.param_patt: @At.1.%SubscriptType (%SubscriptType.2)) -> @At.1.%ElementType (%ElementType.2);
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: fn @At.2[%self.param_patt: %C](%subscript.param_patt: %SubscriptType.1) -> %return: %ElementType.1 {
  216. // CHECK:STDOUT: !entry:
  217. // CHECK:STDOUT: %.loc10_13.1: %.1 = struct_literal ()
  218. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.1 = class_init (), %return [template = constants.%struct.1]
  219. // CHECK:STDOUT: %.loc10_14: init %ElementType.1 = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.1]
  220. // CHECK:STDOUT: return %.loc10_14 to %return
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: fn @__global_init() {
  224. // CHECK:STDOUT: !entry:
  225. // CHECK:STDOUT: %.loc14_25.1: %.1 = struct_literal ()
  226. // CHECK:STDOUT: %.loc14_25.2: ref %SubscriptType.1 = temporary_storage
  227. // CHECK:STDOUT: %.loc14_25.3: init %SubscriptType.1 = class_init (), %.loc14_25.2 [template = constants.%struct.2]
  228. // CHECK:STDOUT: %.loc14_25.4: ref %SubscriptType.1 = temporary %.loc14_25.2, %.loc14_25.3
  229. // CHECK:STDOUT: %.loc14_26.1: ref %SubscriptType.1 = converted %.loc14_25.1, %.loc14_25.4
  230. // CHECK:STDOUT: %.loc14_26.2: %SubscriptType.1 = bind_value %.loc14_26.1
  231. // CHECK:STDOUT: %s: %SubscriptType.1 = bind_name s, %.loc14_26.2
  232. // CHECK:STDOUT: %.loc15_13.1: %.1 = struct_literal ()
  233. // CHECK:STDOUT: %.loc15_13.2: ref %C = temporary_storage
  234. // CHECK:STDOUT: %.loc15_13.3: init %C = class_init (), %.loc15_13.2 [template = constants.%struct.3]
  235. // CHECK:STDOUT: %.loc15_13.4: ref %C = temporary %.loc15_13.2, %.loc15_13.3
  236. // CHECK:STDOUT: %.loc15_14.1: ref %C = converted %.loc15_13.1, %.loc15_13.4
  237. // CHECK:STDOUT: %.loc15_14.2: %C = bind_value %.loc15_14.1
  238. // CHECK:STDOUT: %c: %C = bind_name c, %.loc15_14.2
  239. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  240. // CHECK:STDOUT: %s.ref: %SubscriptType.1 = name_ref s, %s
  241. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) [template = constants.%IndexWith.type.3]
  242. // CHECK:STDOUT: %.loc16_25.1: %.6 = specific_constant imports.%import_ref.3, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) [template = constants.%.7]
  243. // CHECK:STDOUT: %At.ref: %.6 = name_ref At, %.loc16_25.1 [template = constants.%.7]
  244. // CHECK:STDOUT: %.loc16_25.2: %At.type.3 = interface_witness_access constants.%.8, element0 [template = constants.%At.2]
  245. // CHECK:STDOUT: %.loc16_25.3: <bound method> = bound_method %c.ref, %.loc16_25.2
  246. // CHECK:STDOUT: %.loc16_25.4: ref %ElementType.1 = temporary_storage
  247. // CHECK:STDOUT: %At.call: init %ElementType.1 = call %.loc16_25.3(%c.ref, %s.ref) to %.loc16_25.4
  248. // CHECK:STDOUT: %.loc16_25.5: ref %ElementType.1 = temporary %.loc16_25.4, %At.call
  249. // CHECK:STDOUT: %.loc16_25.6: %ElementType.1 = bind_value %.loc16_25.5
  250. // CHECK:STDOUT: %x: %ElementType.1 = bind_name x, %.loc16_25.6
  251. // CHECK:STDOUT: return
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType.2, constants.%ElementType.2) {
  255. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  256. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.2
  257. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  258. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.2
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: specific @IndexWith(@IndexWith.%SubscriptType, @IndexWith.%ElementType) {
  262. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  263. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.2
  264. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  265. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.2
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: specific @IndexWith(@At.1.%SubscriptType, @At.1.%ElementType) {
  269. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  270. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.2
  271. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  272. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.2
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: specific @At.1(constants.%SubscriptType.2, constants.%ElementType.2, constants.%Self.1) {
  276. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  277. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  278. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.2
  279. // CHECK:STDOUT: %Self => constants.%Self.1
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) {
  283. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.1
  284. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.1
  285. // CHECK:STDOUT: %ElementType => constants.%ElementType.1
  286. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.1
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: !definition:
  289. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.3
  290. // CHECK:STDOUT: %Self => constants.%Self.2
  291. // CHECK:STDOUT: %At.type => constants.%At.type.3
  292. // CHECK:STDOUT: %At => constants.%At.3
  293. // CHECK:STDOUT: %.1 => constants.%.6
  294. // CHECK:STDOUT: %.2 => constants.%.7
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: specific @At.1(constants.%SubscriptType.1, constants.%ElementType.1, constants.%C) {
  298. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.1
  299. // CHECK:STDOUT: %ElementType => constants.%ElementType.1
  300. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.3
  301. // CHECK:STDOUT: %Self => constants.%C
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: --- overloaded_builtin.carbon
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: constants {
  307. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  308. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  309. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  310. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  311. // CHECK:STDOUT: %.3: type = tuple_type (i32, i32) [template]
  312. // CHECK:STDOUT: %IndexWith.type.1: type = generic_interface_type @IndexWith [template]
  313. // CHECK:STDOUT: %IndexWith: %IndexWith.type.1 = struct_value () [template]
  314. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic]
  315. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  316. // CHECK:STDOUT: %IndexWith.type.2: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  317. // CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2) = bind_symbolic_name Self, 2 [symbolic]
  318. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic]
  319. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic]
  320. // CHECK:STDOUT: %Self.2: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic]
  321. // CHECK:STDOUT: %At.type.1: type = fn_type @At.1, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  322. // CHECK:STDOUT: %At.1: %At.type.1 = struct_value () [symbolic]
  323. // CHECK:STDOUT: %.4: type = assoc_entity_type %IndexWith.type.2, %At.type.1 [symbolic]
  324. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  325. // CHECK:STDOUT: %IndexWith.type.3: type = interface_type @IndexWith, @IndexWith(i32, i32) [template]
  326. // CHECK:STDOUT: %At.type.2: type = fn_type @At.2 [template]
  327. // CHECK:STDOUT: %At.2: %At.type.2 = struct_value () [template]
  328. // CHECK:STDOUT: %At.type.3: type = fn_type @At.1, @IndexWith(i32, i32) [template]
  329. // CHECK:STDOUT: %At.3: %At.type.3 = struct_value () [template]
  330. // CHECK:STDOUT: %.6: type = assoc_entity_type %IndexWith.type.3, %At.type.3 [template]
  331. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [template]
  332. // CHECK:STDOUT: %.8: <witness> = interface_witness (%At.2) [template]
  333. // CHECK:STDOUT: %.9: type = ptr_type %.3 [template]
  334. // CHECK:STDOUT: %.10: i32 = int_literal 0 [template]
  335. // CHECK:STDOUT: %.11: i32 = int_literal 1 [template]
  336. // CHECK:STDOUT: %.12: i32 = int_literal 5 [template]
  337. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.11, %.12) [template]
  338. // CHECK:STDOUT: %.13: %.4 = assoc_entity element0, imports.%import_ref.7 [symbolic]
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: imports {
  342. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  343. // CHECK:STDOUT: .Int32 = %import_ref.1
  344. // CHECK:STDOUT: .IndexWith = %import_ref.2
  345. // CHECK:STDOUT: import Core//prelude
  346. // CHECK:STDOUT: import Core//prelude/...
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  349. // CHECK:STDOUT: %import_ref.2: %IndexWith.type.1 = import_ref Core//prelude/operators/index, inst+13, loaded [template = constants.%IndexWith]
  350. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/index, inst+22, unloaded
  351. // CHECK:STDOUT: %import_ref.4: @IndexWith.%.1 (%.4) = import_ref Core//prelude/operators/index, inst+50, loaded [symbolic = @IndexWith.%.2 (constants.%.13)]
  352. // CHECK:STDOUT: %import_ref.5: @IndexWith.%At.type (%At.type.1) = import_ref Core//prelude/operators/index, inst+42, loaded [symbolic = @IndexWith.%At (constants.%At.1)]
  353. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/index, inst+42, unloaded
  354. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/index, inst+42, unloaded
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: file {
  358. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  359. // CHECK:STDOUT: .Core = imports.%Core
  360. // CHECK:STDOUT: .s = @__global_init.%s
  361. // CHECK:STDOUT: .e = @__global_init.%e
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT: %Core.import = import Core
  364. // CHECK:STDOUT: impl_decl @impl [template] {} {
  365. // CHECK:STDOUT: %int.make_type_32.loc4_7: init type = call constants.%Int32() [template = i32]
  366. // CHECK:STDOUT: %int.make_type_32.loc4_12: init type = call constants.%Int32() [template = i32]
  367. // CHECK:STDOUT: %.loc4_15.1: %.2 = tuple_literal (%int.make_type_32.loc4_7, %int.make_type_32.loc4_12)
  368. // CHECK:STDOUT: %.loc4_15.2: type = value_of_initializer %int.make_type_32.loc4_7 [template = i32]
  369. // CHECK:STDOUT: %.loc4_15.3: type = converted %int.make_type_32.loc4_7, %.loc4_15.2 [template = i32]
  370. // CHECK:STDOUT: %.loc4_15.4: type = value_of_initializer %int.make_type_32.loc4_12 [template = i32]
  371. // CHECK:STDOUT: %.loc4_15.5: type = converted %int.make_type_32.loc4_12, %.loc4_15.4 [template = i32]
  372. // CHECK:STDOUT: %.loc4_15.6: type = converted %.loc4_15.1, constants.%.3 [template = constants.%.3]
  373. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  374. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.1 = name_ref IndexWith, imports.%import_ref.2 [template = constants.%IndexWith]
  375. // CHECK:STDOUT: %int.make_type_32.loc4_35: init type = call constants.%Int32() [template = i32]
  376. // CHECK:STDOUT: %int.make_type_32.loc4_40: init type = call constants.%Int32() [template = i32]
  377. // CHECK:STDOUT: %.loc4_34.1: type = value_of_initializer %int.make_type_32.loc4_35 [template = i32]
  378. // CHECK:STDOUT: %.loc4_34.2: type = converted %int.make_type_32.loc4_35, %.loc4_34.1 [template = i32]
  379. // CHECK:STDOUT: %.loc4_34.3: type = value_of_initializer %int.make_type_32.loc4_40 [template = i32]
  380. // CHECK:STDOUT: %.loc4_34.4: type = converted %int.make_type_32.loc4_40, %.loc4_34.3 [template = i32]
  381. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(i32, i32) [template = constants.%IndexWith.type.3]
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT: %int.make_type_32.loc10_9: init type = call constants.%Int32() [template = i32]
  384. // CHECK:STDOUT: %int.make_type_32.loc10_14: init type = call constants.%Int32() [template = i32]
  385. // CHECK:STDOUT: %.loc10_17.1: %.2 = tuple_literal (%int.make_type_32.loc10_9, %int.make_type_32.loc10_14)
  386. // CHECK:STDOUT: %.loc10_17.2: type = value_of_initializer %int.make_type_32.loc10_9 [template = i32]
  387. // CHECK:STDOUT: %.loc10_17.3: type = converted %int.make_type_32.loc10_9, %.loc10_17.2 [template = i32]
  388. // CHECK:STDOUT: %.loc10_17.4: type = value_of_initializer %int.make_type_32.loc10_14 [template = i32]
  389. // CHECK:STDOUT: %.loc10_17.5: type = converted %int.make_type_32.loc10_14, %.loc10_17.4 [template = i32]
  390. // CHECK:STDOUT: %.loc10_17.6: type = converted %.loc10_17.1, constants.%.3 [template = constants.%.3]
  391. // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32]
  392. // CHECK:STDOUT: %.loc11_8.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32]
  393. // CHECK:STDOUT: %.loc11_8.2: type = converted %int.make_type_32.loc11, %.loc11_8.1 [template = i32]
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: generic interface @IndexWith(constants.%SubscriptType: type, constants.%ElementType: type) {
  397. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  398. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic = %SubscriptType.patt (constants.%SubscriptType.patt)]
  399. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)]
  400. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic = %ElementType.patt (constants.%ElementType.patt)]
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: !definition:
  403. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  404. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  405. // CHECK:STDOUT: %At.type: type = fn_type @At.1, @IndexWith(%SubscriptType, %ElementType) [symbolic = %At.type (constants.%At.type.1)]
  406. // CHECK:STDOUT: %At: @IndexWith.%At.type (%At.type.1) = struct_value () [symbolic = %At (constants.%At.1)]
  407. // CHECK:STDOUT: %.1: type = assoc_entity_type @IndexWith.%IndexWith.type (%IndexWith.type.2), @IndexWith.%At.type (%At.type.1) [symbolic = %.1 (constants.%.4)]
  408. // CHECK:STDOUT: %.2: @IndexWith.%.1 (%.4) = assoc_entity element0, imports.%import_ref.6 [symbolic = %.2 (constants.%.5)]
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: interface {
  411. // CHECK:STDOUT: !members:
  412. // CHECK:STDOUT: .Self = imports.%import_ref.3
  413. // CHECK:STDOUT: .At = imports.%import_ref.4
  414. // CHECK:STDOUT: witness = (imports.%import_ref.5)
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: impl @impl: %.loc4_15.6 as %IndexWith.type {
  419. // CHECK:STDOUT: %At.decl: %At.type.2 = fn_decl @At.2 [template = constants.%At.2] {
  420. // CHECK:STDOUT: %self.patt: %.3 = binding_pattern self
  421. // CHECK:STDOUT: %self.param_patt: %.3 = value_param_pattern %self.patt, runtime_param0
  422. // CHECK:STDOUT: %subscript.patt: i32 = binding_pattern subscript
  423. // CHECK:STDOUT: %subscript.param_patt: i32 = value_param_pattern %subscript.patt, runtime_param1
  424. // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern
  425. // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param2
  426. // CHECK:STDOUT: } {
  427. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%.loc4_15.6 [template = constants.%.3]
  428. // CHECK:STDOUT: %int.make_type_32.loc5_32: init type = call constants.%Int32() [template = i32]
  429. // CHECK:STDOUT: %.loc5_32.1: type = value_of_initializer %int.make_type_32.loc5_32 [template = i32]
  430. // CHECK:STDOUT: %.loc5_32.2: type = converted %int.make_type_32.loc5_32, %.loc5_32.1 [template = i32]
  431. // CHECK:STDOUT: %int.make_type_32.loc5_40: init type = call constants.%Int32() [template = i32]
  432. // CHECK:STDOUT: %.loc5_40.1: type = value_of_initializer %int.make_type_32.loc5_40 [template = i32]
  433. // CHECK:STDOUT: %.loc5_40.2: type = converted %int.make_type_32.loc5_40, %.loc5_40.1 [template = i32]
  434. // CHECK:STDOUT: %self.param: %.3 = value_param runtime_param0
  435. // CHECK:STDOUT: %self: %.3 = bind_name self, %self.param
  436. // CHECK:STDOUT: %subscript.param: i32 = value_param runtime_param1
  437. // CHECK:STDOUT: %subscript: i32 = bind_name subscript, %subscript.param
  438. // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param2
  439. // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
  440. // CHECK:STDOUT: }
  441. // CHECK:STDOUT: %.loc4_45: <witness> = interface_witness (%At.decl) [template = constants.%.8]
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: !members:
  444. // CHECK:STDOUT: .At = %At.decl
  445. // CHECK:STDOUT: witness = %.loc4_45
  446. // CHECK:STDOUT: }
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: generic fn @At.1(constants.%SubscriptType: type, constants.%ElementType: type, constants.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2)) {
  451. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  452. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)]
  453. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  454. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  455. // CHECK:STDOUT:
  456. // CHECK:STDOUT: fn[%self.param_patt: @At.1.%Self (%Self.2)](%subscript.param_patt: @At.1.%SubscriptType (%SubscriptType)) -> @At.1.%ElementType (%ElementType);
  457. // CHECK:STDOUT: }
  458. // CHECK:STDOUT:
  459. // CHECK:STDOUT: fn @At.2[%self.param_patt: %.3](%subscript.param_patt: i32) -> i32 {
  460. // CHECK:STDOUT: !entry:
  461. // CHECK:STDOUT: %self.ref: %.3 = name_ref self, %self
  462. // CHECK:STDOUT: %.loc6_17: i32 = int_literal 0 [template = constants.%.10]
  463. // CHECK:STDOUT: %.loc6_16: i32 = tuple_access %self.ref, element0
  464. // CHECK:STDOUT: return %.loc6_16
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: fn @__global_init() {
  468. // CHECK:STDOUT: !entry:
  469. // CHECK:STDOUT: %.loc10_22: i32 = int_literal 1 [template = constants.%.11]
  470. // CHECK:STDOUT: %.loc10_25: i32 = int_literal 5 [template = constants.%.12]
  471. // CHECK:STDOUT: %.loc10_26: %.3 = tuple_literal (%.loc10_22, %.loc10_25)
  472. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.loc10_22, %.loc10_25) [template = constants.%tuple]
  473. // CHECK:STDOUT: %.loc10_27: %.3 = converted %.loc10_26, %tuple [template = constants.%tuple]
  474. // CHECK:STDOUT: %s: %.3 = bind_name s, %.loc10_27
  475. // CHECK:STDOUT: %s.ref: %.3 = name_ref s, %s
  476. // CHECK:STDOUT: %.loc11_16: i32 = int_literal 0 [template = constants.%.10]
  477. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(i32, i32) [template = constants.%IndexWith.type.3]
  478. // CHECK:STDOUT: %.loc11_17.1: %.6 = specific_constant imports.%import_ref.4, @IndexWith(i32, i32) [template = constants.%.7]
  479. // CHECK:STDOUT: %At.ref: %.6 = name_ref At, %.loc11_17.1 [template = constants.%.7]
  480. // CHECK:STDOUT: %.loc11_17.2: %At.type.3 = interface_witness_access constants.%.8, element0 [template = constants.%At.2]
  481. // CHECK:STDOUT: %.loc11_17.3: <bound method> = bound_method %s.ref, %.loc11_17.2
  482. // CHECK:STDOUT: %At.call: init i32 = call %.loc11_17.3(%s.ref, %.loc11_16)
  483. // CHECK:STDOUT: %.loc11_18.1: i32 = value_of_initializer %At.call
  484. // CHECK:STDOUT: %.loc11_18.2: i32 = converted %At.call, %.loc11_18.1
  485. // CHECK:STDOUT: %e: i32 = bind_name e, %.loc11_18.2
  486. // CHECK:STDOUT: return
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT:
  489. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType, constants.%ElementType) {
  490. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  491. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType
  492. // CHECK:STDOUT: %ElementType => constants.%ElementType
  493. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType
  494. // CHECK:STDOUT: }
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: specific @IndexWith(@IndexWith.%SubscriptType, @IndexWith.%ElementType) {
  497. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  498. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType
  499. // CHECK:STDOUT: %ElementType => constants.%ElementType
  500. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: specific @IndexWith(@At.1.%SubscriptType, @At.1.%ElementType) {
  504. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  505. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType
  506. // CHECK:STDOUT: %ElementType => constants.%ElementType
  507. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: specific @At.1(constants.%SubscriptType, constants.%ElementType, constants.%Self.1) {
  511. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  512. // CHECK:STDOUT: %ElementType => constants.%ElementType
  513. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.2
  514. // CHECK:STDOUT: %Self => constants.%Self.1
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT:
  517. // CHECK:STDOUT: specific @IndexWith(i32, i32) {
  518. // CHECK:STDOUT: %SubscriptType => i32
  519. // CHECK:STDOUT: %SubscriptType.patt => i32
  520. // CHECK:STDOUT: %ElementType => i32
  521. // CHECK:STDOUT: %ElementType.patt => i32
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: !definition:
  524. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.3
  525. // CHECK:STDOUT: %Self => constants.%Self.2
  526. // CHECK:STDOUT: %At.type => constants.%At.type.3
  527. // CHECK:STDOUT: %At => constants.%At.3
  528. // CHECK:STDOUT: %.1 => constants.%.6
  529. // CHECK:STDOUT: %.2 => constants.%.7
  530. // CHECK:STDOUT: }
  531. // CHECK:STDOUT:
  532. // CHECK:STDOUT: specific @At.1(i32, i32, constants.%.3) {
  533. // CHECK:STDOUT: %SubscriptType => i32
  534. // CHECK:STDOUT: %ElementType => i32
  535. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.3
  536. // CHECK:STDOUT: %Self => constants.%.3
  537. // CHECK:STDOUT: }
  538. // CHECK:STDOUT:
  539. // CHECK:STDOUT: --- fail_invalid_subscript_type.carbon
  540. // CHECK:STDOUT:
  541. // CHECK:STDOUT: constants {
  542. // CHECK:STDOUT: %C: type = class_type @C [template]
  543. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  544. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  545. // CHECK:STDOUT: %ElementType.1: type = class_type @ElementType [template]
  546. // CHECK:STDOUT: %SubscriptType.1: type = class_type @SubscriptType [template]
  547. // CHECK:STDOUT: %IndexWith.type.1: type = generic_interface_type @IndexWith [template]
  548. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  549. // CHECK:STDOUT: %IndexWith: %IndexWith.type.1 = struct_value () [template]
  550. // CHECK:STDOUT: %ElementType.2: type = bind_symbolic_name ElementType, 1 [symbolic]
  551. // CHECK:STDOUT: %SubscriptType.2: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  552. // CHECK:STDOUT: %IndexWith.type.2: type = interface_type @IndexWith, @IndexWith(%SubscriptType.2, %ElementType.2) [symbolic]
  553. // CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2) = bind_symbolic_name Self, 2 [symbolic]
  554. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic]
  555. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic]
  556. // CHECK:STDOUT: %Self.2: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic]
  557. // CHECK:STDOUT: %At.type.1: type = fn_type @At.1, @IndexWith(%SubscriptType.2, %ElementType.2) [symbolic]
  558. // CHECK:STDOUT: %At.1: %At.type.1 = struct_value () [symbolic]
  559. // CHECK:STDOUT: %.4: type = assoc_entity_type %IndexWith.type.2, %At.type.1 [symbolic]
  560. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  561. // CHECK:STDOUT: %IndexWith.type.3: type = interface_type @IndexWith, @IndexWith(%SubscriptType.1, %ElementType.1) [template]
  562. // CHECK:STDOUT: %At.type.2: type = fn_type @At.2 [template]
  563. // CHECK:STDOUT: %At.2: %At.type.2 = struct_value () [template]
  564. // CHECK:STDOUT: %At.type.3: type = fn_type @At.1, @IndexWith(%SubscriptType.1, %ElementType.1) [template]
  565. // CHECK:STDOUT: %At.3: %At.type.3 = struct_value () [template]
  566. // CHECK:STDOUT: %.6: type = assoc_entity_type %IndexWith.type.3, %At.type.3 [template]
  567. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [template]
  568. // CHECK:STDOUT: %.8: <witness> = interface_witness (%At.2) [template]
  569. // CHECK:STDOUT: %.9: type = ptr_type %.1 [template]
  570. // CHECK:STDOUT: %struct.1: %ElementType.1 = struct_value () [template]
  571. // CHECK:STDOUT: %struct.2: %C = struct_value () [template]
  572. // CHECK:STDOUT: %.10: i32 = int_literal 0 [template]
  573. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  574. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  575. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  576. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  577. // CHECK:STDOUT: %Self.3: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  578. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  579. // CHECK:STDOUT: %Self.4: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  580. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  581. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  582. // CHECK:STDOUT: %.11: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  583. // CHECK:STDOUT: %.12: %.11 = assoc_entity element0, imports.%import_ref.10 [symbolic]
  584. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%SubscriptType.1) [template]
  585. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%SubscriptType.1) [template]
  586. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  587. // CHECK:STDOUT: %.13: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  588. // CHECK:STDOUT: %.14: %.13 = assoc_entity element0, imports.%import_ref.10 [template]
  589. // CHECK:STDOUT: %.15: %.11 = assoc_entity element0, imports.%import_ref.11 [symbolic]
  590. // CHECK:STDOUT: %.16: %.4 = assoc_entity element0, imports.%import_ref.12 [symbolic]
  591. // CHECK:STDOUT: }
  592. // CHECK:STDOUT:
  593. // CHECK:STDOUT: imports {
  594. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  595. // CHECK:STDOUT: .IndexWith = %import_ref.1
  596. // CHECK:STDOUT: .ImplicitAs = %import_ref.6
  597. // CHECK:STDOUT: import Core//prelude
  598. // CHECK:STDOUT: import Core//prelude/...
  599. // CHECK:STDOUT: }
  600. // CHECK:STDOUT: %import_ref.1: %IndexWith.type.1 = import_ref Core//prelude/operators/index, inst+13, loaded [template = constants.%IndexWith]
  601. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/index, inst+22, unloaded
  602. // CHECK:STDOUT: %import_ref.3: @IndexWith.%.1 (%.4) = import_ref Core//prelude/operators/index, inst+50, loaded [symbolic = @IndexWith.%.2 (constants.%.16)]
  603. // CHECK:STDOUT: %import_ref.4: @IndexWith.%At.type (%At.type.1) = import_ref Core//prelude/operators/index, inst+42, loaded [symbolic = @IndexWith.%At (constants.%At.1)]
  604. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/index, inst+42, unloaded
  605. // CHECK:STDOUT: %import_ref.6: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
  606. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+55, unloaded
  607. // CHECK:STDOUT: %import_ref.8: @ImplicitAs.%.1 (%.11) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.15)]
  608. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/as, inst+70, unloaded
  609. // CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/as, inst+70, unloaded
  610. // CHECK:STDOUT: %import_ref.11 = import_ref Core//prelude/operators/as, inst+70, unloaded
  611. // CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/index, inst+42, unloaded
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT:
  614. // CHECK:STDOUT: file {
  615. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  616. // CHECK:STDOUT: .Core = imports.%Core
  617. // CHECK:STDOUT: .C = %C.decl
  618. // CHECK:STDOUT: .ElementType = %ElementType.decl
  619. // CHECK:STDOUT: .SubscriptType = %SubscriptType.decl
  620. // CHECK:STDOUT: .c = @__global_init.%c
  621. // CHECK:STDOUT: .x = @__global_init.%x
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT: %Core.import = import Core
  624. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  625. // CHECK:STDOUT: %ElementType.decl: type = class_decl @ElementType [template = constants.%ElementType.1] {} {}
  626. // CHECK:STDOUT: %SubscriptType.decl: type = class_decl @SubscriptType [template = constants.%SubscriptType.1] {} {}
  627. // CHECK:STDOUT: impl_decl @impl [template] {} {
  628. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  629. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  630. // CHECK:STDOUT: %IndexWith.ref: %IndexWith.type.1 = name_ref IndexWith, imports.%import_ref.1 [template = constants.%IndexWith]
  631. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  632. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  633. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) [template = constants.%IndexWith.type.3]
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  636. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, %ElementType.decl [template = constants.%ElementType.1]
  637. // CHECK:STDOUT: }
  638. // CHECK:STDOUT:
  639. // CHECK:STDOUT: generic interface @IndexWith(constants.%SubscriptType.2: type, constants.%ElementType.2: type) {
  640. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType.2)]
  641. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic = %SubscriptType.patt (constants.%SubscriptType.patt)]
  642. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType.2)]
  643. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic = %ElementType.patt (constants.%ElementType.patt)]
  644. // CHECK:STDOUT:
  645. // CHECK:STDOUT: !definition:
  646. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  647. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  648. // CHECK:STDOUT: %At.type: type = fn_type @At.1, @IndexWith(%SubscriptType, %ElementType) [symbolic = %At.type (constants.%At.type.1)]
  649. // CHECK:STDOUT: %At: @IndexWith.%At.type (%At.type.1) = struct_value () [symbolic = %At (constants.%At.1)]
  650. // CHECK:STDOUT: %.1: type = assoc_entity_type @IndexWith.%IndexWith.type (%IndexWith.type.2), @IndexWith.%At.type (%At.type.1) [symbolic = %.1 (constants.%.4)]
  651. // CHECK:STDOUT: %.2: @IndexWith.%.1 (%.4) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.5)]
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: interface {
  654. // CHECK:STDOUT: !members:
  655. // CHECK:STDOUT: .Self = imports.%import_ref.2
  656. // CHECK:STDOUT: .At = imports.%import_ref.3
  657. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  658. // CHECK:STDOUT: }
  659. // CHECK:STDOUT: }
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  662. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  663. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  664. // CHECK:STDOUT:
  665. // CHECK:STDOUT: !definition:
  666. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  667. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.4)]
  668. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  669. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  670. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.11)]
  671. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.11) = assoc_entity element0, imports.%import_ref.10 [symbolic = %.2 (constants.%.12)]
  672. // CHECK:STDOUT:
  673. // CHECK:STDOUT: interface {
  674. // CHECK:STDOUT: !members:
  675. // CHECK:STDOUT: .Self = imports.%import_ref.7
  676. // CHECK:STDOUT: .Convert = imports.%import_ref.8
  677. // CHECK:STDOUT: witness = (imports.%import_ref.9)
  678. // CHECK:STDOUT: }
  679. // CHECK:STDOUT: }
  680. // CHECK:STDOUT:
  681. // CHECK:STDOUT: impl @impl: %C.ref as %IndexWith.type {
  682. // CHECK:STDOUT: %At.decl: %At.type.2 = fn_decl @At.2 [template = constants.%At.2] {
  683. // CHECK:STDOUT: %self.patt: %C = binding_pattern self
  684. // CHECK:STDOUT: %self.param_patt: %C = value_param_pattern %self.patt, runtime_param0
  685. // CHECK:STDOUT: %subscript.patt: %SubscriptType.1 = binding_pattern subscript
  686. // CHECK:STDOUT: %subscript.param_patt: %SubscriptType.1 = value_param_pattern %subscript.patt, runtime_param1
  687. // CHECK:STDOUT: %return.patt: %ElementType.1 = return_slot_pattern
  688. // CHECK:STDOUT: %return.param_patt: %ElementType.1 = out_param_pattern %return.patt, runtime_param2
  689. // CHECK:STDOUT: } {
  690. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%C.ref [template = constants.%C]
  691. // CHECK:STDOUT: %SubscriptType.ref: type = name_ref SubscriptType, file.%SubscriptType.decl [template = constants.%SubscriptType.1]
  692. // CHECK:STDOUT: %ElementType.ref: type = name_ref ElementType, file.%ElementType.decl [template = constants.%ElementType.1]
  693. // CHECK:STDOUT: %self.param: %C = value_param runtime_param0
  694. // CHECK:STDOUT: %self: %C = bind_name self, %self.param
  695. // CHECK:STDOUT: %subscript.param: %SubscriptType.1 = value_param runtime_param1
  696. // CHECK:STDOUT: %subscript: %SubscriptType.1 = bind_name subscript, %subscript.param
  697. // CHECK:STDOUT: %return.param: ref %ElementType.1 = out_param runtime_param2
  698. // CHECK:STDOUT: %return: ref %ElementType.1 = return_slot %return.param
  699. // CHECK:STDOUT: }
  700. // CHECK:STDOUT: %.loc8: <witness> = interface_witness (%At.decl) [template = constants.%.8]
  701. // CHECK:STDOUT:
  702. // CHECK:STDOUT: !members:
  703. // CHECK:STDOUT: .At = %At.decl
  704. // CHECK:STDOUT: witness = %.loc8
  705. // CHECK:STDOUT: }
  706. // CHECK:STDOUT:
  707. // CHECK:STDOUT: class @C {
  708. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  709. // CHECK:STDOUT:
  710. // CHECK:STDOUT: !members:
  711. // CHECK:STDOUT: .Self = constants.%C
  712. // CHECK:STDOUT: }
  713. // CHECK:STDOUT:
  714. // CHECK:STDOUT: class @ElementType {
  715. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  716. // CHECK:STDOUT:
  717. // CHECK:STDOUT: !members:
  718. // CHECK:STDOUT: .Self = constants.%ElementType.1
  719. // CHECK:STDOUT: }
  720. // CHECK:STDOUT:
  721. // CHECK:STDOUT: class @SubscriptType {
  722. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.1 [template = constants.%.2]
  723. // CHECK:STDOUT:
  724. // CHECK:STDOUT: !members:
  725. // CHECK:STDOUT: .Self = constants.%SubscriptType.1
  726. // CHECK:STDOUT: }
  727. // CHECK:STDOUT:
  728. // CHECK:STDOUT: generic fn @At.1(constants.%SubscriptType.2: type, constants.%ElementType.2: type, constants.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2)) {
  729. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType.2)]
  730. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType.2)]
  731. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  732. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  733. // CHECK:STDOUT:
  734. // CHECK:STDOUT: fn[%self.param_patt: @At.1.%Self (%Self.2)](%subscript.param_patt: @At.1.%SubscriptType (%SubscriptType.2)) -> @At.1.%ElementType (%ElementType.2);
  735. // CHECK:STDOUT: }
  736. // CHECK:STDOUT:
  737. // CHECK:STDOUT: fn @At.2[%self.param_patt: %C](%subscript.param_patt: %SubscriptType.1) -> %return: %ElementType.1 {
  738. // CHECK:STDOUT: !entry:
  739. // CHECK:STDOUT: %.loc10_13.1: %.1 = struct_literal ()
  740. // CHECK:STDOUT: %.loc10_13.2: init %ElementType.1 = class_init (), %return [template = constants.%struct.1]
  741. // CHECK:STDOUT: %.loc10_14: init %ElementType.1 = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.1]
  742. // CHECK:STDOUT: return %.loc10_14 to %return
  743. // CHECK:STDOUT: }
  744. // CHECK:STDOUT:
  745. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.3: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  746. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  747. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  748. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.4)]
  749. // CHECK:STDOUT:
  750. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.4)]() -> @Convert.%Dest (%Dest);
  751. // CHECK:STDOUT: }
  752. // CHECK:STDOUT:
  753. // CHECK:STDOUT: fn @__global_init() {
  754. // CHECK:STDOUT: !entry:
  755. // CHECK:STDOUT: %.loc14_13.1: %.1 = struct_literal ()
  756. // CHECK:STDOUT: %.loc14_13.2: ref %C = temporary_storage
  757. // CHECK:STDOUT: %.loc14_13.3: init %C = class_init (), %.loc14_13.2 [template = constants.%struct.2]
  758. // CHECK:STDOUT: %.loc14_13.4: ref %C = temporary %.loc14_13.2, %.loc14_13.3
  759. // CHECK:STDOUT: %.loc14_14.1: ref %C = converted %.loc14_13.1, %.loc14_13.4
  760. // CHECK:STDOUT: %.loc14_14.2: %C = bind_value %.loc14_14.1
  761. // CHECK:STDOUT: %c: %C = bind_name c, %.loc14_14.2
  762. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  763. // CHECK:STDOUT: %.loc22_24: i32 = int_literal 0 [template = constants.%.10]
  764. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%SubscriptType.1) [template = constants.%ImplicitAs.type.3]
  765. // CHECK:STDOUT: %.loc22_25.1: %.13 = specific_constant imports.%import_ref.8, @ImplicitAs(constants.%SubscriptType.1) [template = constants.%.14]
  766. // CHECK:STDOUT: %Convert.ref: %.13 = name_ref Convert, %.loc22_25.1 [template = constants.%.14]
  767. // CHECK:STDOUT: %.loc22_25.2: %SubscriptType.1 = converted %.loc22_24, <error> [template = <error>]
  768. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) [template = constants.%IndexWith.type.3]
  769. // CHECK:STDOUT: %.loc22_25.3: %.6 = specific_constant imports.%import_ref.3, @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) [template = constants.%.7]
  770. // CHECK:STDOUT: %At.ref: %.6 = name_ref At, %.loc22_25.3 [template = constants.%.7]
  771. // CHECK:STDOUT: %.loc22_25.4: %At.type.3 = interface_witness_access constants.%.8, element0 [template = constants.%At.2]
  772. // CHECK:STDOUT: %.loc22_25.5: <bound method> = bound_method %c.ref, %.loc22_25.4
  773. // CHECK:STDOUT: %.loc22_25.6: ref %ElementType.1 = temporary_storage
  774. // CHECK:STDOUT: %At.call: init %ElementType.1 = call %.loc22_25.5(%c.ref, <error>) to %.loc22_25.6
  775. // CHECK:STDOUT: %.loc22_25.7: ref %ElementType.1 = temporary %.loc22_25.6, %At.call
  776. // CHECK:STDOUT: %.loc22_25.8: %ElementType.1 = bind_value %.loc22_25.7
  777. // CHECK:STDOUT: %x: %ElementType.1 = bind_name x, %.loc22_25.8
  778. // CHECK:STDOUT: return
  779. // CHECK:STDOUT: }
  780. // CHECK:STDOUT:
  781. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType.2, constants.%ElementType.2) {
  782. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  783. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.2
  784. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  785. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.2
  786. // CHECK:STDOUT: }
  787. // CHECK:STDOUT:
  788. // CHECK:STDOUT: specific @IndexWith(@IndexWith.%SubscriptType, @IndexWith.%ElementType) {
  789. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  790. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.2
  791. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  792. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.2
  793. // CHECK:STDOUT: }
  794. // CHECK:STDOUT:
  795. // CHECK:STDOUT: specific @IndexWith(@At.1.%SubscriptType, @At.1.%ElementType) {
  796. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  797. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.2
  798. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  799. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.2
  800. // CHECK:STDOUT: }
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: specific @At.1(constants.%SubscriptType.2, constants.%ElementType.2, constants.%Self.1) {
  803. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.2
  804. // CHECK:STDOUT: %ElementType => constants.%ElementType.2
  805. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.2
  806. // CHECK:STDOUT: %Self => constants.%Self.1
  807. // CHECK:STDOUT: }
  808. // CHECK:STDOUT:
  809. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType.1, constants.%ElementType.1) {
  810. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.1
  811. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType.1
  812. // CHECK:STDOUT: %ElementType => constants.%ElementType.1
  813. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType.1
  814. // CHECK:STDOUT:
  815. // CHECK:STDOUT: !definition:
  816. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.3
  817. // CHECK:STDOUT: %Self => constants.%Self.2
  818. // CHECK:STDOUT: %At.type => constants.%At.type.3
  819. // CHECK:STDOUT: %At => constants.%At.3
  820. // CHECK:STDOUT: %.1 => constants.%.6
  821. // CHECK:STDOUT: %.2 => constants.%.7
  822. // CHECK:STDOUT: }
  823. // CHECK:STDOUT:
  824. // CHECK:STDOUT: specific @At.1(constants.%SubscriptType.1, constants.%ElementType.1, constants.%C) {
  825. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType.1
  826. // CHECK:STDOUT: %ElementType => constants.%ElementType.1
  827. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.3
  828. // CHECK:STDOUT: %Self => constants.%C
  829. // CHECK:STDOUT: }
  830. // CHECK:STDOUT:
  831. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  832. // CHECK:STDOUT: %Dest => constants.%Dest
  833. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  834. // CHECK:STDOUT: }
  835. // CHECK:STDOUT:
  836. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  837. // CHECK:STDOUT: %Dest => constants.%Dest
  838. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  839. // CHECK:STDOUT: }
  840. // CHECK:STDOUT:
  841. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  842. // CHECK:STDOUT: %Dest => constants.%Dest
  843. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  844. // CHECK:STDOUT: }
  845. // CHECK:STDOUT:
  846. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.3) {
  847. // CHECK:STDOUT: %Dest => constants.%Dest
  848. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  849. // CHECK:STDOUT: %Self => constants.%Self.3
  850. // CHECK:STDOUT: }
  851. // CHECK:STDOUT:
  852. // CHECK:STDOUT: specific @ImplicitAs(constants.%SubscriptType.1) {
  853. // CHECK:STDOUT: %Dest => constants.%SubscriptType.1
  854. // CHECK:STDOUT: %Dest.patt => constants.%SubscriptType.1
  855. // CHECK:STDOUT:
  856. // CHECK:STDOUT: !definition:
  857. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  858. // CHECK:STDOUT: %Self => constants.%Self.4
  859. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  860. // CHECK:STDOUT: %Convert => constants.%Convert.2
  861. // CHECK:STDOUT: %.1 => constants.%.13
  862. // CHECK:STDOUT: %.2 => constants.%.14
  863. // CHECK:STDOUT: }
  864. // CHECK:STDOUT:
  865. // CHECK:STDOUT: --- fail_index_with_not_implemented.carbon
  866. // CHECK:STDOUT:
  867. // CHECK:STDOUT: constants {
  868. // CHECK:STDOUT: %C: type = class_type @C [template]
  869. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  870. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  871. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  872. // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
  873. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  874. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  875. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  876. // CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
  877. // CHECK:STDOUT: %IndexWith.type.1: type = generic_interface_type @IndexWith [template]
  878. // CHECK:STDOUT: %IndexWith: %IndexWith.type.1 = struct_value () [template]
  879. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic]
  880. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic]
  881. // CHECK:STDOUT: %IndexWith.type.2: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  882. // CHECK:STDOUT: %Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2) = bind_symbolic_name Self, 2 [symbolic]
  883. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic]
  884. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic]
  885. // CHECK:STDOUT: %Self.2: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic]
  886. // CHECK:STDOUT: %At.type: type = fn_type @At, @IndexWith(%SubscriptType, %ElementType) [symbolic]
  887. // CHECK:STDOUT: %At: %At.type = struct_value () [symbolic]
  888. // CHECK:STDOUT: %.6: type = assoc_entity_type %IndexWith.type.2, %At.type [symbolic]
  889. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  890. // CHECK:STDOUT: }
  891. // CHECK:STDOUT:
  892. // CHECK:STDOUT: imports {
  893. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  894. // CHECK:STDOUT: .Int32 = %import_ref.1
  895. // CHECK:STDOUT: .IndexWith = %import_ref.2
  896. // CHECK:STDOUT: import Core//prelude
  897. // CHECK:STDOUT: import Core//prelude/...
  898. // CHECK:STDOUT: }
  899. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  900. // CHECK:STDOUT: %import_ref.2: %IndexWith.type.1 = import_ref Core//prelude/operators/index, inst+13, loaded [template = constants.%IndexWith]
  901. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/index, inst+22, unloaded
  902. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/index, inst+50, unloaded
  903. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/index, inst+42, unloaded
  904. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/index, inst+42, unloaded
  905. // CHECK:STDOUT: }
  906. // CHECK:STDOUT:
  907. // CHECK:STDOUT: file {
  908. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  909. // CHECK:STDOUT: .Core = imports.%Core
  910. // CHECK:STDOUT: .C = %C.decl
  911. // CHECK:STDOUT: .c = @__global_init.%c
  912. // CHECK:STDOUT: .x = @__global_init.%x
  913. // CHECK:STDOUT: }
  914. // CHECK:STDOUT: %Core.import = import Core
  915. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  916. // CHECK:STDOUT: %C.ref: type = name_ref C, %C.decl [template = constants.%C]
  917. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  918. // CHECK:STDOUT: %.loc10_8.1: type = value_of_initializer %int.make_type_32 [template = i32]
  919. // CHECK:STDOUT: %.loc10_8.2: type = converted %int.make_type_32, %.loc10_8.1 [template = i32]
  920. // CHECK:STDOUT: }
  921. // CHECK:STDOUT:
  922. // CHECK:STDOUT: generic interface @IndexWith(constants.%SubscriptType: type, constants.%ElementType: type) {
  923. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  924. // CHECK:STDOUT: %SubscriptType.patt: type = symbolic_binding_pattern SubscriptType, 0 [symbolic = %SubscriptType.patt (constants.%SubscriptType.patt)]
  925. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)]
  926. // CHECK:STDOUT: %ElementType.patt: type = symbolic_binding_pattern ElementType, 1 [symbolic = %ElementType.patt (constants.%ElementType.patt)]
  927. // CHECK:STDOUT:
  928. // CHECK:STDOUT: !definition:
  929. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  930. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  931. // CHECK:STDOUT: %At.type: type = fn_type @At, @IndexWith(%SubscriptType, %ElementType) [symbolic = %At.type (constants.%At.type)]
  932. // CHECK:STDOUT: %At: @IndexWith.%At.type (%At.type) = struct_value () [symbolic = %At (constants.%At)]
  933. // CHECK:STDOUT: %.1: type = assoc_entity_type @IndexWith.%IndexWith.type (%IndexWith.type.2), @IndexWith.%At.type (%At.type) [symbolic = %.1 (constants.%.6)]
  934. // CHECK:STDOUT: %.2: @IndexWith.%.1 (%.6) = assoc_entity element0, imports.%import_ref.6 [symbolic = %.2 (constants.%.7)]
  935. // CHECK:STDOUT:
  936. // CHECK:STDOUT: interface {
  937. // CHECK:STDOUT: !members:
  938. // CHECK:STDOUT: .Self = imports.%import_ref.3
  939. // CHECK:STDOUT: .At = imports.%import_ref.4
  940. // CHECK:STDOUT: witness = (imports.%import_ref.5)
  941. // CHECK:STDOUT: }
  942. // CHECK:STDOUT: }
  943. // CHECK:STDOUT:
  944. // CHECK:STDOUT: class @C {
  945. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  946. // CHECK:STDOUT:
  947. // CHECK:STDOUT: !members:
  948. // CHECK:STDOUT: .Self = constants.%C
  949. // CHECK:STDOUT: }
  950. // CHECK:STDOUT:
  951. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  952. // CHECK:STDOUT:
  953. // CHECK:STDOUT: generic fn @At(constants.%SubscriptType: type, constants.%ElementType: type, constants.%Self.1: @IndexWith.%IndexWith.type (%IndexWith.type.2)) {
  954. // CHECK:STDOUT: %SubscriptType: type = bind_symbolic_name SubscriptType, 0 [symbolic = %SubscriptType (constants.%SubscriptType)]
  955. // CHECK:STDOUT: %ElementType: type = bind_symbolic_name ElementType, 1 [symbolic = %ElementType (constants.%ElementType)]
  956. // CHECK:STDOUT: %IndexWith.type: type = interface_type @IndexWith, @IndexWith(%SubscriptType, %ElementType) [symbolic = %IndexWith.type (constants.%IndexWith.type.2)]
  957. // CHECK:STDOUT: %Self: %IndexWith.type.2 = bind_symbolic_name Self, 2 [symbolic = %Self (constants.%Self.2)]
  958. // CHECK:STDOUT:
  959. // CHECK:STDOUT: fn[%self.param_patt: @At.%Self (%Self.2)](%subscript.param_patt: @At.%SubscriptType (%SubscriptType)) -> @At.%ElementType (%ElementType);
  960. // CHECK:STDOUT: }
  961. // CHECK:STDOUT:
  962. // CHECK:STDOUT: fn @__global_init() {
  963. // CHECK:STDOUT: !entry:
  964. // CHECK:STDOUT: %.loc6_13.1: %.1 = struct_literal ()
  965. // CHECK:STDOUT: %.loc6_13.2: ref %C = temporary_storage
  966. // CHECK:STDOUT: %.loc6_13.3: init %C = class_init (), %.loc6_13.2 [template = constants.%struct]
  967. // CHECK:STDOUT: %.loc6_13.4: ref %C = temporary %.loc6_13.2, %.loc6_13.3
  968. // CHECK:STDOUT: %.loc6_14.1: ref %C = converted %.loc6_13.1, %.loc6_13.4
  969. // CHECK:STDOUT: %.loc6_14.2: %C = bind_value %.loc6_14.1
  970. // CHECK:STDOUT: %c: %C = bind_name c, %.loc6_14.2
  971. // CHECK:STDOUT: %c.ref: %C = name_ref c, %c
  972. // CHECK:STDOUT: %.loc10: i32 = int_literal 0 [template = constants.%.5]
  973. // CHECK:STDOUT: %x: i32 = bind_name x, <error>
  974. // CHECK:STDOUT: return
  975. // CHECK:STDOUT: }
  976. // CHECK:STDOUT:
  977. // CHECK:STDOUT: specific @IndexWith(constants.%SubscriptType, constants.%ElementType) {
  978. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  979. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType
  980. // CHECK:STDOUT: %ElementType => constants.%ElementType
  981. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType
  982. // CHECK:STDOUT: }
  983. // CHECK:STDOUT:
  984. // CHECK:STDOUT: specific @IndexWith(@IndexWith.%SubscriptType, @IndexWith.%ElementType) {
  985. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  986. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType
  987. // CHECK:STDOUT: %ElementType => constants.%ElementType
  988. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType
  989. // CHECK:STDOUT: }
  990. // CHECK:STDOUT:
  991. // CHECK:STDOUT: specific @IndexWith(@At.%SubscriptType, @At.%ElementType) {
  992. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  993. // CHECK:STDOUT: %SubscriptType.patt => constants.%SubscriptType
  994. // CHECK:STDOUT: %ElementType => constants.%ElementType
  995. // CHECK:STDOUT: %ElementType.patt => constants.%ElementType
  996. // CHECK:STDOUT: }
  997. // CHECK:STDOUT:
  998. // CHECK:STDOUT: specific @At(constants.%SubscriptType, constants.%ElementType, constants.%Self.1) {
  999. // CHECK:STDOUT: %SubscriptType => constants.%SubscriptType
  1000. // CHECK:STDOUT: %ElementType => constants.%ElementType
  1001. // CHECK:STDOUT: %IndexWith.type => constants.%IndexWith.type.2
  1002. // CHECK:STDOUT: %Self => constants.%Self.1
  1003. // CHECK:STDOUT: }
  1004. // CHECK:STDOUT: