deduce.carbon 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  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/function/generic/deduce.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/deduce.carbon
  10. // --- deduce_explicit.carbon
  11. library "[[@TEST_NAME]]";
  12. fn ExplicitGenericParam(T:! type) -> T* { return ExplicitGenericParam(T); }
  13. fn CallExplicitGenericParam() -> i32* {
  14. return ExplicitGenericParam(i32);
  15. }
  16. fn CallExplicitGenericParamWithGenericArg(T:! type) -> {.a: T}* {
  17. return ExplicitGenericParam({.a: T});
  18. }
  19. // --- fail_todo_explicit_vs_deduced.carbon
  20. library "[[@TEST_NAME]]";
  21. class A {}
  22. fn ExplicitAndAlsoDeduced(T:! type, x: T) -> T*;
  23. // TODO: This should presumably be accepted. We shouldn't deduce values for parameters with explicitly-specified values.
  24. fn CallExplicitAndAlsoDeduced(n: i32) -> i32* {
  25. // CHECK:STDERR: fail_todo_explicit_vs_deduced.carbon:[[@LINE+7]]:10: error: inconsistent deductions for value of generic parameter `T`
  26. // CHECK:STDERR: return ExplicitAndAlsoDeduced(A, {});
  27. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  28. // CHECK:STDERR: fail_todo_explicit_vs_deduced.carbon:[[@LINE-7]]:1: note: while deducing parameters of generic declared here
  29. // CHECK:STDERR: fn ExplicitAndAlsoDeduced(T:! type, x: T) -> T*;
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. // CHECK:STDERR:
  32. return ExplicitAndAlsoDeduced(A, {});
  33. }
  34. // --- deduce_implicit.carbon
  35. library "[[@TEST_NAME]]";
  36. fn ImplicitGenericParam[T:! type](x: T) -> T* { return ImplicitGenericParam(x); }
  37. fn CallImplicitGenericParam(n: i32) -> i32* {
  38. return ImplicitGenericParam(n);
  39. }
  40. // --- deduce_nested_tuple.carbon
  41. library "[[@TEST_NAME]]";
  42. fn TupleParam[T:! type](x: (T, i32)) {}
  43. fn CallTupleParam() {
  44. TupleParam((1, 2));
  45. }
  46. // --- fail_todo_deduce_nested_struct.carbon
  47. library "[[@TEST_NAME]]";
  48. fn StructParam[T:! type](x: {.a: T, .b: i32}) {}
  49. fn CallStructParam() {
  50. // CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE+7]]:3: error: cannot deduce value for generic parameter `T`
  51. // CHECK:STDERR: StructParam({.a = 1, .b = 2});
  52. // CHECK:STDERR: ^~~~~~~~~~~~
  53. // CHECK:STDERR: fail_todo_deduce_nested_struct.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here
  54. // CHECK:STDERR: fn StructParam[T:! type](x: {.a: T, .b: i32}) {}
  55. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. // CHECK:STDERR:
  57. StructParam({.a = 1, .b = 2});
  58. }
  59. // --- fail_deduce_incomplete.carbon
  60. library "[[@TEST_NAME]]";
  61. // TODO: It would be nice to diagnose this at its point of declaration, because
  62. // U is not deducible.
  63. fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U;
  64. fn CallImplicitNotDeducible() {
  65. // CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE+7]]:3: error: cannot deduce value for generic parameter `U`
  66. // CHECK:STDERR: ImplicitNotDeducible(42);
  67. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  68. // CHECK:STDERR: fail_deduce_incomplete.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here
  69. // CHECK:STDERR: fn ImplicitNotDeducible[T:! type, U:! type](x: T) -> U;
  70. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. // CHECK:STDERR:
  72. ImplicitNotDeducible(42);
  73. }
  74. // --- fail_deduce_inconsistent.carbon
  75. library "[[@TEST_NAME]]";
  76. fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T;
  77. fn CallImplicitNotDeducible() {
  78. // CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE+6]]:3: error: inconsistent deductions for value of generic parameter `T`
  79. // CHECK:STDERR: ImplicitNotDeducible(42, {.x = 12});
  80. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
  81. // CHECK:STDERR: fail_deduce_inconsistent.carbon:[[@LINE-6]]:1: note: while deducing parameters of generic declared here
  82. // CHECK:STDERR: fn ImplicitNotDeducible[T:! type](x: T, y: T) -> T;
  83. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. ImplicitNotDeducible(42, {.x = 12});
  85. }
  86. // CHECK:STDOUT: --- deduce_explicit.carbon
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: constants {
  89. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  90. // CHECK:STDOUT: %.1: type = ptr_type %T [symbolic]
  91. // CHECK:STDOUT: %ExplicitGenericParam.type: type = fn_type @ExplicitGenericParam [template]
  92. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  93. // CHECK:STDOUT: %ExplicitGenericParam: %ExplicitGenericParam.type = struct_value () [template]
  94. // CHECK:STDOUT: %.3: <specific function> = specific_function %ExplicitGenericParam, @ExplicitGenericParam(%T) [symbolic]
  95. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  96. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  97. // CHECK:STDOUT: %.4: type = ptr_type i32 [template]
  98. // CHECK:STDOUT: %CallExplicitGenericParam.type: type = fn_type @CallExplicitGenericParam [template]
  99. // CHECK:STDOUT: %CallExplicitGenericParam: %CallExplicitGenericParam.type = struct_value () [template]
  100. // CHECK:STDOUT: %.5: <specific function> = specific_function %ExplicitGenericParam, @ExplicitGenericParam(i32) [template]
  101. // CHECK:STDOUT: %.6: type = struct_type {.a: %T} [symbolic]
  102. // CHECK:STDOUT: %.7: type = ptr_type %.6 [symbolic]
  103. // CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg.type: type = fn_type @CallExplicitGenericParamWithGenericArg [template]
  104. // CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg: %CallExplicitGenericParamWithGenericArg.type = struct_value () [template]
  105. // CHECK:STDOUT: %.8: <specific function> = specific_function %ExplicitGenericParam, @ExplicitGenericParam(%.6) [symbolic]
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: imports {
  109. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  110. // CHECK:STDOUT: .Int32 = %import_ref
  111. // CHECK:STDOUT: import Core//prelude
  112. // CHECK:STDOUT: import Core//prelude/operators
  113. // CHECK:STDOUT: import Core//prelude/types
  114. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  115. // CHECK:STDOUT: import Core//prelude/operators/as
  116. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  117. // CHECK:STDOUT: import Core//prelude/operators/comparison
  118. // CHECK:STDOUT: import Core//prelude/types/bool
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: file {
  124. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  125. // CHECK:STDOUT: .Core = imports.%Core
  126. // CHECK:STDOUT: .ExplicitGenericParam = %ExplicitGenericParam.decl
  127. // CHECK:STDOUT: .CallExplicitGenericParam = %CallExplicitGenericParam.decl
  128. // CHECK:STDOUT: .CallExplicitGenericParamWithGenericArg = %CallExplicitGenericParamWithGenericArg.decl
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %Core.import = import Core
  131. // CHECK:STDOUT: %ExplicitGenericParam.decl: %ExplicitGenericParam.type = fn_decl @ExplicitGenericParam [template = constants.%ExplicitGenericParam] {
  132. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  133. // CHECK:STDOUT: } {
  134. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  135. // CHECK:STDOUT: %T.loc4_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_25.2 (constants.%T)]
  136. // CHECK:STDOUT: %T.ref.loc4_38: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  137. // CHECK:STDOUT: %.loc4_39.1: type = ptr_type %T [symbolic = %.loc4_39.2 (constants.%.1)]
  138. // CHECK:STDOUT: %return: ref @ExplicitGenericParam.%.loc4_39.2 (%.1) = var <return slot>
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT: %CallExplicitGenericParam.decl: %CallExplicitGenericParam.type = fn_decl @CallExplicitGenericParam [template = constants.%CallExplicitGenericParam] {} {
  141. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  142. // CHECK:STDOUT: %.loc6_37.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  143. // CHECK:STDOUT: %.loc6_37.2: type = converted %int.make_type_32.loc6, %.loc6_37.1 [template = i32]
  144. // CHECK:STDOUT: %.loc6_37.3: type = ptr_type i32 [template = constants.%.4]
  145. // CHECK:STDOUT: %return: ref %.4 = var <return slot>
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg.decl: %CallExplicitGenericParamWithGenericArg.type = fn_decl @CallExplicitGenericParamWithGenericArg [template = constants.%CallExplicitGenericParamWithGenericArg] {
  148. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  149. // CHECK:STDOUT: } {
  150. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  151. // CHECK:STDOUT: %T.loc10_43.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc10_43.2 (constants.%T)]
  152. // CHECK:STDOUT: %T.ref.loc10: type = name_ref T, %T.loc10_43.1 [symbolic = %T.loc10_43.2 (constants.%T)]
  153. // CHECK:STDOUT: %.loc10_62.1: type = struct_type {.a: %T} [symbolic = %.loc10_62.2 (constants.%.6)]
  154. // CHECK:STDOUT: %.loc10_63.1: type = ptr_type %.6 [symbolic = %.loc10_63.2 (constants.%.7)]
  155. // CHECK:STDOUT: %return: ref @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.7) = var <return slot>
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: generic fn @ExplicitGenericParam(%T.loc4_25.1: type) {
  160. // CHECK:STDOUT: %T.loc4_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_25.2 (constants.%T)]
  161. // CHECK:STDOUT: %.loc4_39.2: type = ptr_type @ExplicitGenericParam.%T.loc4_25.2 (%T) [symbolic = %.loc4_39.2 (constants.%.1)]
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: !definition:
  164. // CHECK:STDOUT: %.loc4_50.2: <specific function> = specific_function constants.%ExplicitGenericParam, @ExplicitGenericParam(%T.loc4_25.2) [symbolic = %.loc4_50.2 (constants.%.3)]
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: fn(%T.loc4_25.1: type) -> @ExplicitGenericParam.%.loc4_39.2 (%.1) {
  167. // CHECK:STDOUT: !entry:
  168. // CHECK:STDOUT: %ExplicitGenericParam.ref: %ExplicitGenericParam.type = name_ref ExplicitGenericParam, file.%ExplicitGenericParam.decl [template = constants.%ExplicitGenericParam]
  169. // CHECK:STDOUT: %T.ref.loc4_71: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  170. // CHECK:STDOUT: %.loc4_50.1: <specific function> = specific_function %ExplicitGenericParam.ref, @ExplicitGenericParam(constants.%T) [symbolic = %.loc4_50.2 (constants.%.3)]
  171. // CHECK:STDOUT: %ExplicitGenericParam.call: init @ExplicitGenericParam.%.loc4_39.2 (%.1) = call %.loc4_50.1()
  172. // CHECK:STDOUT: %.loc4_73.1: @ExplicitGenericParam.%.loc4_39.2 (%.1) = value_of_initializer %ExplicitGenericParam.call
  173. // CHECK:STDOUT: %.loc4_73.2: @ExplicitGenericParam.%.loc4_39.2 (%.1) = converted %ExplicitGenericParam.call, %.loc4_73.1
  174. // CHECK:STDOUT: return %.loc4_73.2
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT: }
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: fn @CallExplicitGenericParam() -> %.4 {
  181. // CHECK:STDOUT: !entry:
  182. // CHECK:STDOUT: %ExplicitGenericParam.ref: %ExplicitGenericParam.type = name_ref ExplicitGenericParam, file.%ExplicitGenericParam.decl [template = constants.%ExplicitGenericParam]
  183. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  184. // CHECK:STDOUT: %.loc7_30.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  185. // CHECK:STDOUT: %.loc7_30.2: type = converted %int.make_type_32.loc7, %.loc7_30.1 [template = i32]
  186. // CHECK:STDOUT: %.loc7_10: <specific function> = specific_function %ExplicitGenericParam.ref, @ExplicitGenericParam(i32) [template = constants.%.5]
  187. // CHECK:STDOUT: %ExplicitGenericParam.call: init %.4 = call %.loc7_10()
  188. // CHECK:STDOUT: %.loc7_35.1: %.4 = value_of_initializer %ExplicitGenericParam.call
  189. // CHECK:STDOUT: %.loc7_35.2: %.4 = converted %ExplicitGenericParam.call, %.loc7_35.1
  190. // CHECK:STDOUT: return %.loc7_35.2
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: generic fn @CallExplicitGenericParamWithGenericArg(%T.loc10_43.1: type) {
  194. // CHECK:STDOUT: %T.loc10_43.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc10_43.2 (constants.%T)]
  195. // CHECK:STDOUT: %.loc10_62.2: type = struct_type {.a: @CallExplicitGenericParamWithGenericArg.%T.loc10_43.2 (%T)} [symbolic = %.loc10_62.2 (constants.%.6)]
  196. // CHECK:STDOUT: %.loc10_63.2: type = ptr_type @CallExplicitGenericParamWithGenericArg.%.loc10_62.2 (%.6) [symbolic = %.loc10_63.2 (constants.%.7)]
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: !definition:
  199. // CHECK:STDOUT: %.loc11_10.2: <specific function> = specific_function constants.%ExplicitGenericParam, @ExplicitGenericParam(%.loc10_62.2) [symbolic = %.loc11_10.2 (constants.%.8)]
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: fn(%T.loc10_43.1: type) -> @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.7) {
  202. // CHECK:STDOUT: !entry:
  203. // CHECK:STDOUT: %ExplicitGenericParam.ref: %ExplicitGenericParam.type = name_ref ExplicitGenericParam, file.%ExplicitGenericParam.decl [template = constants.%ExplicitGenericParam]
  204. // CHECK:STDOUT: %T.ref.loc11: type = name_ref T, %T.loc10_43.1 [symbolic = %T.loc10_43.2 (constants.%T)]
  205. // CHECK:STDOUT: %.loc11_37: type = struct_type {.a: %T} [symbolic = %.loc10_62.2 (constants.%.6)]
  206. // CHECK:STDOUT: %.loc11_10.1: <specific function> = specific_function %ExplicitGenericParam.ref, @ExplicitGenericParam(constants.%.6) [symbolic = %.loc11_10.2 (constants.%.8)]
  207. // CHECK:STDOUT: %ExplicitGenericParam.call: init @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.7) = call %.loc11_10.1()
  208. // CHECK:STDOUT: %.loc11_39.1: @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.7) = value_of_initializer %ExplicitGenericParam.call
  209. // CHECK:STDOUT: %.loc11_39.2: @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.7) = converted %ExplicitGenericParam.call, %.loc11_39.1
  210. // CHECK:STDOUT: return %.loc11_39.2
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT: }
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: specific @ExplicitGenericParam(constants.%T) {
  215. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  216. // CHECK:STDOUT: %.loc4_39.2 => constants.%.1
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: !definition:
  219. // CHECK:STDOUT: %.loc4_50.2 => constants.%.3
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: specific @ExplicitGenericParam(@ExplicitGenericParam.%T.loc4_25.2) {
  223. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  224. // CHECK:STDOUT: %.loc4_39.2 => constants.%.1
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: specific @ExplicitGenericParam(i32) {
  228. // CHECK:STDOUT: %T.loc4_25.2 => i32
  229. // CHECK:STDOUT: %.loc4_39.2 => constants.%.4
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: !definition:
  232. // CHECK:STDOUT: %.loc4_50.2 => constants.%.5
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: specific @CallExplicitGenericParamWithGenericArg(constants.%T) {
  236. // CHECK:STDOUT: %T.loc10_43.2 => constants.%T
  237. // CHECK:STDOUT: %.loc10_62.2 => constants.%.6
  238. // CHECK:STDOUT: %.loc10_63.2 => constants.%.7
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: specific @ExplicitGenericParam(constants.%.6) {
  242. // CHECK:STDOUT: %T.loc4_25.2 => constants.%.6
  243. // CHECK:STDOUT: %.loc4_39.2 => constants.%.7
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: !definition:
  246. // CHECK:STDOUT: %.loc4_50.2 => constants.%.8
  247. // CHECK:STDOUT: }
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: specific @ExplicitGenericParam(@CallExplicitGenericParamWithGenericArg.%.loc10_62.2) {
  250. // CHECK:STDOUT: %T.loc4_25.2 => constants.%.6
  251. // CHECK:STDOUT: %.loc4_39.2 => constants.%.7
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: --- fail_todo_explicit_vs_deduced.carbon
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: constants {
  257. // CHECK:STDOUT: %A: type = class_type @A [template]
  258. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  259. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  260. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  261. // CHECK:STDOUT: %.3: type = ptr_type %T [symbolic]
  262. // CHECK:STDOUT: %ExplicitAndAlsoDeduced.type: type = fn_type @ExplicitAndAlsoDeduced [template]
  263. // CHECK:STDOUT: %.4: type = tuple_type () [template]
  264. // CHECK:STDOUT: %ExplicitAndAlsoDeduced: %ExplicitAndAlsoDeduced.type = struct_value () [template]
  265. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  266. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  267. // CHECK:STDOUT: %.5: type = ptr_type i32 [template]
  268. // CHECK:STDOUT: %CallExplicitAndAlsoDeduced.type: type = fn_type @CallExplicitAndAlsoDeduced [template]
  269. // CHECK:STDOUT: %CallExplicitAndAlsoDeduced: %CallExplicitAndAlsoDeduced.type = struct_value () [template]
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: imports {
  273. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  274. // CHECK:STDOUT: .Int32 = %import_ref
  275. // CHECK:STDOUT: import Core//prelude
  276. // CHECK:STDOUT: import Core//prelude/operators
  277. // CHECK:STDOUT: import Core//prelude/types
  278. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  279. // CHECK:STDOUT: import Core//prelude/operators/as
  280. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  281. // CHECK:STDOUT: import Core//prelude/operators/comparison
  282. // CHECK:STDOUT: import Core//prelude/types/bool
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: file {
  288. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  289. // CHECK:STDOUT: .Core = imports.%Core
  290. // CHECK:STDOUT: .A = %A.decl
  291. // CHECK:STDOUT: .ExplicitAndAlsoDeduced = %ExplicitAndAlsoDeduced.decl
  292. // CHECK:STDOUT: .CallExplicitAndAlsoDeduced = %CallExplicitAndAlsoDeduced.decl
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT: %Core.import = import Core
  295. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  296. // CHECK:STDOUT: %ExplicitAndAlsoDeduced.decl: %ExplicitAndAlsoDeduced.type = fn_decl @ExplicitAndAlsoDeduced [template = constants.%ExplicitAndAlsoDeduced] {
  297. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  298. // CHECK:STDOUT: %x.patt: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) = binding_pattern x
  299. // CHECK:STDOUT: } {
  300. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  301. // CHECK:STDOUT: %T.loc6_27.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_27.2 (constants.%T)]
  302. // CHECK:STDOUT: %T.ref.loc6_40: type = name_ref T, %T.loc6_27.1 [symbolic = %T.loc6_27.2 (constants.%T)]
  303. // CHECK:STDOUT: %x.param: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) = param x, runtime_param0
  304. // CHECK:STDOUT: %x: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) = bind_name x, %x.param
  305. // CHECK:STDOUT: %T.ref.loc6_46: type = name_ref T, %T.loc6_27.1 [symbolic = %T.loc6_27.2 (constants.%T)]
  306. // CHECK:STDOUT: %.loc6_47.1: type = ptr_type %T [symbolic = %.loc6_47.2 (constants.%.3)]
  307. // CHECK:STDOUT: %return: ref @ExplicitAndAlsoDeduced.%.loc6_47.2 (%.3) = var <return slot>
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT: %CallExplicitAndAlsoDeduced.decl: %CallExplicitAndAlsoDeduced.type = fn_decl @CallExplicitAndAlsoDeduced [template = constants.%CallExplicitAndAlsoDeduced] {
  310. // CHECK:STDOUT: %n.patt: i32 = binding_pattern n
  311. // CHECK:STDOUT: } {
  312. // CHECK:STDOUT: %int.make_type_32.loc9_34: init type = call constants.%Int32() [template = i32]
  313. // CHECK:STDOUT: %.loc9_34.1: type = value_of_initializer %int.make_type_32.loc9_34 [template = i32]
  314. // CHECK:STDOUT: %.loc9_34.2: type = converted %int.make_type_32.loc9_34, %.loc9_34.1 [template = i32]
  315. // CHECK:STDOUT: %n.param: i32 = param n, runtime_param0
  316. // CHECK:STDOUT: %n: i32 = bind_name n, %n.param
  317. // CHECK:STDOUT: %int.make_type_32.loc9_42: init type = call constants.%Int32() [template = i32]
  318. // CHECK:STDOUT: %.loc9_45.1: type = value_of_initializer %int.make_type_32.loc9_42 [template = i32]
  319. // CHECK:STDOUT: %.loc9_45.2: type = converted %int.make_type_32.loc9_42, %.loc9_45.1 [template = i32]
  320. // CHECK:STDOUT: %.loc9_45.3: type = ptr_type i32 [template = constants.%.5]
  321. // CHECK:STDOUT: %return: ref %.5 = var <return slot>
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: class @A {
  326. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: !members:
  329. // CHECK:STDOUT: .Self = constants.%A
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: generic fn @ExplicitAndAlsoDeduced(%T.loc6_27.1: type) {
  333. // CHECK:STDOUT: %T.loc6_27.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_27.2 (constants.%T)]
  334. // CHECK:STDOUT: %.loc6_47.2: type = ptr_type @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) [symbolic = %.loc6_47.2 (constants.%.3)]
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: fn(%T.loc6_27.1: type, %x: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T)) -> @ExplicitAndAlsoDeduced.%.loc6_47.2 (%.3);
  337. // CHECK:STDOUT: }
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: fn @CallExplicitAndAlsoDeduced(%n: i32) -> %.5 {
  342. // CHECK:STDOUT: !entry:
  343. // CHECK:STDOUT: %ExplicitAndAlsoDeduced.ref: %ExplicitAndAlsoDeduced.type = name_ref ExplicitAndAlsoDeduced, file.%ExplicitAndAlsoDeduced.decl [template = constants.%ExplicitAndAlsoDeduced]
  344. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  345. // CHECK:STDOUT: %.loc17: %.1 = struct_literal ()
  346. // CHECK:STDOUT: return <error>
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: specific @ExplicitAndAlsoDeduced(constants.%T) {
  350. // CHECK:STDOUT: %T.loc6_27.2 => constants.%T
  351. // CHECK:STDOUT: %.loc6_47.2 => constants.%.3
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: --- deduce_implicit.carbon
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: constants {
  357. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  358. // CHECK:STDOUT: %.1: type = ptr_type %T [symbolic]
  359. // CHECK:STDOUT: %ImplicitGenericParam.type: type = fn_type @ImplicitGenericParam [template]
  360. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  361. // CHECK:STDOUT: %ImplicitGenericParam: %ImplicitGenericParam.type = struct_value () [template]
  362. // CHECK:STDOUT: %.3: <specific function> = specific_function %ImplicitGenericParam, @ImplicitGenericParam(%T) [symbolic]
  363. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  364. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  365. // CHECK:STDOUT: %.4: type = ptr_type i32 [template]
  366. // CHECK:STDOUT: %CallImplicitGenericParam.type: type = fn_type @CallImplicitGenericParam [template]
  367. // CHECK:STDOUT: %CallImplicitGenericParam: %CallImplicitGenericParam.type = struct_value () [template]
  368. // CHECK:STDOUT: %.5: <specific function> = specific_function %ImplicitGenericParam, @ImplicitGenericParam(i32) [template]
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: imports {
  372. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  373. // CHECK:STDOUT: .Int32 = %import_ref
  374. // CHECK:STDOUT: import Core//prelude
  375. // CHECK:STDOUT: import Core//prelude/operators
  376. // CHECK:STDOUT: import Core//prelude/types
  377. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  378. // CHECK:STDOUT: import Core//prelude/operators/as
  379. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  380. // CHECK:STDOUT: import Core//prelude/operators/comparison
  381. // CHECK:STDOUT: import Core//prelude/types/bool
  382. // CHECK:STDOUT: }
  383. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: file {
  387. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  388. // CHECK:STDOUT: .Core = imports.%Core
  389. // CHECK:STDOUT: .ImplicitGenericParam = %ImplicitGenericParam.decl
  390. // CHECK:STDOUT: .CallImplicitGenericParam = %CallImplicitGenericParam.decl
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT: %Core.import = import Core
  393. // CHECK:STDOUT: %ImplicitGenericParam.decl: %ImplicitGenericParam.type = fn_decl @ImplicitGenericParam [template = constants.%ImplicitGenericParam] {
  394. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  395. // CHECK:STDOUT: %x.patt: @ImplicitGenericParam.%T.loc4_25.2 (%T) = binding_pattern x
  396. // CHECK:STDOUT: } {
  397. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  398. // CHECK:STDOUT: %T.loc4_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_25.2 (constants.%T)]
  399. // CHECK:STDOUT: %T.ref.loc4_38: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  400. // CHECK:STDOUT: %x.param: @ImplicitGenericParam.%T.loc4_25.2 (%T) = param x, runtime_param0
  401. // CHECK:STDOUT: %x: @ImplicitGenericParam.%T.loc4_25.2 (%T) = bind_name x, %x.param
  402. // CHECK:STDOUT: %T.ref.loc4_44: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  403. // CHECK:STDOUT: %.loc4_45.1: type = ptr_type %T [symbolic = %.loc4_45.2 (constants.%.1)]
  404. // CHECK:STDOUT: %return: ref @ImplicitGenericParam.%.loc4_45.2 (%.1) = var <return slot>
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT: %CallImplicitGenericParam.decl: %CallImplicitGenericParam.type = fn_decl @CallImplicitGenericParam [template = constants.%CallImplicitGenericParam] {
  407. // CHECK:STDOUT: %n.patt: i32 = binding_pattern n
  408. // CHECK:STDOUT: } {
  409. // CHECK:STDOUT: %int.make_type_32.loc6_32: init type = call constants.%Int32() [template = i32]
  410. // CHECK:STDOUT: %.loc6_32.1: type = value_of_initializer %int.make_type_32.loc6_32 [template = i32]
  411. // CHECK:STDOUT: %.loc6_32.2: type = converted %int.make_type_32.loc6_32, %.loc6_32.1 [template = i32]
  412. // CHECK:STDOUT: %n.param: i32 = param n, runtime_param0
  413. // CHECK:STDOUT: %n: i32 = bind_name n, %n.param
  414. // CHECK:STDOUT: %int.make_type_32.loc6_40: init type = call constants.%Int32() [template = i32]
  415. // CHECK:STDOUT: %.loc6_43.1: type = value_of_initializer %int.make_type_32.loc6_40 [template = i32]
  416. // CHECK:STDOUT: %.loc6_43.2: type = converted %int.make_type_32.loc6_40, %.loc6_43.1 [template = i32]
  417. // CHECK:STDOUT: %.loc6_43.3: type = ptr_type i32 [template = constants.%.4]
  418. // CHECK:STDOUT: %return: ref %.4 = var <return slot>
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: generic fn @ImplicitGenericParam(%T.loc4_25.1: type) {
  423. // CHECK:STDOUT: %T.loc4_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_25.2 (constants.%T)]
  424. // CHECK:STDOUT: %.loc4_45.2: type = ptr_type @ImplicitGenericParam.%T.loc4_25.2 (%T) [symbolic = %.loc4_45.2 (constants.%.1)]
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: !definition:
  427. // CHECK:STDOUT: %.loc4_56.2: <specific function> = specific_function constants.%ImplicitGenericParam, @ImplicitGenericParam(%T.loc4_25.2) [symbolic = %.loc4_56.2 (constants.%.3)]
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: fn[%T.loc4_25.1: type](%x: @ImplicitGenericParam.%T.loc4_25.2 (%T)) -> @ImplicitGenericParam.%.loc4_45.2 (%.1) {
  430. // CHECK:STDOUT: !entry:
  431. // CHECK:STDOUT: %ImplicitGenericParam.ref: %ImplicitGenericParam.type = name_ref ImplicitGenericParam, file.%ImplicitGenericParam.decl [template = constants.%ImplicitGenericParam]
  432. // CHECK:STDOUT: %x.ref: @ImplicitGenericParam.%T.loc4_25.2 (%T) = name_ref x, %x
  433. // CHECK:STDOUT: %.loc4_56.1: <specific function> = specific_function %ImplicitGenericParam.ref, @ImplicitGenericParam(constants.%T) [symbolic = %.loc4_56.2 (constants.%.3)]
  434. // CHECK:STDOUT: %ImplicitGenericParam.call: init @ImplicitGenericParam.%.loc4_45.2 (%.1) = call %.loc4_56.1(%x.ref)
  435. // CHECK:STDOUT: %.loc4_79.1: @ImplicitGenericParam.%.loc4_45.2 (%.1) = value_of_initializer %ImplicitGenericParam.call
  436. // CHECK:STDOUT: %.loc4_79.2: @ImplicitGenericParam.%.loc4_45.2 (%.1) = converted %ImplicitGenericParam.call, %.loc4_79.1
  437. // CHECK:STDOUT: return %.loc4_79.2
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: fn @CallImplicitGenericParam(%n: i32) -> %.4 {
  444. // CHECK:STDOUT: !entry:
  445. // CHECK:STDOUT: %ImplicitGenericParam.ref: %ImplicitGenericParam.type = name_ref ImplicitGenericParam, file.%ImplicitGenericParam.decl [template = constants.%ImplicitGenericParam]
  446. // CHECK:STDOUT: %n.ref: i32 = name_ref n, %n
  447. // CHECK:STDOUT: %.loc7_10: <specific function> = specific_function %ImplicitGenericParam.ref, @ImplicitGenericParam(i32) [template = constants.%.5]
  448. // CHECK:STDOUT: %ImplicitGenericParam.call: init %.4 = call %.loc7_10(%n.ref)
  449. // CHECK:STDOUT: %.loc7_33.1: %.4 = value_of_initializer %ImplicitGenericParam.call
  450. // CHECK:STDOUT: %.loc7_33.2: %.4 = converted %ImplicitGenericParam.call, %.loc7_33.1
  451. // CHECK:STDOUT: return %.loc7_33.2
  452. // CHECK:STDOUT: }
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: specific @ImplicitGenericParam(constants.%T) {
  455. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  456. // CHECK:STDOUT: %.loc4_45.2 => constants.%.1
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: !definition:
  459. // CHECK:STDOUT: %.loc4_56.2 => constants.%.3
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: specific @ImplicitGenericParam(@ImplicitGenericParam.%T.loc4_25.2) {
  463. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  464. // CHECK:STDOUT: %.loc4_45.2 => constants.%.1
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: specific @ImplicitGenericParam(i32) {
  468. // CHECK:STDOUT: %T.loc4_25.2 => i32
  469. // CHECK:STDOUT: %.loc4_45.2 => constants.%.4
  470. // CHECK:STDOUT:
  471. // CHECK:STDOUT: !definition:
  472. // CHECK:STDOUT: %.loc4_56.2 => constants.%.5
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT:
  475. // CHECK:STDOUT: --- deduce_nested_tuple.carbon
  476. // CHECK:STDOUT:
  477. // CHECK:STDOUT: constants {
  478. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  479. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  480. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  481. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  482. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  483. // CHECK:STDOUT: %.3: type = tuple_type (%T, i32) [symbolic]
  484. // CHECK:STDOUT: %TupleParam.type: type = fn_type @TupleParam [template]
  485. // CHECK:STDOUT: %TupleParam: %TupleParam.type = struct_value () [template]
  486. // CHECK:STDOUT: %.4: type = ptr_type %.3 [symbolic]
  487. // CHECK:STDOUT: %CallTupleParam.type: type = fn_type @CallTupleParam [template]
  488. // CHECK:STDOUT: %CallTupleParam: %CallTupleParam.type = struct_value () [template]
  489. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  490. // CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
  491. // CHECK:STDOUT: %.7: type = tuple_type (i32, i32) [template]
  492. // CHECK:STDOUT: %.8: <specific function> = specific_function %TupleParam, @TupleParam(i32) [template]
  493. // CHECK:STDOUT: %.9: type = ptr_type %.7 [template]
  494. // CHECK:STDOUT: %tuple: %.7 = tuple_value (%.5, %.6) [template]
  495. // CHECK:STDOUT: }
  496. // CHECK:STDOUT:
  497. // CHECK:STDOUT: imports {
  498. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  499. // CHECK:STDOUT: .Int32 = %import_ref
  500. // CHECK:STDOUT: import Core//prelude
  501. // CHECK:STDOUT: import Core//prelude/operators
  502. // CHECK:STDOUT: import Core//prelude/types
  503. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  504. // CHECK:STDOUT: import Core//prelude/operators/as
  505. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  506. // CHECK:STDOUT: import Core//prelude/operators/comparison
  507. // CHECK:STDOUT: import Core//prelude/types/bool
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  510. // CHECK:STDOUT: }
  511. // CHECK:STDOUT:
  512. // CHECK:STDOUT: file {
  513. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  514. // CHECK:STDOUT: .Core = imports.%Core
  515. // CHECK:STDOUT: .TupleParam = %TupleParam.decl
  516. // CHECK:STDOUT: .CallTupleParam = %CallTupleParam.decl
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT: %Core.import = import Core
  519. // CHECK:STDOUT: %TupleParam.decl: %TupleParam.type = fn_decl @TupleParam [template = constants.%TupleParam] {
  520. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  521. // CHECK:STDOUT: %x.patt: @TupleParam.%.loc4_35.5 (%.3) = binding_pattern x
  522. // CHECK:STDOUT: } {
  523. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  524. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_15.2 (constants.%T)]
  525. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)]
  526. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  527. // CHECK:STDOUT: %.loc4_35.1: %.2 = tuple_literal (%T.ref, %int.make_type_32)
  528. // CHECK:STDOUT: %.loc4_35.2: type = value_of_initializer %int.make_type_32 [template = i32]
  529. // CHECK:STDOUT: %.loc4_35.3: type = converted %int.make_type_32, %.loc4_35.2 [template = i32]
  530. // CHECK:STDOUT: %.loc4_35.4: type = converted %.loc4_35.1, constants.%.3 [symbolic = %.loc4_35.5 (constants.%.3)]
  531. // CHECK:STDOUT: %x.param: @TupleParam.%.loc4_35.5 (%.3) = param x, runtime_param0
  532. // CHECK:STDOUT: %x: @TupleParam.%.loc4_35.5 (%.3) = bind_name x, %x.param
  533. // CHECK:STDOUT: }
  534. // CHECK:STDOUT: %CallTupleParam.decl: %CallTupleParam.type = fn_decl @CallTupleParam [template = constants.%CallTupleParam] {} {}
  535. // CHECK:STDOUT: }
  536. // CHECK:STDOUT:
  537. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  538. // CHECK:STDOUT:
  539. // CHECK:STDOUT: generic fn @TupleParam(%T.loc4_15.1: type) {
  540. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_15.2 (constants.%T)]
  541. // CHECK:STDOUT: %.loc4_35.5: type = tuple_type (@TupleParam.%T.loc4_15.2 (%T), i32) [symbolic = %.loc4_35.5 (constants.%.3)]
  542. // CHECK:STDOUT:
  543. // CHECK:STDOUT: !definition:
  544. // CHECK:STDOUT:
  545. // CHECK:STDOUT: fn[%T.loc4_15.1: type](%x: @TupleParam.%.loc4_35.5 (%.3)) {
  546. // CHECK:STDOUT: !entry:
  547. // CHECK:STDOUT: return
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: fn @CallTupleParam() {
  552. // CHECK:STDOUT: !entry:
  553. // CHECK:STDOUT: %TupleParam.ref: %TupleParam.type = name_ref TupleParam, file.%TupleParam.decl [template = constants.%TupleParam]
  554. // CHECK:STDOUT: %.loc7_15: i32 = int_literal 1 [template = constants.%.5]
  555. // CHECK:STDOUT: %.loc7_18: i32 = int_literal 2 [template = constants.%.6]
  556. // CHECK:STDOUT: %.loc7_19: %.7 = tuple_literal (%.loc7_15, %.loc7_18)
  557. // CHECK:STDOUT: %.loc7_3: <specific function> = specific_function %TupleParam.ref, @TupleParam(i32) [template = constants.%.8]
  558. // CHECK:STDOUT: %tuple: %.7 = tuple_value (%.loc7_15, %.loc7_18) [template = constants.%tuple]
  559. // CHECK:STDOUT: %.loc7_13: %.7 = converted %.loc7_19, %tuple [template = constants.%tuple]
  560. // CHECK:STDOUT: %TupleParam.call: init %.1 = call %.loc7_3(%.loc7_13)
  561. // CHECK:STDOUT: return
  562. // CHECK:STDOUT: }
  563. // CHECK:STDOUT:
  564. // CHECK:STDOUT: specific @TupleParam(constants.%T) {
  565. // CHECK:STDOUT: %T.loc4_15.2 => constants.%T
  566. // CHECK:STDOUT: %.loc4_35.5 => constants.%.3
  567. // CHECK:STDOUT: }
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: specific @TupleParam(i32) {
  570. // CHECK:STDOUT: %T.loc4_15.2 => i32
  571. // CHECK:STDOUT: %.loc4_35.5 => constants.%.7
  572. // CHECK:STDOUT:
  573. // CHECK:STDOUT: !definition:
  574. // CHECK:STDOUT: }
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: --- fail_todo_deduce_nested_struct.carbon
  577. // CHECK:STDOUT:
  578. // CHECK:STDOUT: constants {
  579. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  580. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  581. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  582. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  583. // CHECK:STDOUT: %.2: type = struct_type {.a: %T, .b: i32} [symbolic]
  584. // CHECK:STDOUT: %StructParam.type: type = fn_type @StructParam [template]
  585. // CHECK:STDOUT: %StructParam: %StructParam.type = struct_value () [template]
  586. // CHECK:STDOUT: %.3: type = ptr_type %.2 [symbolic]
  587. // CHECK:STDOUT: %CallStructParam.type: type = fn_type @CallStructParam [template]
  588. // CHECK:STDOUT: %CallStructParam: %CallStructParam.type = struct_value () [template]
  589. // CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
  590. // CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
  591. // CHECK:STDOUT: %.6: type = struct_type {.a: i32, .b: i32} [template]
  592. // CHECK:STDOUT: }
  593. // CHECK:STDOUT:
  594. // CHECK:STDOUT: imports {
  595. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  596. // CHECK:STDOUT: .Int32 = %import_ref
  597. // CHECK:STDOUT: import Core//prelude
  598. // CHECK:STDOUT: import Core//prelude/operators
  599. // CHECK:STDOUT: import Core//prelude/types
  600. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  601. // CHECK:STDOUT: import Core//prelude/operators/as
  602. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  603. // CHECK:STDOUT: import Core//prelude/operators/comparison
  604. // CHECK:STDOUT: import Core//prelude/types/bool
  605. // CHECK:STDOUT: }
  606. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  607. // CHECK:STDOUT: }
  608. // CHECK:STDOUT:
  609. // CHECK:STDOUT: file {
  610. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  611. // CHECK:STDOUT: .Core = imports.%Core
  612. // CHECK:STDOUT: .StructParam = %StructParam.decl
  613. // CHECK:STDOUT: .CallStructParam = %CallStructParam.decl
  614. // CHECK:STDOUT: }
  615. // CHECK:STDOUT: %Core.import = import Core
  616. // CHECK:STDOUT: %StructParam.decl: %StructParam.type = fn_decl @StructParam [template = constants.%StructParam] {
  617. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  618. // CHECK:STDOUT: %x.patt: @StructParam.%.loc4_44.2 (%.2) = binding_pattern x
  619. // CHECK:STDOUT: } {
  620. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  621. // CHECK:STDOUT: %T.loc4_16.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_16.2 (constants.%T)]
  622. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_16.1 [symbolic = %T.loc4_16.2 (constants.%T)]
  623. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  624. // CHECK:STDOUT: %.loc4_41.1: type = value_of_initializer %int.make_type_32 [template = i32]
  625. // CHECK:STDOUT: %.loc4_41.2: type = converted %int.make_type_32, %.loc4_41.1 [template = i32]
  626. // CHECK:STDOUT: %.loc4_44.1: type = struct_type {.a: %T, .b: i32} [symbolic = %.loc4_44.2 (constants.%.2)]
  627. // CHECK:STDOUT: %x.param: @StructParam.%.loc4_44.2 (%.2) = param x, runtime_param0
  628. // CHECK:STDOUT: %x: @StructParam.%.loc4_44.2 (%.2) = bind_name x, %x.param
  629. // CHECK:STDOUT: }
  630. // CHECK:STDOUT: %CallStructParam.decl: %CallStructParam.type = fn_decl @CallStructParam [template = constants.%CallStructParam] {} {}
  631. // CHECK:STDOUT: }
  632. // CHECK:STDOUT:
  633. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  634. // CHECK:STDOUT:
  635. // CHECK:STDOUT: generic fn @StructParam(%T.loc4_16.1: type) {
  636. // CHECK:STDOUT: %T.loc4_16.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_16.2 (constants.%T)]
  637. // CHECK:STDOUT: %.loc4_44.2: type = struct_type {.a: @StructParam.%T.loc4_16.2 (%T), .b: i32} [symbolic = %.loc4_44.2 (constants.%.2)]
  638. // CHECK:STDOUT:
  639. // CHECK:STDOUT: !definition:
  640. // CHECK:STDOUT:
  641. // CHECK:STDOUT: fn[%T.loc4_16.1: type](%x: @StructParam.%.loc4_44.2 (%.2)) {
  642. // CHECK:STDOUT: !entry:
  643. // CHECK:STDOUT: return
  644. // CHECK:STDOUT: }
  645. // CHECK:STDOUT: }
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: fn @CallStructParam() {
  648. // CHECK:STDOUT: !entry:
  649. // CHECK:STDOUT: %StructParam.ref: %StructParam.type = name_ref StructParam, file.%StructParam.decl [template = constants.%StructParam]
  650. // CHECK:STDOUT: %.loc14_21: i32 = int_literal 1 [template = constants.%.4]
  651. // CHECK:STDOUT: %.loc14_29: i32 = int_literal 2 [template = constants.%.5]
  652. // CHECK:STDOUT: %.loc14_30: %.6 = struct_literal (%.loc14_21, %.loc14_29)
  653. // CHECK:STDOUT: return
  654. // CHECK:STDOUT: }
  655. // CHECK:STDOUT:
  656. // CHECK:STDOUT: specific @StructParam(constants.%T) {
  657. // CHECK:STDOUT: %T.loc4_16.2 => constants.%T
  658. // CHECK:STDOUT: %.loc4_44.2 => constants.%.2
  659. // CHECK:STDOUT: }
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: --- fail_deduce_incomplete.carbon
  662. // CHECK:STDOUT:
  663. // CHECK:STDOUT: constants {
  664. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  665. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 1 [symbolic]
  666. // CHECK:STDOUT: %ImplicitNotDeducible.type: type = fn_type @ImplicitNotDeducible [template]
  667. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  668. // CHECK:STDOUT: %ImplicitNotDeducible: %ImplicitNotDeducible.type = struct_value () [template]
  669. // CHECK:STDOUT: %CallImplicitNotDeducible.type: type = fn_type @CallImplicitNotDeducible [template]
  670. // CHECK:STDOUT: %CallImplicitNotDeducible: %CallImplicitNotDeducible.type = struct_value () [template]
  671. // CHECK:STDOUT: %.2: i32 = int_literal 42 [template]
  672. // CHECK:STDOUT: }
  673. // CHECK:STDOUT:
  674. // CHECK:STDOUT: imports {
  675. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  676. // CHECK:STDOUT: import Core//prelude
  677. // CHECK:STDOUT: import Core//prelude/operators
  678. // CHECK:STDOUT: import Core//prelude/types
  679. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  680. // CHECK:STDOUT: import Core//prelude/operators/as
  681. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  682. // CHECK:STDOUT: import Core//prelude/operators/comparison
  683. // CHECK:STDOUT: import Core//prelude/types/bool
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT: }
  686. // CHECK:STDOUT:
  687. // CHECK:STDOUT: file {
  688. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  689. // CHECK:STDOUT: .Core = imports.%Core
  690. // CHECK:STDOUT: .ImplicitNotDeducible = %ImplicitNotDeducible.decl
  691. // CHECK:STDOUT: .CallImplicitNotDeducible = %CallImplicitNotDeducible.decl
  692. // CHECK:STDOUT: }
  693. // CHECK:STDOUT: %Core.import = import Core
  694. // CHECK:STDOUT: %ImplicitNotDeducible.decl: %ImplicitNotDeducible.type = fn_decl @ImplicitNotDeducible [template = constants.%ImplicitNotDeducible] {
  695. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  696. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 1
  697. // CHECK:STDOUT: %x.patt: @ImplicitNotDeducible.%T.loc6_25.2 (%T) = binding_pattern x
  698. // CHECK:STDOUT: } {
  699. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  700. // CHECK:STDOUT: %T.loc6_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_25.2 (constants.%T)]
  701. // CHECK:STDOUT: %U.param: type = param U, runtime_param<invalid>
  702. // CHECK:STDOUT: %U.loc6_35.1: type = bind_symbolic_name U, 1, %U.param [symbolic = %U.loc6_35.2 (constants.%U)]
  703. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6_25.1 [symbolic = %T.loc6_25.2 (constants.%T)]
  704. // CHECK:STDOUT: %x.param: @ImplicitNotDeducible.%T.loc6_25.2 (%T) = param x, runtime_param0
  705. // CHECK:STDOUT: %x: @ImplicitNotDeducible.%T.loc6_25.2 (%T) = bind_name x, %x.param
  706. // CHECK:STDOUT: %U.ref: type = name_ref U, %U.loc6_35.1 [symbolic = %U.loc6_35.2 (constants.%U)]
  707. // CHECK:STDOUT: %return: ref @ImplicitNotDeducible.%U.loc6_35.2 (%U) = var <return slot>
  708. // CHECK:STDOUT: }
  709. // CHECK:STDOUT: %CallImplicitNotDeducible.decl: %CallImplicitNotDeducible.type = fn_decl @CallImplicitNotDeducible [template = constants.%CallImplicitNotDeducible] {} {}
  710. // CHECK:STDOUT: }
  711. // CHECK:STDOUT:
  712. // CHECK:STDOUT: generic fn @ImplicitNotDeducible(%T.loc6_25.1: type, %U.loc6_35.1: type) {
  713. // CHECK:STDOUT: %T.loc6_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_25.2 (constants.%T)]
  714. // CHECK:STDOUT: %U.loc6_35.2: type = bind_symbolic_name U, 1 [symbolic = %U.loc6_35.2 (constants.%U)]
  715. // CHECK:STDOUT:
  716. // CHECK:STDOUT: fn[%T.loc6_25.1: type, %U.loc6_35.1: type](%x: @ImplicitNotDeducible.%T.loc6_25.2 (%T)) -> @ImplicitNotDeducible.%U.loc6_35.2 (%U);
  717. // CHECK:STDOUT: }
  718. // CHECK:STDOUT:
  719. // CHECK:STDOUT: fn @CallImplicitNotDeducible() {
  720. // CHECK:STDOUT: !entry:
  721. // CHECK:STDOUT: %ImplicitNotDeducible.ref: %ImplicitNotDeducible.type = name_ref ImplicitNotDeducible, file.%ImplicitNotDeducible.decl [template = constants.%ImplicitNotDeducible]
  722. // CHECK:STDOUT: %.loc16: i32 = int_literal 42 [template = constants.%.2]
  723. // CHECK:STDOUT: return
  724. // CHECK:STDOUT: }
  725. // CHECK:STDOUT:
  726. // CHECK:STDOUT: specific @ImplicitNotDeducible(constants.%T, constants.%U) {
  727. // CHECK:STDOUT: %T.loc6_25.2 => constants.%T
  728. // CHECK:STDOUT: %U.loc6_35.2 => constants.%U
  729. // CHECK:STDOUT: }
  730. // CHECK:STDOUT:
  731. // CHECK:STDOUT: --- fail_deduce_inconsistent.carbon
  732. // CHECK:STDOUT:
  733. // CHECK:STDOUT: constants {
  734. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  735. // CHECK:STDOUT: %ImplicitNotDeducible.type: type = fn_type @ImplicitNotDeducible [template]
  736. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  737. // CHECK:STDOUT: %ImplicitNotDeducible: %ImplicitNotDeducible.type = struct_value () [template]
  738. // CHECK:STDOUT: %CallImplicitNotDeducible.type: type = fn_type @CallImplicitNotDeducible [template]
  739. // CHECK:STDOUT: %CallImplicitNotDeducible: %CallImplicitNotDeducible.type = struct_value () [template]
  740. // CHECK:STDOUT: %.2: i32 = int_literal 42 [template]
  741. // CHECK:STDOUT: %.3: i32 = int_literal 12 [template]
  742. // CHECK:STDOUT: %.4: type = struct_type {.x: i32} [template]
  743. // CHECK:STDOUT: }
  744. // CHECK:STDOUT:
  745. // CHECK:STDOUT: imports {
  746. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  747. // CHECK:STDOUT: import Core//prelude
  748. // CHECK:STDOUT: import Core//prelude/operators
  749. // CHECK:STDOUT: import Core//prelude/types
  750. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  751. // CHECK:STDOUT: import Core//prelude/operators/as
  752. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  753. // CHECK:STDOUT: import Core//prelude/operators/comparison
  754. // CHECK:STDOUT: import Core//prelude/types/bool
  755. // CHECK:STDOUT: }
  756. // CHECK:STDOUT: }
  757. // CHECK:STDOUT:
  758. // CHECK:STDOUT: file {
  759. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  760. // CHECK:STDOUT: .Core = imports.%Core
  761. // CHECK:STDOUT: .ImplicitNotDeducible = %ImplicitNotDeducible.decl
  762. // CHECK:STDOUT: .CallImplicitNotDeducible = %CallImplicitNotDeducible.decl
  763. // CHECK:STDOUT: }
  764. // CHECK:STDOUT: %Core.import = import Core
  765. // CHECK:STDOUT: %ImplicitNotDeducible.decl: %ImplicitNotDeducible.type = fn_decl @ImplicitNotDeducible [template = constants.%ImplicitNotDeducible] {
  766. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  767. // CHECK:STDOUT: %x.patt: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = binding_pattern x
  768. // CHECK:STDOUT: %y.patt: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = binding_pattern y
  769. // CHECK:STDOUT: } {
  770. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  771. // CHECK:STDOUT: %T.loc4_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_25.2 (constants.%T)]
  772. // CHECK:STDOUT: %T.ref.loc4_38: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  773. // CHECK:STDOUT: %x.param: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = param x, runtime_param0
  774. // CHECK:STDOUT: %x: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = bind_name x, %x.param
  775. // CHECK:STDOUT: %T.ref.loc4_44: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  776. // CHECK:STDOUT: %y.param: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = param y, runtime_param1
  777. // CHECK:STDOUT: %y: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = bind_name y, %y.param
  778. // CHECK:STDOUT: %T.ref.loc4_50: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  779. // CHECK:STDOUT: %return: ref @ImplicitNotDeducible.%T.loc4_25.2 (%T) = var <return slot>
  780. // CHECK:STDOUT: }
  781. // CHECK:STDOUT: %CallImplicitNotDeducible.decl: %CallImplicitNotDeducible.type = fn_decl @CallImplicitNotDeducible [template = constants.%CallImplicitNotDeducible] {} {}
  782. // CHECK:STDOUT: }
  783. // CHECK:STDOUT:
  784. // CHECK:STDOUT: generic fn @ImplicitNotDeducible(%T.loc4_25.1: type) {
  785. // CHECK:STDOUT: %T.loc4_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_25.2 (constants.%T)]
  786. // CHECK:STDOUT:
  787. // CHECK:STDOUT: fn[%T.loc4_25.1: type](%x: @ImplicitNotDeducible.%T.loc4_25.2 (%T), %y: @ImplicitNotDeducible.%T.loc4_25.2 (%T)) -> @ImplicitNotDeducible.%T.loc4_25.2 (%T);
  788. // CHECK:STDOUT: }
  789. // CHECK:STDOUT:
  790. // CHECK:STDOUT: fn @CallImplicitNotDeducible() {
  791. // CHECK:STDOUT: !entry:
  792. // CHECK:STDOUT: %ImplicitNotDeducible.ref: %ImplicitNotDeducible.type = name_ref ImplicitNotDeducible, file.%ImplicitNotDeducible.decl [template = constants.%ImplicitNotDeducible]
  793. // CHECK:STDOUT: %.loc13_24: i32 = int_literal 42 [template = constants.%.2]
  794. // CHECK:STDOUT: %.loc13_34: i32 = int_literal 12 [template = constants.%.3]
  795. // CHECK:STDOUT: %.loc13_36: %.4 = struct_literal (%.loc13_34)
  796. // CHECK:STDOUT: return
  797. // CHECK:STDOUT: }
  798. // CHECK:STDOUT:
  799. // CHECK:STDOUT: specific @ImplicitNotDeducible(constants.%T) {
  800. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  801. // CHECK:STDOUT: }
  802. // CHECK:STDOUT: