array.carbon 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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/deduce/array.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/deduce/array.carbon
  10. // --- type_only.carbon
  11. library "[[@TEST_NAME]]";
  12. class C {}
  13. fn F[T:! type](a: [T; 3]) -> T { return a[0]; }
  14. fn G() -> C {
  15. var a: [C; 3] = ({}, {}, {});
  16. return F(a);
  17. }
  18. // --- fail_todo_bound_only.carbon
  19. library "[[@TEST_NAME]]";
  20. class C {}
  21. // CHECK:STDERR: fail_todo_bound_only.carbon:[[@LINE+4]]:22: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
  22. // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  23. // CHECK:STDERR: ^
  24. // CHECK:STDERR:
  25. fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  26. fn G() -> C {
  27. var a: [C; 3] = ({}, {}, {});
  28. return F(a);
  29. }
  30. // --- fail_todo_type_and_bound.carbon
  31. library "[[@TEST_NAME]]";
  32. class C {}
  33. // CHECK:STDERR: fail_todo_type_and_bound.carbon:[[@LINE+4]]:32: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
  34. // CHECK:STDERR: fn F[T:! type, N:! i32](a: [T; N]) -> T;
  35. // CHECK:STDERR: ^
  36. // CHECK:STDERR:
  37. fn F[T:! type, N:! i32](a: [T; N]) -> T;
  38. fn G() -> C {
  39. var a: [C; 3] = ({}, {}, {});
  40. return F(a);
  41. }
  42. // --- fail_bound_mismatch.carbon
  43. library "[[@TEST_NAME]]";
  44. class C {}
  45. fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
  46. fn G() -> C {
  47. // TODO: We succeed at deducing T here but fail to convert. Is this the right behavior?
  48. var a: [C; 3] = ({}, {}, {});
  49. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+10]]:12: error: cannot implicitly convert from `[C; 3]` to `[C; 2]` [ImplicitAsConversionFailure]
  50. // CHECK:STDERR: return F(a);
  51. // CHECK:STDERR: ^
  52. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+7]]:12: note: type `[C; 3]` does not implement interface `ImplicitAs([C; 2])` [MissingImplInMemberAccessNote]
  53. // CHECK:STDERR: return F(a);
  54. // CHECK:STDERR: ^
  55. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE-11]]:16: note: initializing function parameter [InCallToFunctionParam]
  56. // CHECK:STDERR: fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
  57. // CHECK:STDERR: ^~~~~~~~~
  58. // CHECK:STDERR:
  59. return F(a);
  60. }
  61. // --- fail_type_mismatch.carbon
  62. library "[[@TEST_NAME]]";
  63. class C {}
  64. class D {}
  65. // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:22: error: semantics TODO: `symbolic array bound` [SemanticsTodo]
  66. // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  67. // CHECK:STDERR: ^
  68. fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  69. fn G() -> C {
  70. var a: [D; 3] = ({}, {}, {});
  71. return F(a);
  72. }
  73. // CHECK:STDOUT: --- type_only.carbon
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: constants {
  76. // CHECK:STDOUT: %C: type = class_type @C [template]
  77. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  78. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  79. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  80. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  81. // CHECK:STDOUT: %.3: i32 = int_value 3 [template]
  82. // CHECK:STDOUT: %.4: type = array_type %.3, %T [symbolic]
  83. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  84. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  85. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  86. // CHECK:STDOUT: %.5: type = ptr_type %.4 [symbolic]
  87. // CHECK:STDOUT: %.6: i32 = int_value 0 [template]
  88. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  89. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  90. // CHECK:STDOUT: %.7: type = ptr_type %.1 [template]
  91. // CHECK:STDOUT: %.8: type = array_type %.3, %C [template]
  92. // CHECK:STDOUT: %.9: type = ptr_type %.8 [template]
  93. // CHECK:STDOUT: %tuple.type: type = tuple_type (%.1, %.1, %.1) [template]
  94. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  95. // CHECK:STDOUT: %.10: i32 = int_value 1 [template]
  96. // CHECK:STDOUT: %.11: i32 = int_value 2 [template]
  97. // CHECK:STDOUT: %array: %.8 = tuple_value (%struct, %struct, %struct) [template]
  98. // CHECK:STDOUT: %.12: <specific function> = specific_function %F, @F(%C) [template]
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: imports {
  102. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  103. // CHECK:STDOUT: import Core//prelude
  104. // CHECK:STDOUT: import Core//prelude/...
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: file {
  109. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  110. // CHECK:STDOUT: .Core = imports.%Core
  111. // CHECK:STDOUT: .C = %C.decl
  112. // CHECK:STDOUT: .F = %F.decl
  113. // CHECK:STDOUT: .G = %G.decl
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: %Core.import = import Core
  116. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  117. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  118. // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  119. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param<invalid> [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  120. // CHECK:STDOUT: %a.patt: @F.%.loc6_24.2 (%.4) = binding_pattern a
  121. // CHECK:STDOUT: %a.param_patt: @F.%.loc6_24.2 (%.4) = value_param_pattern %a.patt, runtime_param0
  122. // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern
  123. // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  124. // CHECK:STDOUT: } {
  125. // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  126. // CHECK:STDOUT: %.loc6_23: i32 = int_value 3 [template = constants.%.3]
  127. // CHECK:STDOUT: %.loc6_24.1: type = array_type %.loc6_23, %T [symbolic = %.loc6_24.2 (constants.%.4)]
  128. // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  129. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  130. // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
  131. // CHECK:STDOUT: %a.param: @F.%.loc6_24.2 (%.4) = value_param runtime_param0
  132. // CHECK:STDOUT: %a: @F.%.loc6_24.2 (%.4) = bind_name a, %a.param
  133. // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1
  134. // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  137. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  138. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  139. // CHECK:STDOUT: } {
  140. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
  141. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  142. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: class @C {
  147. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: !members:
  150. // CHECK:STDOUT: .Self = constants.%C
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
  154. // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
  155. // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  156. // CHECK:STDOUT: %.loc6_24.2: type = array_type constants.%.3, @F.%T.loc6_6.2 (%T) [symbolic = %.loc6_24.2 (constants.%.4)]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !definition:
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%.loc6_24.2 (%.4)) -> @F.%T.loc6_6.2 (%T) {
  161. // CHECK:STDOUT: !entry:
  162. // CHECK:STDOUT: %a.ref: @F.%.loc6_24.2 (%.4) = name_ref a, %a
  163. // CHECK:STDOUT: %.loc6_43: i32 = int_value 0 [template = constants.%.6]
  164. // CHECK:STDOUT: %.loc6_44.1: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref
  165. // CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43
  166. // CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2
  167. // CHECK:STDOUT: return %.loc6_44.3
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: fn @G() -> %return: %C {
  172. // CHECK:STDOUT: !entry:
  173. // CHECK:STDOUT: %C.ref.loc9: type = name_ref C, file.%C.decl [template = constants.%C]
  174. // CHECK:STDOUT: %.loc9_14: i32 = int_value 3 [template = constants.%.3]
  175. // CHECK:STDOUT: %.loc9_15: type = array_type %.loc9_14, %C [template = constants.%.8]
  176. // CHECK:STDOUT: %a.var: ref %.8 = var a
  177. // CHECK:STDOUT: %a: ref %.8 = bind_name a, %a.var
  178. // CHECK:STDOUT: %.loc9_21.1: %.1 = struct_literal ()
  179. // CHECK:STDOUT: %.loc9_25.1: %.1 = struct_literal ()
  180. // CHECK:STDOUT: %.loc9_29.1: %.1 = struct_literal ()
  181. // CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1)
  182. // CHECK:STDOUT: %.loc9_30.2: i32 = int_value 0 [template = constants.%.6]
  183. // CHECK:STDOUT: %.loc9_30.3: ref %C = array_index %a.var, %.loc9_30.2
  184. // CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.3 [template = constants.%struct]
  185. // CHECK:STDOUT: %.loc9_30.4: init %C = converted %.loc9_21.1, %.loc9_21.2 [template = constants.%struct]
  186. // CHECK:STDOUT: %.loc9_30.5: i32 = int_value 1 [template = constants.%.10]
  187. // CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %.loc9_30.5
  188. // CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.6 [template = constants.%struct]
  189. // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%struct]
  190. // CHECK:STDOUT: %.loc9_30.8: i32 = int_value 2 [template = constants.%.11]
  191. // CHECK:STDOUT: %.loc9_30.9: ref %C = array_index %a.var, %.loc9_30.8
  192. // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.9 [template = constants.%struct]
  193. // CHECK:STDOUT: %.loc9_30.10: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%struct]
  194. // CHECK:STDOUT: %.loc9_30.11: init %.8 = array_init (%.loc9_30.4, %.loc9_30.7, %.loc9_30.10) to %a.var [template = constants.%array]
  195. // CHECK:STDOUT: %.loc9_31: init %.8 = converted %.loc9_30.1, %.loc9_30.11 [template = constants.%array]
  196. // CHECK:STDOUT: assign %a.var, %.loc9_31
  197. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  198. // CHECK:STDOUT: %a.ref: ref %.8 = name_ref a, %a
  199. // CHECK:STDOUT: %.loc10_10: <specific function> = specific_function %F.ref, @F(constants.%C) [template = constants.%.12]
  200. // CHECK:STDOUT: %.loc8_8.2: ref %C = splice_block %return {}
  201. // CHECK:STDOUT: %.loc10_12: %.8 = bind_value %a.ref
  202. // CHECK:STDOUT: %F.call: init %C = call %.loc10_10(%.loc10_12) to %.loc8_8.2
  203. // CHECK:STDOUT: return %F.call to %return
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: specific @F(constants.%T) {
  207. // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
  208. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T
  209. // CHECK:STDOUT: %.loc6_24.2 => constants.%.4
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: specific @F(constants.%C) {
  213. // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
  214. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C
  215. // CHECK:STDOUT: %.loc6_24.2 => constants.%.8
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: !definition:
  218. // CHECK:STDOUT: }
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: --- fail_todo_bound_only.carbon
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: constants {
  223. // CHECK:STDOUT: %C: type = class_type @C [template]
  224. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  225. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  226. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  227. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  228. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  229. // CHECK:STDOUT: %N: i32 = bind_symbolic_name N, 0 [symbolic]
  230. // CHECK:STDOUT: %N.patt: i32 = symbolic_binding_pattern N, 0 [symbolic]
  231. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  232. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  233. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  234. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  235. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  236. // CHECK:STDOUT: %.4: i32 = int_value 3 [template]
  237. // CHECK:STDOUT: %.5: type = array_type %.4, %C [template]
  238. // CHECK:STDOUT: %.6: type = ptr_type %.5 [template]
  239. // CHECK:STDOUT: %tuple.type: type = tuple_type (%.1, %.1, %.1) [template]
  240. // CHECK:STDOUT: %.7: i32 = int_value 0 [template]
  241. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  242. // CHECK:STDOUT: %.8: i32 = int_value 1 [template]
  243. // CHECK:STDOUT: %.9: i32 = int_value 2 [template]
  244. // CHECK:STDOUT: %array: %.5 = tuple_value (%struct, %struct, %struct) [template]
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: imports {
  248. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  249. // CHECK:STDOUT: .Int32 = %import_ref
  250. // CHECK:STDOUT: import Core//prelude
  251. // CHECK:STDOUT: import Core//prelude/...
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: file {
  257. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  258. // CHECK:STDOUT: .Core = imports.%Core
  259. // CHECK:STDOUT: .C = %C.decl
  260. // CHECK:STDOUT: .F = %F.decl
  261. // CHECK:STDOUT: .G = %G.decl
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT: %Core.import = import Core
  264. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  265. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  266. // CHECK:STDOUT: %N.patt.loc10_6.1: i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt)]
  267. // CHECK:STDOUT: %N.param_patt: i32 = value_param_pattern %N.patt.loc10_6.1, runtime_param<invalid> [symbolic = %N.patt.loc10_6.2 (constants.%N.patt)]
  268. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  269. // CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
  270. // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern
  271. // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param1
  272. // CHECK:STDOUT: } {
  273. // CHECK:STDOUT: %int.make_type_32.loc10_10: init type = call constants.%Int32() [template = i32]
  274. // CHECK:STDOUT: %.loc10_10.1: type = value_of_initializer %int.make_type_32.loc10_10 [template = i32]
  275. // CHECK:STDOUT: %.loc10_10.2: type = converted %int.make_type_32.loc10_10, %.loc10_10.1 [template = i32]
  276. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  277. // CHECK:STDOUT: %N.ref.loc10_22: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
  278. // CHECK:STDOUT: %.loc10_23: type = array_type %N.ref.loc10_22, %C [template = <error>]
  279. // CHECK:STDOUT: %int.make_type_32.loc10_29: init type = call constants.%Int32() [template = i32]
  280. // CHECK:STDOUT: %.loc10_29.1: type = value_of_initializer %int.make_type_32.loc10_29 [template = i32]
  281. // CHECK:STDOUT: %.loc10_29.2: type = converted %int.make_type_32.loc10_29, %.loc10_29.1 [template = i32]
  282. // CHECK:STDOUT: %N.param: i32 = value_param runtime_param<invalid>
  283. // CHECK:STDOUT: %N.loc10_6.1: i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc10_6.2 (constants.%N)]
  284. // CHECK:STDOUT: %a.param: <error> = value_param runtime_param0
  285. // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
  286. // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param1
  287. // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  290. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  291. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  292. // CHECK:STDOUT: } {
  293. // CHECK:STDOUT: %C.ref.loc12: type = name_ref C, file.%C.decl [template = constants.%C]
  294. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  295. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: class @C {
  300. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: !members:
  303. // CHECK:STDOUT: .Self = constants.%C
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: generic fn @F(%N.loc10_6.1: i32) {
  309. // CHECK:STDOUT: %N.loc10_6.2: i32 = bind_symbolic_name N, 0 [symbolic = %N.loc10_6.2 (constants.%N)]
  310. // CHECK:STDOUT: %N.patt.loc10_6.2: i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt)]
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: !definition:
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: fn[%N.param_patt: i32](%a.param_patt: <error>) -> i32 {
  315. // CHECK:STDOUT: !entry:
  316. // CHECK:STDOUT: %N.ref.loc10_42: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
  317. // CHECK:STDOUT: return %N.ref.loc10_42
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT: }
  320. // CHECK:STDOUT:
  321. // CHECK:STDOUT: fn @G() -> %return: %C {
  322. // CHECK:STDOUT: !entry:
  323. // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, file.%C.decl [template = constants.%C]
  324. // CHECK:STDOUT: %.loc13_14: i32 = int_value 3 [template = constants.%.4]
  325. // CHECK:STDOUT: %.loc13_15: type = array_type %.loc13_14, %C [template = constants.%.5]
  326. // CHECK:STDOUT: %a.var: ref %.5 = var a
  327. // CHECK:STDOUT: %a: ref %.5 = bind_name a, %a.var
  328. // CHECK:STDOUT: %.loc13_21.1: %.1 = struct_literal ()
  329. // CHECK:STDOUT: %.loc13_25.1: %.1 = struct_literal ()
  330. // CHECK:STDOUT: %.loc13_29.1: %.1 = struct_literal ()
  331. // CHECK:STDOUT: %.loc13_30.1: %tuple.type = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
  332. // CHECK:STDOUT: %.loc13_30.2: i32 = int_value 0 [template = constants.%.7]
  333. // CHECK:STDOUT: %.loc13_30.3: ref %C = array_index %a.var, %.loc13_30.2
  334. // CHECK:STDOUT: %.loc13_21.2: init %C = class_init (), %.loc13_30.3 [template = constants.%struct]
  335. // CHECK:STDOUT: %.loc13_30.4: init %C = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%struct]
  336. // CHECK:STDOUT: %.loc13_30.5: i32 = int_value 1 [template = constants.%.8]
  337. // CHECK:STDOUT: %.loc13_30.6: ref %C = array_index %a.var, %.loc13_30.5
  338. // CHECK:STDOUT: %.loc13_25.2: init %C = class_init (), %.loc13_30.6 [template = constants.%struct]
  339. // CHECK:STDOUT: %.loc13_30.7: init %C = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%struct]
  340. // CHECK:STDOUT: %.loc13_30.8: i32 = int_value 2 [template = constants.%.9]
  341. // CHECK:STDOUT: %.loc13_30.9: ref %C = array_index %a.var, %.loc13_30.8
  342. // CHECK:STDOUT: %.loc13_29.2: init %C = class_init (), %.loc13_30.9 [template = constants.%struct]
  343. // CHECK:STDOUT: %.loc13_30.10: init %C = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%struct]
  344. // CHECK:STDOUT: %.loc13_30.11: init %.5 = array_init (%.loc13_30.4, %.loc13_30.7, %.loc13_30.10) to %a.var [template = constants.%array]
  345. // CHECK:STDOUT: %.loc13_31: init %.5 = converted %.loc13_30.1, %.loc13_30.11 [template = constants.%array]
  346. // CHECK:STDOUT: assign %a.var, %.loc13_31
  347. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  348. // CHECK:STDOUT: %a.ref: ref %.5 = name_ref a, %a
  349. // CHECK:STDOUT: return <error> to %return
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: specific @F(constants.%N) {
  353. // CHECK:STDOUT: %N.loc10_6.2 => constants.%N
  354. // CHECK:STDOUT: %N.patt.loc10_6.2 => constants.%N
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: --- fail_todo_type_and_bound.carbon
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: constants {
  360. // CHECK:STDOUT: %C: type = class_type @C [template]
  361. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  362. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  363. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  364. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  365. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  366. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  367. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  368. // CHECK:STDOUT: %N: i32 = bind_symbolic_name N, 1 [symbolic]
  369. // CHECK:STDOUT: %N.patt: i32 = symbolic_binding_pattern N, 1 [symbolic]
  370. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  371. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  372. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  373. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  374. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  375. // CHECK:STDOUT: %.4: i32 = int_value 3 [template]
  376. // CHECK:STDOUT: %.5: type = array_type %.4, %C [template]
  377. // CHECK:STDOUT: %.6: type = ptr_type %.5 [template]
  378. // CHECK:STDOUT: %tuple.type: type = tuple_type (%.1, %.1, %.1) [template]
  379. // CHECK:STDOUT: %.7: i32 = int_value 0 [template]
  380. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  381. // CHECK:STDOUT: %.8: i32 = int_value 1 [template]
  382. // CHECK:STDOUT: %.9: i32 = int_value 2 [template]
  383. // CHECK:STDOUT: %array: %.5 = tuple_value (%struct, %struct, %struct) [template]
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: imports {
  387. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  388. // CHECK:STDOUT: .Int32 = %import_ref
  389. // CHECK:STDOUT: import Core//prelude
  390. // CHECK:STDOUT: import Core//prelude/...
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: file {
  396. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  397. // CHECK:STDOUT: .Core = imports.%Core
  398. // CHECK:STDOUT: .C = %C.decl
  399. // CHECK:STDOUT: .F = %F.decl
  400. // CHECK:STDOUT: .G = %G.decl
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT: %Core.import = import Core
  403. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  404. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  405. // CHECK:STDOUT: %T.patt.loc10_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc10_6.2 (constants.%T.patt)]
  406. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc10_6.1, runtime_param<invalid> [symbolic = %T.patt.loc10_6.2 (constants.%T.patt)]
  407. // CHECK:STDOUT: %N.patt.loc10_16.1: i32 = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc10_16.2 (constants.%N.patt)]
  408. // CHECK:STDOUT: %N.param_patt: i32 = value_param_pattern %N.patt.loc10_16.1, runtime_param<invalid> [symbolic = %N.patt.loc10_16.2 (constants.%N.patt)]
  409. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  410. // CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
  411. // CHECK:STDOUT: %return.patt: @F.%T.loc10_6.2 (%T) = return_slot_pattern
  412. // CHECK:STDOUT: %return.param_patt: @F.%T.loc10_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  413. // CHECK:STDOUT: } {
  414. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  415. // CHECK:STDOUT: %.loc10_20.1: type = value_of_initializer %int.make_type_32 [template = i32]
  416. // CHECK:STDOUT: %.loc10_20.2: type = converted %int.make_type_32, %.loc10_20.1 [template = i32]
  417. // CHECK:STDOUT: %T.ref.loc10_29: type = name_ref T, %T.loc10_6.1 [symbolic = %T.loc10_6.2 (constants.%T)]
  418. // CHECK:STDOUT: %N.ref: i32 = name_ref N, %N.loc10_16.1 [symbolic = %N.loc10_16.2 (constants.%N)]
  419. // CHECK:STDOUT: %.loc10_33: type = array_type %N.ref, %T [template = <error>]
  420. // CHECK:STDOUT: %T.ref.loc10_39: type = name_ref T, %T.loc10_6.1 [symbolic = %T.loc10_6.2 (constants.%T)]
  421. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  422. // CHECK:STDOUT: %T.loc10_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc10_6.2 (constants.%T)]
  423. // CHECK:STDOUT: %N.param: i32 = value_param runtime_param<invalid>
  424. // CHECK:STDOUT: %N.loc10_16.1: i32 = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc10_16.2 (constants.%N)]
  425. // CHECK:STDOUT: %a.param: <error> = value_param runtime_param0
  426. // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
  427. // CHECK:STDOUT: %return.param: ref @F.%T.loc10_6.2 (%T) = out_param runtime_param1
  428. // CHECK:STDOUT: %return: ref @F.%T.loc10_6.2 (%T) = return_slot %return.param
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  431. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  432. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  433. // CHECK:STDOUT: } {
  434. // CHECK:STDOUT: %C.ref.loc12: type = name_ref C, file.%C.decl [template = constants.%C]
  435. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  436. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: class @C {
  441. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: !members:
  444. // CHECK:STDOUT: .Self = constants.%C
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT:
  447. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: generic fn @F(%T.loc10_6.1: type, %N.loc10_16.1: i32) {
  450. // CHECK:STDOUT: %T.loc10_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc10_6.2 (constants.%T)]
  451. // CHECK:STDOUT: %T.patt.loc10_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc10_6.2 (constants.%T.patt)]
  452. // CHECK:STDOUT: %N.loc10_16.2: i32 = bind_symbolic_name N, 1 [symbolic = %N.loc10_16.2 (constants.%N)]
  453. // CHECK:STDOUT: %N.patt.loc10_16.2: i32 = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc10_16.2 (constants.%N.patt)]
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: fn[%T.param_patt: type, %N.param_patt: i32](%a.param_patt: <error>) -> @F.%T.loc10_6.2 (%T);
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: fn @G() -> %return: %C {
  459. // CHECK:STDOUT: !entry:
  460. // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, file.%C.decl [template = constants.%C]
  461. // CHECK:STDOUT: %.loc13_14: i32 = int_value 3 [template = constants.%.4]
  462. // CHECK:STDOUT: %.loc13_15: type = array_type %.loc13_14, %C [template = constants.%.5]
  463. // CHECK:STDOUT: %a.var: ref %.5 = var a
  464. // CHECK:STDOUT: %a: ref %.5 = bind_name a, %a.var
  465. // CHECK:STDOUT: %.loc13_21.1: %.1 = struct_literal ()
  466. // CHECK:STDOUT: %.loc13_25.1: %.1 = struct_literal ()
  467. // CHECK:STDOUT: %.loc13_29.1: %.1 = struct_literal ()
  468. // CHECK:STDOUT: %.loc13_30.1: %tuple.type = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
  469. // CHECK:STDOUT: %.loc13_30.2: i32 = int_value 0 [template = constants.%.7]
  470. // CHECK:STDOUT: %.loc13_30.3: ref %C = array_index %a.var, %.loc13_30.2
  471. // CHECK:STDOUT: %.loc13_21.2: init %C = class_init (), %.loc13_30.3 [template = constants.%struct]
  472. // CHECK:STDOUT: %.loc13_30.4: init %C = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%struct]
  473. // CHECK:STDOUT: %.loc13_30.5: i32 = int_value 1 [template = constants.%.8]
  474. // CHECK:STDOUT: %.loc13_30.6: ref %C = array_index %a.var, %.loc13_30.5
  475. // CHECK:STDOUT: %.loc13_25.2: init %C = class_init (), %.loc13_30.6 [template = constants.%struct]
  476. // CHECK:STDOUT: %.loc13_30.7: init %C = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%struct]
  477. // CHECK:STDOUT: %.loc13_30.8: i32 = int_value 2 [template = constants.%.9]
  478. // CHECK:STDOUT: %.loc13_30.9: ref %C = array_index %a.var, %.loc13_30.8
  479. // CHECK:STDOUT: %.loc13_29.2: init %C = class_init (), %.loc13_30.9 [template = constants.%struct]
  480. // CHECK:STDOUT: %.loc13_30.10: init %C = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%struct]
  481. // CHECK:STDOUT: %.loc13_30.11: init %.5 = array_init (%.loc13_30.4, %.loc13_30.7, %.loc13_30.10) to %a.var [template = constants.%array]
  482. // CHECK:STDOUT: %.loc13_31: init %.5 = converted %.loc13_30.1, %.loc13_30.11 [template = constants.%array]
  483. // CHECK:STDOUT: assign %a.var, %.loc13_31
  484. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  485. // CHECK:STDOUT: %a.ref: ref %.5 = name_ref a, %a
  486. // CHECK:STDOUT: return <error> to %return
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT:
  489. // CHECK:STDOUT: specific @F(constants.%T, constants.%N) {
  490. // CHECK:STDOUT: %T.loc10_6.2 => constants.%T
  491. // CHECK:STDOUT: %T.patt.loc10_6.2 => constants.%T
  492. // CHECK:STDOUT: %N.loc10_16.2 => constants.%N
  493. // CHECK:STDOUT: %N.patt.loc10_16.2 => constants.%N
  494. // CHECK:STDOUT: }
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: --- fail_bound_mismatch.carbon
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: constants {
  499. // CHECK:STDOUT: %C: type = class_type @C [template]
  500. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  501. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  502. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  503. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  504. // CHECK:STDOUT: %.3: i32 = int_value 2 [template]
  505. // CHECK:STDOUT: %.4: type = array_type %.3, %T [symbolic]
  506. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  507. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  508. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  509. // CHECK:STDOUT: %.5: type = ptr_type %.4 [symbolic]
  510. // CHECK:STDOUT: %.6: i32 = int_value 0 [template]
  511. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  512. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  513. // CHECK:STDOUT: %.7: type = ptr_type %.1 [template]
  514. // CHECK:STDOUT: %.8: i32 = int_value 3 [template]
  515. // CHECK:STDOUT: %.9: type = array_type %.8, %C [template]
  516. // CHECK:STDOUT: %.10: type = ptr_type %.9 [template]
  517. // CHECK:STDOUT: %tuple.type: type = tuple_type (%.1, %.1, %.1) [template]
  518. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  519. // CHECK:STDOUT: %.11: i32 = int_value 1 [template]
  520. // CHECK:STDOUT: %array: %.9 = tuple_value (%struct, %struct, %struct) [template]
  521. // CHECK:STDOUT: %.12: type = array_type %.3, %C [template]
  522. // CHECK:STDOUT: %.13: <specific function> = specific_function %F, @F(%C) [template]
  523. // CHECK:STDOUT: %.14: type = ptr_type %.12 [template]
  524. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  525. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  526. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  527. // CHECK:STDOUT: %ImplicitAs.type.2: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
  528. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  529. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  530. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  531. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  532. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  533. // CHECK:STDOUT: %.15: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  534. // CHECK:STDOUT: %.16: %.15 = assoc_entity element0, imports.%import_ref.5 [symbolic]
  535. // CHECK:STDOUT: %ImplicitAs.type.3: type = facet_type <@ImplicitAs, @ImplicitAs(%.12)> [template]
  536. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%.12) [template]
  537. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  538. // CHECK:STDOUT: %.17: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  539. // CHECK:STDOUT: %.18: %.17 = assoc_entity element0, imports.%import_ref.5 [template]
  540. // CHECK:STDOUT: %.19: %.15 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  541. // CHECK:STDOUT: }
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: imports {
  544. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  545. // CHECK:STDOUT: .ImplicitAs = %import_ref.1
  546. // CHECK:STDOUT: import Core//prelude
  547. // CHECK:STDOUT: import Core//prelude/...
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: %import_ref.1: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+48, loaded [template = constants.%ImplicitAs]
  550. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/as, inst+54, unloaded
  551. // CHECK:STDOUT: %import_ref.3: @ImplicitAs.%.1 (%.15) = import_ref Core//prelude/operators/as, inst+76, loaded [symbolic = @ImplicitAs.%.2 (constants.%.19)]
  552. // CHECK:STDOUT: %import_ref.4 = import_ref Core//prelude/operators/as, inst+69, unloaded
  553. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+69, unloaded
  554. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+69, unloaded
  555. // CHECK:STDOUT: }
  556. // CHECK:STDOUT:
  557. // CHECK:STDOUT: file {
  558. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  559. // CHECK:STDOUT: .Core = imports.%Core
  560. // CHECK:STDOUT: .C = %C.decl
  561. // CHECK:STDOUT: .F = %F.decl
  562. // CHECK:STDOUT: .G = %G.decl
  563. // CHECK:STDOUT: }
  564. // CHECK:STDOUT: %Core.import = import Core
  565. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  566. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  567. // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  568. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param<invalid> [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  569. // CHECK:STDOUT: %a.patt: @F.%.loc6_24.2 (%.4) = binding_pattern a
  570. // CHECK:STDOUT: %a.param_patt: @F.%.loc6_24.2 (%.4) = value_param_pattern %a.patt, runtime_param0
  571. // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern
  572. // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  573. // CHECK:STDOUT: } {
  574. // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  575. // CHECK:STDOUT: %.loc6_23: i32 = int_value 2 [template = constants.%.3]
  576. // CHECK:STDOUT: %.loc6_24.1: type = array_type %.loc6_23, %T [symbolic = %.loc6_24.2 (constants.%.4)]
  577. // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  578. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  579. // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
  580. // CHECK:STDOUT: %a.param: @F.%.loc6_24.2 (%.4) = value_param runtime_param0
  581. // CHECK:STDOUT: %a: @F.%.loc6_24.2 (%.4) = bind_name a, %a.param
  582. // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1
  583. // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param
  584. // CHECK:STDOUT: }
  585. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  586. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  587. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  588. // CHECK:STDOUT: } {
  589. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
  590. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  591. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  592. // CHECK:STDOUT: }
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT:
  595. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  596. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  597. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: !definition:
  600. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  601. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  602. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  603. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  604. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.15)]
  605. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.15) = assoc_entity element0, imports.%import_ref.5 [symbolic = %.2 (constants.%.16)]
  606. // CHECK:STDOUT:
  607. // CHECK:STDOUT: interface {
  608. // CHECK:STDOUT: !members:
  609. // CHECK:STDOUT: .Self = imports.%import_ref.2
  610. // CHECK:STDOUT: .Convert = imports.%import_ref.3
  611. // CHECK:STDOUT: witness = (imports.%import_ref.4)
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT: }
  614. // CHECK:STDOUT:
  615. // CHECK:STDOUT: class @C {
  616. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  617. // CHECK:STDOUT:
  618. // CHECK:STDOUT: !members:
  619. // CHECK:STDOUT: .Self = constants.%C
  620. // CHECK:STDOUT: }
  621. // CHECK:STDOUT:
  622. // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
  623. // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
  624. // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  625. // CHECK:STDOUT: %.loc6_24.2: type = array_type constants.%.3, @F.%T.loc6_6.2 (%T) [symbolic = %.loc6_24.2 (constants.%.4)]
  626. // CHECK:STDOUT:
  627. // CHECK:STDOUT: !definition:
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%.loc6_24.2 (%.4)) -> @F.%T.loc6_6.2 (%T) {
  630. // CHECK:STDOUT: !entry:
  631. // CHECK:STDOUT: %a.ref: @F.%.loc6_24.2 (%.4) = name_ref a, %a
  632. // CHECK:STDOUT: %.loc6_43: i32 = int_value 0 [template = constants.%.6]
  633. // CHECK:STDOUT: %.loc6_44.1: ref @F.%.loc6_24.2 (%.4) = value_as_ref %a.ref
  634. // CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43
  635. // CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2
  636. // CHECK:STDOUT: return %.loc6_44.3
  637. // CHECK:STDOUT: }
  638. // CHECK:STDOUT: }
  639. // CHECK:STDOUT:
  640. // CHECK:STDOUT: fn @G() -> %return: %C {
  641. // CHECK:STDOUT: !entry:
  642. // CHECK:STDOUT: %C.ref.loc10: type = name_ref C, file.%C.decl [template = constants.%C]
  643. // CHECK:STDOUT: %.loc10_14: i32 = int_value 3 [template = constants.%.8]
  644. // CHECK:STDOUT: %.loc10_15: type = array_type %.loc10_14, %C [template = constants.%.9]
  645. // CHECK:STDOUT: %a.var: ref %.9 = var a
  646. // CHECK:STDOUT: %a: ref %.9 = bind_name a, %a.var
  647. // CHECK:STDOUT: %.loc10_21.1: %.1 = struct_literal ()
  648. // CHECK:STDOUT: %.loc10_25.1: %.1 = struct_literal ()
  649. // CHECK:STDOUT: %.loc10_29.1: %.1 = struct_literal ()
  650. // CHECK:STDOUT: %.loc10_30.1: %tuple.type = tuple_literal (%.loc10_21.1, %.loc10_25.1, %.loc10_29.1)
  651. // CHECK:STDOUT: %.loc10_30.2: i32 = int_value 0 [template = constants.%.6]
  652. // CHECK:STDOUT: %.loc10_30.3: ref %C = array_index %a.var, %.loc10_30.2
  653. // CHECK:STDOUT: %.loc10_21.2: init %C = class_init (), %.loc10_30.3 [template = constants.%struct]
  654. // CHECK:STDOUT: %.loc10_30.4: init %C = converted %.loc10_21.1, %.loc10_21.2 [template = constants.%struct]
  655. // CHECK:STDOUT: %.loc10_30.5: i32 = int_value 1 [template = constants.%.11]
  656. // CHECK:STDOUT: %.loc10_30.6: ref %C = array_index %a.var, %.loc10_30.5
  657. // CHECK:STDOUT: %.loc10_25.2: init %C = class_init (), %.loc10_30.6 [template = constants.%struct]
  658. // CHECK:STDOUT: %.loc10_30.7: init %C = converted %.loc10_25.1, %.loc10_25.2 [template = constants.%struct]
  659. // CHECK:STDOUT: %.loc10_30.8: i32 = int_value 2 [template = constants.%.3]
  660. // CHECK:STDOUT: %.loc10_30.9: ref %C = array_index %a.var, %.loc10_30.8
  661. // CHECK:STDOUT: %.loc10_29.2: init %C = class_init (), %.loc10_30.9 [template = constants.%struct]
  662. // CHECK:STDOUT: %.loc10_30.10: init %C = converted %.loc10_29.1, %.loc10_29.2 [template = constants.%struct]
  663. // CHECK:STDOUT: %.loc10_30.11: init %.9 = array_init (%.loc10_30.4, %.loc10_30.7, %.loc10_30.10) to %a.var [template = constants.%array]
  664. // CHECK:STDOUT: %.loc10_31: init %.9 = converted %.loc10_30.1, %.loc10_30.11 [template = constants.%array]
  665. // CHECK:STDOUT: assign %a.var, %.loc10_31
  666. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  667. // CHECK:STDOUT: %a.ref: ref %.9 = name_ref a, %a
  668. // CHECK:STDOUT: %.loc21_10: <specific function> = specific_function %F.ref, @F(constants.%C) [template = constants.%.13]
  669. // CHECK:STDOUT: %.loc8_8.2: ref %C = splice_block %return {}
  670. // CHECK:STDOUT: %.loc21_12: %.12 = converted %a.ref, <error> [template = <error>]
  671. // CHECK:STDOUT: %F.call: init %C = call %.loc21_10(<error>) to %.loc8_8.2
  672. // CHECK:STDOUT: return %F.call to %return
  673. // CHECK:STDOUT: }
  674. // CHECK:STDOUT:
  675. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  676. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  677. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  678. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  681. // CHECK:STDOUT: }
  682. // CHECK:STDOUT:
  683. // CHECK:STDOUT: specific @F(constants.%T) {
  684. // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
  685. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T
  686. // CHECK:STDOUT: %.loc6_24.2 => constants.%.4
  687. // CHECK:STDOUT: }
  688. // CHECK:STDOUT:
  689. // CHECK:STDOUT: specific @F(constants.%C) {
  690. // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
  691. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C
  692. // CHECK:STDOUT: %.loc6_24.2 => constants.%.12
  693. // CHECK:STDOUT:
  694. // CHECK:STDOUT: !definition:
  695. // CHECK:STDOUT: }
  696. // CHECK:STDOUT:
  697. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  698. // CHECK:STDOUT: %Dest => constants.%Dest
  699. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  700. // CHECK:STDOUT: }
  701. // CHECK:STDOUT:
  702. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  703. // CHECK:STDOUT: %Dest => constants.%Dest
  704. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  705. // CHECK:STDOUT: }
  706. // CHECK:STDOUT:
  707. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  708. // CHECK:STDOUT: %Dest => constants.%Dest
  709. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  710. // CHECK:STDOUT: }
  711. // CHECK:STDOUT:
  712. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  713. // CHECK:STDOUT: %Dest => constants.%Dest
  714. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  715. // CHECK:STDOUT: %Self => constants.%Self.1
  716. // CHECK:STDOUT: }
  717. // CHECK:STDOUT:
  718. // CHECK:STDOUT: specific @ImplicitAs(constants.%.12) {
  719. // CHECK:STDOUT: %Dest => constants.%.12
  720. // CHECK:STDOUT: %Dest.patt => constants.%.12
  721. // CHECK:STDOUT:
  722. // CHECK:STDOUT: !definition:
  723. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  724. // CHECK:STDOUT: %Self => constants.%Self.2
  725. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  726. // CHECK:STDOUT: %Convert => constants.%Convert.2
  727. // CHECK:STDOUT: %.1 => constants.%.17
  728. // CHECK:STDOUT: %.2 => constants.%.18
  729. // CHECK:STDOUT: }
  730. // CHECK:STDOUT:
  731. // CHECK:STDOUT: --- fail_type_mismatch.carbon
  732. // CHECK:STDOUT:
  733. // CHECK:STDOUT: constants {
  734. // CHECK:STDOUT: %C: type = class_type @C [template]
  735. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  736. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  737. // CHECK:STDOUT: %D: type = class_type @D [template]
  738. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  739. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  740. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  741. // CHECK:STDOUT: %N: i32 = bind_symbolic_name N, 0 [symbolic]
  742. // CHECK:STDOUT: %N.patt: i32 = symbolic_binding_pattern N, 0 [symbolic]
  743. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  744. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  745. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  746. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  747. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  748. // CHECK:STDOUT: %.4: i32 = int_value 3 [template]
  749. // CHECK:STDOUT: %.5: type = array_type %.4, %D [template]
  750. // CHECK:STDOUT: %.6: type = ptr_type %.5 [template]
  751. // CHECK:STDOUT: %tuple.type: type = tuple_type (%.1, %.1, %.1) [template]
  752. // CHECK:STDOUT: %.7: i32 = int_value 0 [template]
  753. // CHECK:STDOUT: %struct: %D = struct_value () [template]
  754. // CHECK:STDOUT: %.8: i32 = int_value 1 [template]
  755. // CHECK:STDOUT: %.9: i32 = int_value 2 [template]
  756. // CHECK:STDOUT: %array: %.5 = tuple_value (%struct, %struct, %struct) [template]
  757. // CHECK:STDOUT: }
  758. // CHECK:STDOUT:
  759. // CHECK:STDOUT: imports {
  760. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  761. // CHECK:STDOUT: .Int32 = %import_ref
  762. // CHECK:STDOUT: import Core//prelude
  763. // CHECK:STDOUT: import Core//prelude/...
  764. // CHECK:STDOUT: }
  765. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  766. // CHECK:STDOUT: }
  767. // CHECK:STDOUT:
  768. // CHECK:STDOUT: file {
  769. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  770. // CHECK:STDOUT: .Core = imports.%Core
  771. // CHECK:STDOUT: .C = %C.decl
  772. // CHECK:STDOUT: .D = %D.decl
  773. // CHECK:STDOUT: .F = %F.decl
  774. // CHECK:STDOUT: .G = %G.decl
  775. // CHECK:STDOUT: }
  776. // CHECK:STDOUT: %Core.import = import Core
  777. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  778. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  779. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  780. // CHECK:STDOUT: %N.patt.loc10_6.1: i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt)]
  781. // CHECK:STDOUT: %N.param_patt: i32 = value_param_pattern %N.patt.loc10_6.1, runtime_param<invalid> [symbolic = %N.patt.loc10_6.2 (constants.%N.patt)]
  782. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  783. // CHECK:STDOUT: %a.param_patt: <error> = value_param_pattern %a.patt, runtime_param0
  784. // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern
  785. // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param1
  786. // CHECK:STDOUT: } {
  787. // CHECK:STDOUT: %int.make_type_32.loc10_10: init type = call constants.%Int32() [template = i32]
  788. // CHECK:STDOUT: %.loc10_10.1: type = value_of_initializer %int.make_type_32.loc10_10 [template = i32]
  789. // CHECK:STDOUT: %.loc10_10.2: type = converted %int.make_type_32.loc10_10, %.loc10_10.1 [template = i32]
  790. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  791. // CHECK:STDOUT: %N.ref.loc10_22: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
  792. // CHECK:STDOUT: %.loc10_23: type = array_type %N.ref.loc10_22, %C [template = <error>]
  793. // CHECK:STDOUT: %int.make_type_32.loc10_29: init type = call constants.%Int32() [template = i32]
  794. // CHECK:STDOUT: %.loc10_29.1: type = value_of_initializer %int.make_type_32.loc10_29 [template = i32]
  795. // CHECK:STDOUT: %.loc10_29.2: type = converted %int.make_type_32.loc10_29, %.loc10_29.1 [template = i32]
  796. // CHECK:STDOUT: %N.param: i32 = value_param runtime_param<invalid>
  797. // CHECK:STDOUT: %N.loc10_6.1: i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc10_6.2 (constants.%N)]
  798. // CHECK:STDOUT: %a.param: <error> = value_param runtime_param0
  799. // CHECK:STDOUT: %a: <error> = bind_name a, %a.param
  800. // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param1
  801. // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
  802. // CHECK:STDOUT: }
  803. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  804. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  805. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  806. // CHECK:STDOUT: } {
  807. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  808. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  809. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  810. // CHECK:STDOUT: }
  811. // CHECK:STDOUT: }
  812. // CHECK:STDOUT:
  813. // CHECK:STDOUT: class @C {
  814. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  815. // CHECK:STDOUT:
  816. // CHECK:STDOUT: !members:
  817. // CHECK:STDOUT: .Self = constants.%C
  818. // CHECK:STDOUT: }
  819. // CHECK:STDOUT:
  820. // CHECK:STDOUT: class @D {
  821. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  822. // CHECK:STDOUT:
  823. // CHECK:STDOUT: !members:
  824. // CHECK:STDOUT: .Self = constants.%D
  825. // CHECK:STDOUT: }
  826. // CHECK:STDOUT:
  827. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  828. // CHECK:STDOUT:
  829. // CHECK:STDOUT: generic fn @F(%N.loc10_6.1: i32) {
  830. // CHECK:STDOUT: %N.loc10_6.2: i32 = bind_symbolic_name N, 0 [symbolic = %N.loc10_6.2 (constants.%N)]
  831. // CHECK:STDOUT: %N.patt.loc10_6.2: i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc10_6.2 (constants.%N.patt)]
  832. // CHECK:STDOUT:
  833. // CHECK:STDOUT: !definition:
  834. // CHECK:STDOUT:
  835. // CHECK:STDOUT: fn[%N.param_patt: i32](%a.param_patt: <error>) -> i32 {
  836. // CHECK:STDOUT: !entry:
  837. // CHECK:STDOUT: %N.ref.loc10_42: i32 = name_ref N, %N.loc10_6.1 [symbolic = %N.loc10_6.2 (constants.%N)]
  838. // CHECK:STDOUT: return %N.ref.loc10_42
  839. // CHECK:STDOUT: }
  840. // CHECK:STDOUT: }
  841. // CHECK:STDOUT:
  842. // CHECK:STDOUT: fn @G() -> %return: %C {
  843. // CHECK:STDOUT: !entry:
  844. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  845. // CHECK:STDOUT: %.loc13_14: i32 = int_value 3 [template = constants.%.4]
  846. // CHECK:STDOUT: %.loc13_15: type = array_type %.loc13_14, %D [template = constants.%.5]
  847. // CHECK:STDOUT: %a.var: ref %.5 = var a
  848. // CHECK:STDOUT: %a: ref %.5 = bind_name a, %a.var
  849. // CHECK:STDOUT: %.loc13_21.1: %.1 = struct_literal ()
  850. // CHECK:STDOUT: %.loc13_25.1: %.1 = struct_literal ()
  851. // CHECK:STDOUT: %.loc13_29.1: %.1 = struct_literal ()
  852. // CHECK:STDOUT: %.loc13_30.1: %tuple.type = tuple_literal (%.loc13_21.1, %.loc13_25.1, %.loc13_29.1)
  853. // CHECK:STDOUT: %.loc13_30.2: i32 = int_value 0 [template = constants.%.7]
  854. // CHECK:STDOUT: %.loc13_30.3: ref %D = array_index %a.var, %.loc13_30.2
  855. // CHECK:STDOUT: %.loc13_21.2: init %D = class_init (), %.loc13_30.3 [template = constants.%struct]
  856. // CHECK:STDOUT: %.loc13_30.4: init %D = converted %.loc13_21.1, %.loc13_21.2 [template = constants.%struct]
  857. // CHECK:STDOUT: %.loc13_30.5: i32 = int_value 1 [template = constants.%.8]
  858. // CHECK:STDOUT: %.loc13_30.6: ref %D = array_index %a.var, %.loc13_30.5
  859. // CHECK:STDOUT: %.loc13_25.2: init %D = class_init (), %.loc13_30.6 [template = constants.%struct]
  860. // CHECK:STDOUT: %.loc13_30.7: init %D = converted %.loc13_25.1, %.loc13_25.2 [template = constants.%struct]
  861. // CHECK:STDOUT: %.loc13_30.8: i32 = int_value 2 [template = constants.%.9]
  862. // CHECK:STDOUT: %.loc13_30.9: ref %D = array_index %a.var, %.loc13_30.8
  863. // CHECK:STDOUT: %.loc13_29.2: init %D = class_init (), %.loc13_30.9 [template = constants.%struct]
  864. // CHECK:STDOUT: %.loc13_30.10: init %D = converted %.loc13_29.1, %.loc13_29.2 [template = constants.%struct]
  865. // CHECK:STDOUT: %.loc13_30.11: init %.5 = array_init (%.loc13_30.4, %.loc13_30.7, %.loc13_30.10) to %a.var [template = constants.%array]
  866. // CHECK:STDOUT: %.loc13_31: init %.5 = converted %.loc13_30.1, %.loc13_30.11 [template = constants.%array]
  867. // CHECK:STDOUT: assign %a.var, %.loc13_31
  868. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  869. // CHECK:STDOUT: %a.ref: ref %.5 = name_ref a, %a
  870. // CHECK:STDOUT: return <error> to %return
  871. // CHECK:STDOUT: }
  872. // CHECK:STDOUT:
  873. // CHECK:STDOUT: specific @F(constants.%N) {
  874. // CHECK:STDOUT: %N.loc10_6.2 => constants.%N
  875. // CHECK:STDOUT: %N.patt.loc10_6.2 => constants.%N
  876. // CHECK:STDOUT: }
  877. // CHECK:STDOUT: