deduce.carbon 39 KB

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