deduce.carbon 40 KB

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