deduce.carbon 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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*;
  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*;
  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: %Int32.type: type = fn_type @Int32 [template]
  95. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  96. // CHECK:STDOUT: %.3: type = ptr_type i32 [template]
  97. // CHECK:STDOUT: %CallExplicitGenericParam.type: type = fn_type @CallExplicitGenericParam [template]
  98. // CHECK:STDOUT: %CallExplicitGenericParam: %CallExplicitGenericParam.type = struct_value () [template]
  99. // CHECK:STDOUT: %.4: type = struct_type {.a: %T} [symbolic]
  100. // CHECK:STDOUT: %.5: type = ptr_type %.4 [symbolic]
  101. // CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg.type: type = fn_type @CallExplicitGenericParamWithGenericArg [template]
  102. // CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg: %CallExplicitGenericParamWithGenericArg.type = struct_value () [template]
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: imports {
  106. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  107. // CHECK:STDOUT: .Int32 = %import_ref
  108. // CHECK:STDOUT: import Core//prelude
  109. // CHECK:STDOUT: import Core//prelude/operators
  110. // CHECK:STDOUT: import Core//prelude/types
  111. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  112. // CHECK:STDOUT: import Core//prelude/operators/as
  113. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  114. // CHECK:STDOUT: import Core//prelude/operators/comparison
  115. // CHECK:STDOUT: import Core//prelude/types/bool
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: file {
  121. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  122. // CHECK:STDOUT: .Core = imports.%Core
  123. // CHECK:STDOUT: .ExplicitGenericParam = %ExplicitGenericParam.decl
  124. // CHECK:STDOUT: .CallExplicitGenericParam = %CallExplicitGenericParam.decl
  125. // CHECK:STDOUT: .CallExplicitGenericParamWithGenericArg = %CallExplicitGenericParamWithGenericArg.decl
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: %Core.import = import Core
  128. // CHECK:STDOUT: %ExplicitGenericParam.decl: %ExplicitGenericParam.type = fn_decl @ExplicitGenericParam [template = constants.%ExplicitGenericParam] {
  129. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  130. // CHECK:STDOUT: } {
  131. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  132. // CHECK:STDOUT: %T.loc4_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_25.2 (constants.%T)]
  133. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  134. // CHECK:STDOUT: %.loc4_39.1: type = ptr_type %T [symbolic = %.loc4_39.2 (constants.%.1)]
  135. // CHECK:STDOUT: %return: ref @ExplicitGenericParam.%.loc4_39.2 (%.1) = var <return slot>
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: %CallExplicitGenericParam.decl: %CallExplicitGenericParam.type = fn_decl @CallExplicitGenericParam [template = constants.%CallExplicitGenericParam] {} {
  138. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  139. // CHECK:STDOUT: %.loc6_37.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  140. // CHECK:STDOUT: %.loc6_37.2: type = converted %int.make_type_32.loc6, %.loc6_37.1 [template = i32]
  141. // CHECK:STDOUT: %.loc6_37.3: type = ptr_type i32 [template = constants.%.3]
  142. // CHECK:STDOUT: %return: ref %.3 = var <return slot>
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT: %CallExplicitGenericParamWithGenericArg.decl: %CallExplicitGenericParamWithGenericArg.type = fn_decl @CallExplicitGenericParamWithGenericArg [template = constants.%CallExplicitGenericParamWithGenericArg] {
  145. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  146. // CHECK:STDOUT: } {
  147. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  148. // CHECK:STDOUT: %T.loc10_43.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc10_43.2 (constants.%T)]
  149. // CHECK:STDOUT: %T.ref.loc10: type = name_ref T, %T.loc10_43.1 [symbolic = %T.loc10_43.2 (constants.%T)]
  150. // CHECK:STDOUT: %.loc10_62.1: type = struct_type {.a: %T} [symbolic = %.loc10_62.2 (constants.%.4)]
  151. // CHECK:STDOUT: %.loc10_63.1: type = ptr_type %.4 [symbolic = %.loc10_63.2 (constants.%.5)]
  152. // CHECK:STDOUT: %return: ref @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.5) = var <return slot>
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: generic fn @ExplicitGenericParam(%T.loc4_25.1: type) {
  157. // CHECK:STDOUT: %T.loc4_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_25.2 (constants.%T)]
  158. // CHECK:STDOUT: %.loc4_39.2: type = ptr_type @ExplicitGenericParam.%T.loc4_25.2 (%T) [symbolic = %.loc4_39.2 (constants.%.1)]
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: fn(%T.loc4_25.1: type) -> @ExplicitGenericParam.%.loc4_39.2 (%.1);
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: fn @CallExplicitGenericParam() -> %.3 {
  166. // CHECK:STDOUT: !entry:
  167. // CHECK:STDOUT: %ExplicitGenericParam.ref: %ExplicitGenericParam.type = name_ref ExplicitGenericParam, file.%ExplicitGenericParam.decl [template = constants.%ExplicitGenericParam]
  168. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  169. // CHECK:STDOUT: %.loc7_30.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  170. // CHECK:STDOUT: %.loc7_30.2: type = converted %int.make_type_32.loc7, %.loc7_30.1 [template = i32]
  171. // CHECK:STDOUT: %ExplicitGenericParam.call: init %.3 = call %ExplicitGenericParam.ref()
  172. // CHECK:STDOUT: %.loc7_35.1: %.3 = value_of_initializer %ExplicitGenericParam.call
  173. // CHECK:STDOUT: %.loc7_35.2: %.3 = converted %ExplicitGenericParam.call, %.loc7_35.1
  174. // CHECK:STDOUT: return %.loc7_35.2
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: generic fn @CallExplicitGenericParamWithGenericArg(%T.loc10_43.1: type) {
  178. // CHECK:STDOUT: %T.loc10_43.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc10_43.2 (constants.%T)]
  179. // CHECK:STDOUT: %.loc10_62.2: type = struct_type {.a: @CallExplicitGenericParamWithGenericArg.%T.loc10_43.2 (%T)} [symbolic = %.loc10_62.2 (constants.%.4)]
  180. // CHECK:STDOUT: %.loc10_63.2: type = ptr_type @CallExplicitGenericParamWithGenericArg.%.loc10_62.2 (%.4) [symbolic = %.loc10_63.2 (constants.%.5)]
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: !definition:
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: fn(%T.loc10_43.1: type) -> @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.5) {
  185. // CHECK:STDOUT: !entry:
  186. // CHECK:STDOUT: %ExplicitGenericParam.ref: %ExplicitGenericParam.type = name_ref ExplicitGenericParam, file.%ExplicitGenericParam.decl [template = constants.%ExplicitGenericParam]
  187. // CHECK:STDOUT: %T.ref.loc11: type = name_ref T, %T.loc10_43.1 [symbolic = %T.loc10_43.2 (constants.%T)]
  188. // CHECK:STDOUT: %.loc11_37: type = struct_type {.a: %T} [symbolic = %.loc10_62.2 (constants.%.4)]
  189. // CHECK:STDOUT: %ExplicitGenericParam.call: init @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.5) = call %ExplicitGenericParam.ref()
  190. // CHECK:STDOUT: %.loc11_39.1: @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.5) = value_of_initializer %ExplicitGenericParam.call
  191. // CHECK:STDOUT: %.loc11_39.2: @CallExplicitGenericParamWithGenericArg.%.loc10_63.2 (%.5) = converted %ExplicitGenericParam.call, %.loc11_39.1
  192. // CHECK:STDOUT: return %.loc11_39.2
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: specific @ExplicitGenericParam(constants.%T) {
  197. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  198. // CHECK:STDOUT: %.loc4_39.2 => constants.%.1
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: specific @ExplicitGenericParam(i32) {
  202. // CHECK:STDOUT: %T.loc4_25.2 => i32
  203. // CHECK:STDOUT: %.loc4_39.2 => constants.%.3
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: specific @CallExplicitGenericParamWithGenericArg(constants.%T) {
  207. // CHECK:STDOUT: %T.loc10_43.2 => constants.%T
  208. // CHECK:STDOUT: %.loc10_62.2 => constants.%.4
  209. // CHECK:STDOUT: %.loc10_63.2 => constants.%.5
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: specific @ExplicitGenericParam(constants.%.4) {
  213. // CHECK:STDOUT: %T.loc4_25.2 => constants.%.4
  214. // CHECK:STDOUT: %.loc4_39.2 => constants.%.5
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: --- fail_todo_explicit_vs_deduced.carbon
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: constants {
  220. // CHECK:STDOUT: %A: type = class_type @A [template]
  221. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  222. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  223. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  224. // CHECK:STDOUT: %.3: type = ptr_type %T [symbolic]
  225. // CHECK:STDOUT: %ExplicitAndAlsoDeduced.type: type = fn_type @ExplicitAndAlsoDeduced [template]
  226. // CHECK:STDOUT: %.4: type = tuple_type () [template]
  227. // CHECK:STDOUT: %ExplicitAndAlsoDeduced: %ExplicitAndAlsoDeduced.type = struct_value () [template]
  228. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  229. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  230. // CHECK:STDOUT: %.5: type = ptr_type i32 [template]
  231. // CHECK:STDOUT: %CallExplicitAndAlsoDeduced.type: type = fn_type @CallExplicitAndAlsoDeduced [template]
  232. // CHECK:STDOUT: %CallExplicitAndAlsoDeduced: %CallExplicitAndAlsoDeduced.type = struct_value () [template]
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: imports {
  236. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  237. // CHECK:STDOUT: .Int32 = %import_ref
  238. // CHECK:STDOUT: import Core//prelude
  239. // CHECK:STDOUT: import Core//prelude/operators
  240. // CHECK:STDOUT: import Core//prelude/types
  241. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  242. // CHECK:STDOUT: import Core//prelude/operators/as
  243. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  244. // CHECK:STDOUT: import Core//prelude/operators/comparison
  245. // CHECK:STDOUT: import Core//prelude/types/bool
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: file {
  251. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  252. // CHECK:STDOUT: .Core = imports.%Core
  253. // CHECK:STDOUT: .A = %A.decl
  254. // CHECK:STDOUT: .ExplicitAndAlsoDeduced = %ExplicitAndAlsoDeduced.decl
  255. // CHECK:STDOUT: .CallExplicitAndAlsoDeduced = %CallExplicitAndAlsoDeduced.decl
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT: %Core.import = import Core
  258. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  259. // CHECK:STDOUT: %ExplicitAndAlsoDeduced.decl: %ExplicitAndAlsoDeduced.type = fn_decl @ExplicitAndAlsoDeduced [template = constants.%ExplicitAndAlsoDeduced] {
  260. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  261. // CHECK:STDOUT: %x.patt: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) = binding_pattern x
  262. // CHECK:STDOUT: } {
  263. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  264. // CHECK:STDOUT: %T.loc6_27.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_27.2 (constants.%T)]
  265. // CHECK:STDOUT: %T.ref.loc6_40: type = name_ref T, %T.loc6_27.1 [symbolic = %T.loc6_27.2 (constants.%T)]
  266. // CHECK:STDOUT: %x.param: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) = param x, runtime_param0
  267. // CHECK:STDOUT: %x: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) = bind_name x, %x.param
  268. // CHECK:STDOUT: %T.ref.loc6_46: type = name_ref T, %T.loc6_27.1 [symbolic = %T.loc6_27.2 (constants.%T)]
  269. // CHECK:STDOUT: %.loc6_47.1: type = ptr_type %T [symbolic = %.loc6_47.2 (constants.%.3)]
  270. // CHECK:STDOUT: %return: ref @ExplicitAndAlsoDeduced.%.loc6_47.2 (%.3) = var <return slot>
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT: %CallExplicitAndAlsoDeduced.decl: %CallExplicitAndAlsoDeduced.type = fn_decl @CallExplicitAndAlsoDeduced [template = constants.%CallExplicitAndAlsoDeduced] {
  273. // CHECK:STDOUT: %n.patt: i32 = binding_pattern n
  274. // CHECK:STDOUT: } {
  275. // CHECK:STDOUT: %int.make_type_32.loc9_34: init type = call constants.%Int32() [template = i32]
  276. // CHECK:STDOUT: %.loc9_34.1: type = value_of_initializer %int.make_type_32.loc9_34 [template = i32]
  277. // CHECK:STDOUT: %.loc9_34.2: type = converted %int.make_type_32.loc9_34, %.loc9_34.1 [template = i32]
  278. // CHECK:STDOUT: %n.param: i32 = param n, runtime_param0
  279. // CHECK:STDOUT: %n: i32 = bind_name n, %n.param
  280. // CHECK:STDOUT: %int.make_type_32.loc9_42: init type = call constants.%Int32() [template = i32]
  281. // CHECK:STDOUT: %.loc9_45.1: type = value_of_initializer %int.make_type_32.loc9_42 [template = i32]
  282. // CHECK:STDOUT: %.loc9_45.2: type = converted %int.make_type_32.loc9_42, %.loc9_45.1 [template = i32]
  283. // CHECK:STDOUT: %.loc9_45.3: type = ptr_type i32 [template = constants.%.5]
  284. // CHECK:STDOUT: %return: ref %.5 = var <return slot>
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: class @A {
  289. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: !members:
  292. // CHECK:STDOUT: .Self = constants.%A
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: generic fn @ExplicitAndAlsoDeduced(%T.loc6_27.1: type) {
  296. // CHECK:STDOUT: %T.loc6_27.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_27.2 (constants.%T)]
  297. // CHECK:STDOUT: %.loc6_47.2: type = ptr_type @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T) [symbolic = %.loc6_47.2 (constants.%.3)]
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: fn(%T.loc6_27.1: type, %x: @ExplicitAndAlsoDeduced.%T.loc6_27.2 (%T)) -> @ExplicitAndAlsoDeduced.%.loc6_47.2 (%.3);
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: fn @CallExplicitAndAlsoDeduced(%n: i32) -> %.5 {
  305. // CHECK:STDOUT: !entry:
  306. // CHECK:STDOUT: %ExplicitAndAlsoDeduced.ref: %ExplicitAndAlsoDeduced.type = name_ref ExplicitAndAlsoDeduced, file.%ExplicitAndAlsoDeduced.decl [template = constants.%ExplicitAndAlsoDeduced]
  307. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
  308. // CHECK:STDOUT: %.loc17: %.1 = struct_literal ()
  309. // CHECK:STDOUT: return <error>
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: specific @ExplicitAndAlsoDeduced(constants.%T) {
  313. // CHECK:STDOUT: %T.loc6_27.2 => constants.%T
  314. // CHECK:STDOUT: %.loc6_47.2 => constants.%.3
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: --- deduce_implicit.carbon
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: constants {
  320. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  321. // CHECK:STDOUT: %.1: type = ptr_type %T [symbolic]
  322. // CHECK:STDOUT: %ImplicitGenericParam.type: type = fn_type @ImplicitGenericParam [template]
  323. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  324. // CHECK:STDOUT: %ImplicitGenericParam: %ImplicitGenericParam.type = struct_value () [template]
  325. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  326. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  327. // CHECK:STDOUT: %.3: type = ptr_type i32 [template]
  328. // CHECK:STDOUT: %CallImplicitGenericParam.type: type = fn_type @CallImplicitGenericParam [template]
  329. // CHECK:STDOUT: %CallImplicitGenericParam: %CallImplicitGenericParam.type = struct_value () [template]
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: imports {
  333. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  334. // CHECK:STDOUT: .Int32 = %import_ref
  335. // CHECK:STDOUT: import Core//prelude
  336. // CHECK:STDOUT: import Core//prelude/operators
  337. // CHECK:STDOUT: import Core//prelude/types
  338. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  339. // CHECK:STDOUT: import Core//prelude/operators/as
  340. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  341. // CHECK:STDOUT: import Core//prelude/operators/comparison
  342. // CHECK:STDOUT: import Core//prelude/types/bool
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: file {
  348. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  349. // CHECK:STDOUT: .Core = imports.%Core
  350. // CHECK:STDOUT: .ImplicitGenericParam = %ImplicitGenericParam.decl
  351. // CHECK:STDOUT: .CallImplicitGenericParam = %CallImplicitGenericParam.decl
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: %Core.import = import Core
  354. // CHECK:STDOUT: %ImplicitGenericParam.decl: %ImplicitGenericParam.type = fn_decl @ImplicitGenericParam [template = constants.%ImplicitGenericParam] {
  355. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  356. // CHECK:STDOUT: %x.patt: @ImplicitGenericParam.%T.loc4_25.2 (%T) = binding_pattern x
  357. // CHECK:STDOUT: } {
  358. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  359. // CHECK:STDOUT: %T.loc4_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_25.2 (constants.%T)]
  360. // CHECK:STDOUT: %T.ref.loc4_38: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  361. // CHECK:STDOUT: %x.param: @ImplicitGenericParam.%T.loc4_25.2 (%T) = param x, runtime_param0
  362. // CHECK:STDOUT: %x: @ImplicitGenericParam.%T.loc4_25.2 (%T) = bind_name x, %x.param
  363. // CHECK:STDOUT: %T.ref.loc4_44: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  364. // CHECK:STDOUT: %.loc4_45.1: type = ptr_type %T [symbolic = %.loc4_45.2 (constants.%.1)]
  365. // CHECK:STDOUT: %return: ref @ImplicitGenericParam.%.loc4_45.2 (%.1) = var <return slot>
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT: %CallImplicitGenericParam.decl: %CallImplicitGenericParam.type = fn_decl @CallImplicitGenericParam [template = constants.%CallImplicitGenericParam] {
  368. // CHECK:STDOUT: %n.patt: i32 = binding_pattern n
  369. // CHECK:STDOUT: } {
  370. // CHECK:STDOUT: %int.make_type_32.loc6_32: init type = call constants.%Int32() [template = i32]
  371. // CHECK:STDOUT: %.loc6_32.1: type = value_of_initializer %int.make_type_32.loc6_32 [template = i32]
  372. // CHECK:STDOUT: %.loc6_32.2: type = converted %int.make_type_32.loc6_32, %.loc6_32.1 [template = i32]
  373. // CHECK:STDOUT: %n.param: i32 = param n, runtime_param0
  374. // CHECK:STDOUT: %n: i32 = bind_name n, %n.param
  375. // CHECK:STDOUT: %int.make_type_32.loc6_40: init type = call constants.%Int32() [template = i32]
  376. // CHECK:STDOUT: %.loc6_43.1: type = value_of_initializer %int.make_type_32.loc6_40 [template = i32]
  377. // CHECK:STDOUT: %.loc6_43.2: type = converted %int.make_type_32.loc6_40, %.loc6_43.1 [template = i32]
  378. // CHECK:STDOUT: %.loc6_43.3: type = ptr_type i32 [template = constants.%.3]
  379. // CHECK:STDOUT: %return: ref %.3 = var <return slot>
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: generic fn @ImplicitGenericParam(%T.loc4_25.1: type) {
  384. // CHECK:STDOUT: %T.loc4_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_25.2 (constants.%T)]
  385. // CHECK:STDOUT: %.loc4_45.2: type = ptr_type @ImplicitGenericParam.%T.loc4_25.2 (%T) [symbolic = %.loc4_45.2 (constants.%.1)]
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: fn[%T.loc4_25.1: type](%x: @ImplicitGenericParam.%T.loc4_25.2 (%T)) -> @ImplicitGenericParam.%.loc4_45.2 (%.1);
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT:
  390. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  391. // CHECK:STDOUT:
  392. // CHECK:STDOUT: fn @CallImplicitGenericParam(%n: i32) -> %.3 {
  393. // CHECK:STDOUT: !entry:
  394. // CHECK:STDOUT: %ImplicitGenericParam.ref: %ImplicitGenericParam.type = name_ref ImplicitGenericParam, file.%ImplicitGenericParam.decl [template = constants.%ImplicitGenericParam]
  395. // CHECK:STDOUT: %n.ref: i32 = name_ref n, %n
  396. // CHECK:STDOUT: %ImplicitGenericParam.call: init %.3 = call %ImplicitGenericParam.ref(%n.ref)
  397. // CHECK:STDOUT: %.loc7_33.1: %.3 = value_of_initializer %ImplicitGenericParam.call
  398. // CHECK:STDOUT: %.loc7_33.2: %.3 = converted %ImplicitGenericParam.call, %.loc7_33.1
  399. // CHECK:STDOUT: return %.loc7_33.2
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: specific @ImplicitGenericParam(constants.%T) {
  403. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  404. // CHECK:STDOUT: %.loc4_45.2 => constants.%.1
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT:
  407. // CHECK:STDOUT: specific @ImplicitGenericParam(i32) {
  408. // CHECK:STDOUT: %T.loc4_25.2 => i32
  409. // CHECK:STDOUT: %.loc4_45.2 => constants.%.3
  410. // CHECK:STDOUT: }
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: --- deduce_nested_tuple.carbon
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: constants {
  415. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  416. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  417. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  418. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  419. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  420. // CHECK:STDOUT: %.3: type = tuple_type (%T, i32) [symbolic]
  421. // CHECK:STDOUT: %TupleParam.type: type = fn_type @TupleParam [template]
  422. // CHECK:STDOUT: %TupleParam: %TupleParam.type = struct_value () [template]
  423. // CHECK:STDOUT: %CallTupleParam.type: type = fn_type @CallTupleParam [template]
  424. // CHECK:STDOUT: %CallTupleParam: %CallTupleParam.type = struct_value () [template]
  425. // CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
  426. // CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
  427. // CHECK:STDOUT: %.6: type = tuple_type (i32, i32) [template]
  428. // CHECK:STDOUT: %.7: type = ptr_type %.6 [template]
  429. // CHECK:STDOUT: %tuple: %.6 = tuple_value (%.4, %.5) [template]
  430. // CHECK:STDOUT: }
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: imports {
  433. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  434. // CHECK:STDOUT: .Int32 = %import_ref
  435. // CHECK:STDOUT: import Core//prelude
  436. // CHECK:STDOUT: import Core//prelude/operators
  437. // CHECK:STDOUT: import Core//prelude/types
  438. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  439. // CHECK:STDOUT: import Core//prelude/operators/as
  440. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  441. // CHECK:STDOUT: import Core//prelude/operators/comparison
  442. // CHECK:STDOUT: import Core//prelude/types/bool
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT:
  447. // CHECK:STDOUT: file {
  448. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  449. // CHECK:STDOUT: .Core = imports.%Core
  450. // CHECK:STDOUT: .TupleParam = %TupleParam.decl
  451. // CHECK:STDOUT: .CallTupleParam = %CallTupleParam.decl
  452. // CHECK:STDOUT: }
  453. // CHECK:STDOUT: %Core.import = import Core
  454. // CHECK:STDOUT: %TupleParam.decl: %TupleParam.type = fn_decl @TupleParam [template = constants.%TupleParam] {
  455. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  456. // CHECK:STDOUT: %x.patt: @TupleParam.%.loc4_35.5 (%.3) = binding_pattern x
  457. // CHECK:STDOUT: } {
  458. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  459. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_15.2 (constants.%T)]
  460. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)]
  461. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  462. // CHECK:STDOUT: %.loc4_35.1: %.2 = tuple_literal (%T.ref, %int.make_type_32)
  463. // CHECK:STDOUT: %.loc4_35.2: type = value_of_initializer %int.make_type_32 [template = i32]
  464. // CHECK:STDOUT: %.loc4_35.3: type = converted %int.make_type_32, %.loc4_35.2 [template = i32]
  465. // CHECK:STDOUT: %.loc4_35.4: type = converted %.loc4_35.1, constants.%.3 [symbolic = %.loc4_35.5 (constants.%.3)]
  466. // CHECK:STDOUT: %x.param: @TupleParam.%.loc4_35.5 (%.3) = param x, runtime_param0
  467. // CHECK:STDOUT: %x: @TupleParam.%.loc4_35.5 (%.3) = bind_name x, %x.param
  468. // CHECK:STDOUT: }
  469. // CHECK:STDOUT: %CallTupleParam.decl: %CallTupleParam.type = fn_decl @CallTupleParam [template = constants.%CallTupleParam] {} {}
  470. // CHECK:STDOUT: }
  471. // CHECK:STDOUT:
  472. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  473. // CHECK:STDOUT:
  474. // CHECK:STDOUT: generic fn @TupleParam(%T.loc4_15.1: type) {
  475. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_15.2 (constants.%T)]
  476. // CHECK:STDOUT: %.loc4_35.5: type = tuple_type (@TupleParam.%T.loc4_15.2 (%T), i32) [symbolic = %.loc4_35.5 (constants.%.3)]
  477. // CHECK:STDOUT:
  478. // CHECK:STDOUT: fn[%T.loc4_15.1: type](%x: @TupleParam.%.loc4_35.5 (%.3));
  479. // CHECK:STDOUT: }
  480. // CHECK:STDOUT:
  481. // CHECK:STDOUT: fn @CallTupleParam() {
  482. // CHECK:STDOUT: !entry:
  483. // CHECK:STDOUT: %TupleParam.ref: %TupleParam.type = name_ref TupleParam, file.%TupleParam.decl [template = constants.%TupleParam]
  484. // CHECK:STDOUT: %.loc7_15: i32 = int_literal 1 [template = constants.%.4]
  485. // CHECK:STDOUT: %.loc7_18: i32 = int_literal 2 [template = constants.%.5]
  486. // CHECK:STDOUT: %.loc7_19: %.6 = tuple_literal (%.loc7_15, %.loc7_18)
  487. // CHECK:STDOUT: %tuple: %.6 = tuple_value (%.loc7_15, %.loc7_18) [template = constants.%tuple]
  488. // CHECK:STDOUT: %.loc7_13: %.6 = converted %.loc7_19, %tuple [template = constants.%tuple]
  489. // CHECK:STDOUT: %TupleParam.call: init %.1 = call %TupleParam.ref(%.loc7_13)
  490. // CHECK:STDOUT: return
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT:
  493. // CHECK:STDOUT: specific @TupleParam(constants.%T) {
  494. // CHECK:STDOUT: %T.loc4_15.2 => constants.%T
  495. // CHECK:STDOUT: %.loc4_35.5 => constants.%.3
  496. // CHECK:STDOUT: }
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: specific @TupleParam(i32) {
  499. // CHECK:STDOUT: %T.loc4_15.2 => i32
  500. // CHECK:STDOUT: %.loc4_35.5 => constants.%.6
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: --- fail_todo_deduce_nested_struct.carbon
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: constants {
  506. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  507. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  508. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  509. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  510. // CHECK:STDOUT: %.2: type = struct_type {.a: %T, .b: i32} [symbolic]
  511. // CHECK:STDOUT: %StructParam.type: type = fn_type @StructParam [template]
  512. // CHECK:STDOUT: %StructParam: %StructParam.type = struct_value () [template]
  513. // CHECK:STDOUT: %CallStructParam.type: type = fn_type @CallStructParam [template]
  514. // CHECK:STDOUT: %CallStructParam: %CallStructParam.type = struct_value () [template]
  515. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  516. // CHECK:STDOUT: %.4: i32 = int_literal 2 [template]
  517. // CHECK:STDOUT: %.5: type = struct_type {.a: i32, .b: i32} [template]
  518. // CHECK:STDOUT: }
  519. // CHECK:STDOUT:
  520. // CHECK:STDOUT: imports {
  521. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  522. // CHECK:STDOUT: .Int32 = %import_ref
  523. // CHECK:STDOUT: import Core//prelude
  524. // CHECK:STDOUT: import Core//prelude/operators
  525. // CHECK:STDOUT: import Core//prelude/types
  526. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  527. // CHECK:STDOUT: import Core//prelude/operators/as
  528. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  529. // CHECK:STDOUT: import Core//prelude/operators/comparison
  530. // CHECK:STDOUT: import Core//prelude/types/bool
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  533. // CHECK:STDOUT: }
  534. // CHECK:STDOUT:
  535. // CHECK:STDOUT: file {
  536. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  537. // CHECK:STDOUT: .Core = imports.%Core
  538. // CHECK:STDOUT: .StructParam = %StructParam.decl
  539. // CHECK:STDOUT: .CallStructParam = %CallStructParam.decl
  540. // CHECK:STDOUT: }
  541. // CHECK:STDOUT: %Core.import = import Core
  542. // CHECK:STDOUT: %StructParam.decl: %StructParam.type = fn_decl @StructParam [template = constants.%StructParam] {
  543. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  544. // CHECK:STDOUT: %x.patt: @StructParam.%.loc4_44.2 (%.2) = binding_pattern x
  545. // CHECK:STDOUT: } {
  546. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  547. // CHECK:STDOUT: %T.loc4_16.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_16.2 (constants.%T)]
  548. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_16.1 [symbolic = %T.loc4_16.2 (constants.%T)]
  549. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  550. // CHECK:STDOUT: %.loc4_41.1: type = value_of_initializer %int.make_type_32 [template = i32]
  551. // CHECK:STDOUT: %.loc4_41.2: type = converted %int.make_type_32, %.loc4_41.1 [template = i32]
  552. // CHECK:STDOUT: %.loc4_44.1: type = struct_type {.a: %T, .b: i32} [symbolic = %.loc4_44.2 (constants.%.2)]
  553. // CHECK:STDOUT: %x.param: @StructParam.%.loc4_44.2 (%.2) = param x, runtime_param0
  554. // CHECK:STDOUT: %x: @StructParam.%.loc4_44.2 (%.2) = bind_name x, %x.param
  555. // CHECK:STDOUT: }
  556. // CHECK:STDOUT: %CallStructParam.decl: %CallStructParam.type = fn_decl @CallStructParam [template = constants.%CallStructParam] {} {}
  557. // CHECK:STDOUT: }
  558. // CHECK:STDOUT:
  559. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  560. // CHECK:STDOUT:
  561. // CHECK:STDOUT: generic fn @StructParam(%T.loc4_16.1: type) {
  562. // CHECK:STDOUT: %T.loc4_16.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_16.2 (constants.%T)]
  563. // CHECK:STDOUT: %.loc4_44.2: type = struct_type {.a: @StructParam.%T.loc4_16.2 (%T), .b: i32} [symbolic = %.loc4_44.2 (constants.%.2)]
  564. // CHECK:STDOUT:
  565. // CHECK:STDOUT: fn[%T.loc4_16.1: type](%x: @StructParam.%.loc4_44.2 (%.2));
  566. // CHECK:STDOUT: }
  567. // CHECK:STDOUT:
  568. // CHECK:STDOUT: fn @CallStructParam() {
  569. // CHECK:STDOUT: !entry:
  570. // CHECK:STDOUT: %StructParam.ref: %StructParam.type = name_ref StructParam, file.%StructParam.decl [template = constants.%StructParam]
  571. // CHECK:STDOUT: %.loc14_21: i32 = int_literal 1 [template = constants.%.3]
  572. // CHECK:STDOUT: %.loc14_29: i32 = int_literal 2 [template = constants.%.4]
  573. // CHECK:STDOUT: %.loc14_30: %.5 = struct_literal (%.loc14_21, %.loc14_29)
  574. // CHECK:STDOUT: return
  575. // CHECK:STDOUT: }
  576. // CHECK:STDOUT:
  577. // CHECK:STDOUT: specific @StructParam(constants.%T) {
  578. // CHECK:STDOUT: %T.loc4_16.2 => constants.%T
  579. // CHECK:STDOUT: %.loc4_44.2 => constants.%.2
  580. // CHECK:STDOUT: }
  581. // CHECK:STDOUT:
  582. // CHECK:STDOUT: --- fail_deduce_incomplete.carbon
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: constants {
  585. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  586. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 1 [symbolic]
  587. // CHECK:STDOUT: %ImplicitNotDeducible.type: type = fn_type @ImplicitNotDeducible [template]
  588. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  589. // CHECK:STDOUT: %ImplicitNotDeducible: %ImplicitNotDeducible.type = struct_value () [template]
  590. // CHECK:STDOUT: %CallImplicitNotDeducible.type: type = fn_type @CallImplicitNotDeducible [template]
  591. // CHECK:STDOUT: %CallImplicitNotDeducible: %CallImplicitNotDeducible.type = struct_value () [template]
  592. // CHECK:STDOUT: %.2: i32 = int_literal 42 [template]
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT:
  595. // CHECK:STDOUT: imports {
  596. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  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: }
  607. // CHECK:STDOUT:
  608. // CHECK:STDOUT: file {
  609. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  610. // CHECK:STDOUT: .Core = imports.%Core
  611. // CHECK:STDOUT: .ImplicitNotDeducible = %ImplicitNotDeducible.decl
  612. // CHECK:STDOUT: .CallImplicitNotDeducible = %CallImplicitNotDeducible.decl
  613. // CHECK:STDOUT: }
  614. // CHECK:STDOUT: %Core.import = import Core
  615. // CHECK:STDOUT: %ImplicitNotDeducible.decl: %ImplicitNotDeducible.type = fn_decl @ImplicitNotDeducible [template = constants.%ImplicitNotDeducible] {
  616. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  617. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 1
  618. // CHECK:STDOUT: %x.patt: @ImplicitNotDeducible.%T.loc6_25.2 (%T) = binding_pattern x
  619. // CHECK:STDOUT: } {
  620. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  621. // CHECK:STDOUT: %T.loc6_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_25.2 (constants.%T)]
  622. // CHECK:STDOUT: %U.param: type = param U, runtime_param<invalid>
  623. // CHECK:STDOUT: %U.loc6_35.1: type = bind_symbolic_name U, 1, %U.param [symbolic = %U.loc6_35.2 (constants.%U)]
  624. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6_25.1 [symbolic = %T.loc6_25.2 (constants.%T)]
  625. // CHECK:STDOUT: %x.param: @ImplicitNotDeducible.%T.loc6_25.2 (%T) = param x, runtime_param0
  626. // CHECK:STDOUT: %x: @ImplicitNotDeducible.%T.loc6_25.2 (%T) = bind_name x, %x.param
  627. // CHECK:STDOUT: %U.ref: type = name_ref U, %U.loc6_35.1 [symbolic = %U.loc6_35.2 (constants.%U)]
  628. // CHECK:STDOUT: %return: ref @ImplicitNotDeducible.%U.loc6_35.2 (%U) = var <return slot>
  629. // CHECK:STDOUT: }
  630. // CHECK:STDOUT: %CallImplicitNotDeducible.decl: %CallImplicitNotDeducible.type = fn_decl @CallImplicitNotDeducible [template = constants.%CallImplicitNotDeducible] {} {}
  631. // CHECK:STDOUT: }
  632. // CHECK:STDOUT:
  633. // CHECK:STDOUT: generic fn @ImplicitNotDeducible(%T.loc6_25.1: type, %U.loc6_35.1: type) {
  634. // CHECK:STDOUT: %T.loc6_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_25.2 (constants.%T)]
  635. // CHECK:STDOUT: %U.loc6_35.2: type = bind_symbolic_name U, 1 [symbolic = %U.loc6_35.2 (constants.%U)]
  636. // CHECK:STDOUT:
  637. // 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);
  638. // CHECK:STDOUT: }
  639. // CHECK:STDOUT:
  640. // CHECK:STDOUT: fn @CallImplicitNotDeducible() {
  641. // CHECK:STDOUT: !entry:
  642. // CHECK:STDOUT: %ImplicitNotDeducible.ref: %ImplicitNotDeducible.type = name_ref ImplicitNotDeducible, file.%ImplicitNotDeducible.decl [template = constants.%ImplicitNotDeducible]
  643. // CHECK:STDOUT: %.loc16: i32 = int_literal 42 [template = constants.%.2]
  644. // CHECK:STDOUT: return
  645. // CHECK:STDOUT: }
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: specific @ImplicitNotDeducible(constants.%T, constants.%U) {
  648. // CHECK:STDOUT: %T.loc6_25.2 => constants.%T
  649. // CHECK:STDOUT: %U.loc6_35.2 => constants.%U
  650. // CHECK:STDOUT: }
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: --- fail_deduce_inconsistent.carbon
  653. // CHECK:STDOUT:
  654. // CHECK:STDOUT: constants {
  655. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  656. // CHECK:STDOUT: %ImplicitNotDeducible.type: type = fn_type @ImplicitNotDeducible [template]
  657. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  658. // CHECK:STDOUT: %ImplicitNotDeducible: %ImplicitNotDeducible.type = struct_value () [template]
  659. // CHECK:STDOUT: %CallImplicitNotDeducible.type: type = fn_type @CallImplicitNotDeducible [template]
  660. // CHECK:STDOUT: %CallImplicitNotDeducible: %CallImplicitNotDeducible.type = struct_value () [template]
  661. // CHECK:STDOUT: %.2: i32 = int_literal 42 [template]
  662. // CHECK:STDOUT: %.3: i32 = int_literal 12 [template]
  663. // CHECK:STDOUT: %.4: type = struct_type {.x: i32} [template]
  664. // CHECK:STDOUT: }
  665. // CHECK:STDOUT:
  666. // CHECK:STDOUT: imports {
  667. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  668. // CHECK:STDOUT: import Core//prelude
  669. // CHECK:STDOUT: import Core//prelude/operators
  670. // CHECK:STDOUT: import Core//prelude/types
  671. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  672. // CHECK:STDOUT: import Core//prelude/operators/as
  673. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  674. // CHECK:STDOUT: import Core//prelude/operators/comparison
  675. // CHECK:STDOUT: import Core//prelude/types/bool
  676. // CHECK:STDOUT: }
  677. // CHECK:STDOUT: }
  678. // CHECK:STDOUT:
  679. // CHECK:STDOUT: file {
  680. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  681. // CHECK:STDOUT: .Core = imports.%Core
  682. // CHECK:STDOUT: .ImplicitNotDeducible = %ImplicitNotDeducible.decl
  683. // CHECK:STDOUT: .CallImplicitNotDeducible = %CallImplicitNotDeducible.decl
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT: %Core.import = import Core
  686. // CHECK:STDOUT: %ImplicitNotDeducible.decl: %ImplicitNotDeducible.type = fn_decl @ImplicitNotDeducible [template = constants.%ImplicitNotDeducible] {
  687. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0
  688. // CHECK:STDOUT: %x.patt: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = binding_pattern x
  689. // CHECK:STDOUT: %y.patt: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = binding_pattern y
  690. // CHECK:STDOUT: } {
  691. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  692. // CHECK:STDOUT: %T.loc4_25.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_25.2 (constants.%T)]
  693. // CHECK:STDOUT: %T.ref.loc4_38: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  694. // CHECK:STDOUT: %x.param: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = param x, runtime_param0
  695. // CHECK:STDOUT: %x: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = bind_name x, %x.param
  696. // CHECK:STDOUT: %T.ref.loc4_44: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  697. // CHECK:STDOUT: %y.param: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = param y, runtime_param1
  698. // CHECK:STDOUT: %y: @ImplicitNotDeducible.%T.loc4_25.2 (%T) = bind_name y, %y.param
  699. // CHECK:STDOUT: %T.ref.loc4_50: type = name_ref T, %T.loc4_25.1 [symbolic = %T.loc4_25.2 (constants.%T)]
  700. // CHECK:STDOUT: %return: ref @ImplicitNotDeducible.%T.loc4_25.2 (%T) = var <return slot>
  701. // CHECK:STDOUT: }
  702. // CHECK:STDOUT: %CallImplicitNotDeducible.decl: %CallImplicitNotDeducible.type = fn_decl @CallImplicitNotDeducible [template = constants.%CallImplicitNotDeducible] {} {}
  703. // CHECK:STDOUT: }
  704. // CHECK:STDOUT:
  705. // CHECK:STDOUT: generic fn @ImplicitNotDeducible(%T.loc4_25.1: type) {
  706. // CHECK:STDOUT: %T.loc4_25.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_25.2 (constants.%T)]
  707. // CHECK:STDOUT:
  708. // 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);
  709. // CHECK:STDOUT: }
  710. // CHECK:STDOUT:
  711. // CHECK:STDOUT: fn @CallImplicitNotDeducible() {
  712. // CHECK:STDOUT: !entry:
  713. // CHECK:STDOUT: %ImplicitNotDeducible.ref: %ImplicitNotDeducible.type = name_ref ImplicitNotDeducible, file.%ImplicitNotDeducible.decl [template = constants.%ImplicitNotDeducible]
  714. // CHECK:STDOUT: %.loc13_24: i32 = int_literal 42 [template = constants.%.2]
  715. // CHECK:STDOUT: %.loc13_34: i32 = int_literal 12 [template = constants.%.3]
  716. // CHECK:STDOUT: %.loc13_36: %.4 = struct_literal (%.loc13_34)
  717. // CHECK:STDOUT: return
  718. // CHECK:STDOUT: }
  719. // CHECK:STDOUT:
  720. // CHECK:STDOUT: specific @ImplicitNotDeducible(constants.%T) {
  721. // CHECK:STDOUT: %T.loc4_25.2 => constants.%T
  722. // CHECK:STDOUT: }
  723. // CHECK:STDOUT: