call.carbon 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/eval/call.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/eval/call.carbon
  12. // --- call.carbon
  13. library "[[@TEST_NAME]]";
  14. eval fn F() -> i32 { return 3; }
  15. var a: array(i32, F()) = (0, 1, 2);
  16. // --- fail_call_wrong_value.carbon
  17. library "[[@TEST_NAME]]";
  18. eval fn F() -> i32 { return 3; }
  19. // Ensure we get an error about the over-sized initializer and aren't just
  20. // treating all `eval fn` calls as silent errors.
  21. // CHECK:STDERR: fail_call_wrong_value.carbon:[[@LINE+4]]:26: error: cannot initialize array of 3 elements from 4 initializers [ArrayInitFromLiteralArgCountMismatch]
  22. // CHECK:STDERR: var a: array(i32, F()) = (0, 1, 2, 3);
  23. // CHECK:STDERR: ^~~~~~~~~~~~
  24. // CHECK:STDERR:
  25. var a: array(i32, F()) = (0, 1, 2, 3);
  26. // --- fail_call_fn_not_eval.carbon
  27. library "[[@TEST_NAME]]";
  28. fn F() -> i32 { return 3; }
  29. // CHECK:STDERR: fail_call_fn_not_eval.carbon:[[@LINE+4]]:19: error: array bound is not a constant [InvalidArrayExpr]
  30. // CHECK:STDERR: var a: array(i32, F()) = (0, 1, 2);
  31. // CHECK:STDERR: ^~~
  32. // CHECK:STDERR:
  33. var a: array(i32, F()) = (0, 1, 2);
  34. // --- fail_call_eval_fn_not_defined.carbon
  35. library "[[@TEST_NAME]]";
  36. eval fn F() -> i32;
  37. // TODO: We should be able to diagnose this better.
  38. // CHECK:STDERR: fail_call_eval_fn_not_defined.carbon:[[@LINE+4]]:19: error: array bound is not a constant [InvalidArrayExpr]
  39. // CHECK:STDERR: var a: array(i32, F()) = (0, 1, 2);
  40. // CHECK:STDERR: ^~~
  41. // CHECK:STDERR:
  42. var a: array(i32, F()) = (0, 1, 2);
  43. // --- param_and_return.carbon
  44. library "[[@TEST_NAME]]";
  45. eval fn F(x: i32) -> i32 { return x; }
  46. var a: array(i32, F(3)) = (1, 2, 3);
  47. // --- fail_todo_dependent_call.carbon
  48. library "[[@TEST_NAME]]";
  49. eval fn F(x: i32) -> i32 { return x; }
  50. fn G(N:! i32) {
  51. // CHECK:STDERR: fail_todo_dependent_call.carbon:[[@LINE+4]]:17: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  52. // CHECK:STDERR: var unused a: array(i32, F(N)) = (0, 1, 2);
  53. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  54. // CHECK:STDERR:
  55. var unused a: array(i32, F(N)) = (0, 1, 2);
  56. }
  57. fn H() { G(3); }
  58. // --- fail_todo_dependent_call_type.carbon
  59. library "[[@TEST_NAME]]";
  60. class C {}
  61. eval fn F(_: i32) -> type {
  62. return C;
  63. }
  64. fn UseFGenerically(X:! i32) {
  65. // CHECK:STDERR: fail_todo_dependent_call_type.carbon:[[@LINE+12]]:3: error: member name of type `<dependent type>` in compound member access is not an instance member or an interface member [CompoundMemberAccessDoesNotUseBase]
  66. // CHECK:STDERR: var unused v: F(X) = {};
  67. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  68. // CHECK:STDERR:
  69. // CHECK:STDERR: fail_todo_dependent_call_type.carbon:[[@LINE+8]]:3: error: value of type `<dependent type>` is not callable [CallToNonCallable]
  70. // CHECK:STDERR: var unused v: F(X) = {};
  71. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  72. // CHECK:STDERR:
  73. // CHECK:STDERR: fail_todo_dependent_call_type.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Core.Destroy` in type `<cannot stringify inst7C00018B: {kind: Call, arg0: inst7C00003E, arg1: inst_block7C00008A, type: type(TypeType)}>` that does not implement that interface [MissingImplInMemberAccess]
  74. // CHECK:STDERR: var unused v: F(X) = {};
  75. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  76. // CHECK:STDERR:
  77. var unused v: F(X) = {};
  78. }
  79. fn UseFSpecifically() {
  80. UseFGenerically(3);
  81. }
  82. // --- return_in_place_discarded.carbon
  83. library "[[@TEST_NAME]]";
  84. eval fn F() -> (i32, i32, i32) { return (1, 2, 3); }
  85. fn G() {
  86. //@dump-sem-ir-begin
  87. F();
  88. //@dump-sem-ir-end
  89. }
  90. // --- return_in_place_init.carbon
  91. library "[[@TEST_NAME]]";
  92. eval fn F() -> (i32, i32, i32) { return (1, 2, 3); }
  93. fn G() {
  94. //@dump-sem-ir-begin
  95. var unused a: (i32, i32, i32) = F();
  96. //@dump-sem-ir-end
  97. }
  98. // --- fail_todo_return_in_place_tuple.carbon
  99. library "[[@TEST_NAME]]";
  100. //@dump-sem-ir-begin
  101. eval fn F() -> (i32, i32, i32) { return (1, 2, 3); }
  102. //@dump-sem-ir-end
  103. eval fn G(v: (i32, i32, i32)) -> i32 { return v.1; }
  104. fn H() {
  105. // TODO: The call to the function is a constant, but the `temporary` instruction wrapping it is not.
  106. //@dump-sem-ir-begin
  107. // CHECK:STDERR: fail_todo_return_in_place_tuple.carbon:[[@LINE+4]]:28: error: array bound is not a constant [InvalidArrayExpr]
  108. // CHECK:STDERR: var unused a: array(i32, G(F())) = (1, 2);
  109. // CHECK:STDERR: ^~~~~~
  110. // CHECK:STDERR:
  111. var unused a: array(i32, G(F())) = (1, 2);
  112. //@dump-sem-ir-end
  113. }
  114. // --- return_in_place_class.carbon
  115. library "[[@TEST_NAME]]";
  116. class C {}
  117. //@dump-sem-ir-begin
  118. eval fn F() -> C { return {}; }
  119. //@dump-sem-ir-end
  120. fn G(_:! C) {}
  121. fn H() {
  122. //@dump-sem-ir-begin
  123. G(F());
  124. //@dump-sem-ir-end
  125. }
  126. // CHECK:STDOUT: --- return_in_place_discarded.carbon
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: constants {
  129. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  130. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  131. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  132. // CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [concrete]
  133. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  134. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  135. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  136. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  137. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  138. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  139. // CHECK:STDOUT: %tuple.ee6: %tuple.type.189 = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
  140. // CHECK:STDOUT: %.43f: ref %tuple.type.189 = temporary invalid, %tuple.ee6 [concrete]
  141. // CHECK:STDOUT: %Destroy.Op.type.bae255.3: type = fn_type @Destroy.Op.loc8_5.3 [concrete]
  142. // CHECK:STDOUT: %Destroy.Op.651ba6.3: %Destroy.Op.type.bae255.3 = struct_value () [concrete]
  143. // CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %.43f, %Destroy.Op.651ba6.3 [concrete]
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: fn @G() {
  147. // CHECK:STDOUT: !entry:
  148. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  149. // CHECK:STDOUT: %.loc8_5.1: ref %tuple.type.189 = temporary_storage
  150. // CHECK:STDOUT: %F.call: init %tuple.type.189 to %.loc8_5.1 = call %F.ref() [concrete = constants.%tuple.ee6]
  151. // CHECK:STDOUT: %.loc8_5.2: ref %tuple.type.189 = temporary %.loc8_5.1, %F.call [concrete = constants.%.43f]
  152. // CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.43f)
  153. // CHECK:STDOUT: <elided>
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: fn @Destroy.Op.loc8_5.1(%self.param: ref %i32.builtin) = "no_op";
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: fn @Destroy.Op.loc8_5.2(%self.param: ref %i32) {
  159. // CHECK:STDOUT: !entry:
  160. // CHECK:STDOUT: return
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: fn @Destroy.Op.loc8_5.3(%self.param: ref %tuple.type.189) {
  164. // CHECK:STDOUT: !entry:
  165. // CHECK:STDOUT: return
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: --- return_in_place_init.carbon
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: constants {
  171. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  172. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  173. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  174. // CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
  175. // CHECK:STDOUT: %tuple.e64: %tuple.type.ff9 = tuple_value (%i32, %i32, %i32) [concrete]
  176. // CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [concrete]
  177. // CHECK:STDOUT: %pattern_type.b5a: type = pattern_type %tuple.type.189 [concrete]
  178. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  179. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  180. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  181. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  182. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  183. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  184. // CHECK:STDOUT: %tuple.ee6: %tuple.type.189 = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
  185. // CHECK:STDOUT: %Destroy.Op.type.bae255.3: type = fn_type @Destroy.Op.loc8_3.3 [concrete]
  186. // CHECK:STDOUT: %Destroy.Op.651ba6.3: %Destroy.Op.type.bae255.3 = struct_value () [concrete]
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: fn @G() {
  190. // CHECK:STDOUT: !entry:
  191. // CHECK:STDOUT: name_binding_decl {
  192. // CHECK:STDOUT: %a.patt: %pattern_type.b5a = ref_binding_pattern a [concrete]
  193. // CHECK:STDOUT: %a.var_patt: %pattern_type.b5a = var_pattern %a.patt [concrete]
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT: %a.var: ref %tuple.type.189 = var %a.var_patt
  196. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  197. // CHECK:STDOUT: %.loc8_3: ref %tuple.type.189 = splice_block %a.var {}
  198. // CHECK:STDOUT: %F.call: init %tuple.type.189 to %.loc8_3 = call %F.ref() [concrete = constants.%tuple.ee6]
  199. // CHECK:STDOUT: assign %a.var, %F.call
  200. // CHECK:STDOUT: %.loc8_31.1: type = splice_block %.loc8_31.3 [concrete = constants.%tuple.type.189] {
  201. // CHECK:STDOUT: %i32.loc8_18: type = type_literal constants.%i32 [concrete = constants.%i32]
  202. // CHECK:STDOUT: %i32.loc8_23: type = type_literal constants.%i32 [concrete = constants.%i32]
  203. // CHECK:STDOUT: %i32.loc8_28: type = type_literal constants.%i32 [concrete = constants.%i32]
  204. // CHECK:STDOUT: %.loc8_31.2: %tuple.type.ff9 = tuple_literal (%i32.loc8_18, %i32.loc8_23, %i32.loc8_28) [concrete = constants.%tuple.e64]
  205. // CHECK:STDOUT: %.loc8_31.3: type = converted %.loc8_31.2, constants.%tuple.type.189 [concrete = constants.%tuple.type.189]
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT: %a: ref %tuple.type.189 = ref_binding a, %a.var
  208. // CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %a.var, constants.%Destroy.Op.651ba6.3
  209. // CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call %Destroy.Op.bound(%a.var)
  210. // CHECK:STDOUT: <elided>
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: fn @Destroy.Op.loc8_3.1(%self.param: ref %i32.builtin) = "no_op";
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: fn @Destroy.Op.loc8_3.2(%self.param: ref %i32) {
  216. // CHECK:STDOUT: !entry:
  217. // CHECK:STDOUT: return
  218. // CHECK:STDOUT: }
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: fn @Destroy.Op.loc8_3.3(%self.param: ref %tuple.type.189) {
  221. // CHECK:STDOUT: !entry:
  222. // CHECK:STDOUT: return
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: --- fail_todo_return_in_place_tuple.carbon
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: constants {
  228. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  229. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  230. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  231. // CHECK:STDOUT: %tuple.type.ff9: type = tuple_type (type, type, type) [concrete]
  232. // CHECK:STDOUT: %tuple.e64: %tuple.type.ff9 = tuple_value (%i32, %i32, %i32) [concrete]
  233. // CHECK:STDOUT: %tuple.type.189: type = tuple_type (%i32, %i32, %i32) [concrete]
  234. // CHECK:STDOUT: %.074: Core.Form = init_form %tuple.type.189 [concrete]
  235. // CHECK:STDOUT: %pattern_type.b5a: type = pattern_type %tuple.type.189 [concrete]
  236. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  237. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  238. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  239. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  240. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  241. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  242. // CHECK:STDOUT: %tuple.type.37f: type = tuple_type (Core.IntLiteral, Core.IntLiteral, Core.IntLiteral) [concrete]
  243. // CHECK:STDOUT: %tuple.2d5: %tuple.type.37f = tuple_value (%int_1.5b8, %int_2.ecc, %int_3.1ba) [concrete]
  244. // CHECK:STDOUT: %ImplicitAs.type.e8c: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  245. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  246. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  247. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6 = struct_value () [symbolic]
  248. // CHECK:STDOUT: %ImplicitAs.impl_witness.6bc: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.74f, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  249. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  250. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d = struct_value () [concrete]
  251. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.e8c = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.6bc) [concrete]
  252. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b37: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete]
  253. // CHECK:STDOUT: %.545: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.b37, %ImplicitAs.facet [concrete]
  254. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.215: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  255. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  256. // CHECK:STDOUT: %bound_method.38b: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  257. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  258. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.4e5: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  259. // CHECK:STDOUT: %bound_method.646: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  260. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  261. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.061: <bound method> = bound_method %int_3.1ba, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  262. // CHECK:STDOUT: %bound_method.fa7: <bound method> = bound_method %int_3.1ba, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  263. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  264. // CHECK:STDOUT: %tuple.ee6: %tuple.type.189 = tuple_value (%int_1.5d2, %int_2.ef8, %int_3.822) [concrete]
  265. // CHECK:STDOUT: %.43f: ref %tuple.type.189 = temporary invalid, %tuple.ee6 [concrete]
  266. // CHECK:STDOUT: %tuple.type.f94: type = tuple_type (Core.IntLiteral, Core.IntLiteral) [concrete]
  267. // CHECK:STDOUT: %tuple.ad8: %tuple.type.f94 = tuple_value (%int_1.5b8, %int_2.ecc) [concrete]
  268. // CHECK:STDOUT: %Destroy.Op.type.bae255.3: type = fn_type @Destroy.Op.loc17_32.3 [concrete]
  269. // CHECK:STDOUT: %Destroy.Op.651ba6.3: %Destroy.Op.type.bae255.3 = struct_value () [concrete]
  270. // CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %.43f, %Destroy.Op.651ba6.3 [concrete]
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: imports {
  274. // CHECK:STDOUT: %Core.import_ref.42d: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2)]
  275. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.74f = impl_witness_table (%Core.import_ref.42d), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: file {
  279. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  280. // CHECK:STDOUT: %return.param_patt: %pattern_type.b5a = out_param_pattern [concrete]
  281. // CHECK:STDOUT: %return.patt: %pattern_type.b5a = return_slot_pattern %return.param_patt, %.loc5_30.2 [concrete]
  282. // CHECK:STDOUT: } {
  283. // CHECK:STDOUT: %i32.loc5_17: type = type_literal constants.%i32 [concrete = constants.%i32]
  284. // CHECK:STDOUT: %i32.loc5_22: type = type_literal constants.%i32 [concrete = constants.%i32]
  285. // CHECK:STDOUT: %i32.loc5_27: type = type_literal constants.%i32 [concrete = constants.%i32]
  286. // CHECK:STDOUT: %.loc5_30.1: %tuple.type.ff9 = tuple_literal (%i32.loc5_17, %i32.loc5_22, %i32.loc5_27) [concrete = constants.%tuple.e64]
  287. // CHECK:STDOUT: %.loc5_30.2: type = converted %.loc5_30.1, constants.%tuple.type.189 [concrete = constants.%tuple.type.189]
  288. // CHECK:STDOUT: %.loc5_30.3: Core.Form = init_form %.loc5_30.2 [concrete = constants.%.074]
  289. // CHECK:STDOUT: %return.param: ref %tuple.type.189 = out_param call_param0
  290. // CHECK:STDOUT: %return: ref %tuple.type.189 = return_slot %return.param
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: fn @F() -> out %return.param: %tuple.type.189 {
  295. // CHECK:STDOUT: !entry:
  296. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  297. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  298. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  299. // CHECK:STDOUT: %.loc5_49.1: %tuple.type.37f = tuple_literal (%int_1, %int_2, %int_3) [concrete = constants.%tuple.2d5]
  300. // CHECK:STDOUT: %impl.elem0.loc5_49.1: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  301. // CHECK:STDOUT: %bound_method.loc5_49.1: <bound method> = bound_method %int_1, %impl.elem0.loc5_49.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.215]
  302. // CHECK:STDOUT: %specific_fn.loc5_49.1: <specific function> = specific_function %impl.elem0.loc5_49.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  303. // CHECK:STDOUT: %bound_method.loc5_49.2: <bound method> = bound_method %int_1, %specific_fn.loc5_49.1 [concrete = constants.%bound_method.38b]
  304. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5_49.1: init %i32 = call %bound_method.loc5_49.2(%int_1) [concrete = constants.%int_1.5d2]
  305. // CHECK:STDOUT: %.loc5_49.2: init %i32 = converted %int_1, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5_49.1 [concrete = constants.%int_1.5d2]
  306. // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %return.param, element0
  307. // CHECK:STDOUT: %.loc5_49.3: init %i32 to %tuple.elem0 = in_place_init %.loc5_49.2 [concrete = constants.%int_1.5d2]
  308. // CHECK:STDOUT: %impl.elem0.loc5_49.2: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  309. // CHECK:STDOUT: %bound_method.loc5_49.3: <bound method> = bound_method %int_2, %impl.elem0.loc5_49.2 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.4e5]
  310. // CHECK:STDOUT: %specific_fn.loc5_49.2: <specific function> = specific_function %impl.elem0.loc5_49.2, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  311. // CHECK:STDOUT: %bound_method.loc5_49.4: <bound method> = bound_method %int_2, %specific_fn.loc5_49.2 [concrete = constants.%bound_method.646]
  312. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5_49.2: init %i32 = call %bound_method.loc5_49.4(%int_2) [concrete = constants.%int_2.ef8]
  313. // CHECK:STDOUT: %.loc5_49.4: init %i32 = converted %int_2, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5_49.2 [concrete = constants.%int_2.ef8]
  314. // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access %return.param, element1
  315. // CHECK:STDOUT: %.loc5_49.5: init %i32 to %tuple.elem1 = in_place_init %.loc5_49.4 [concrete = constants.%int_2.ef8]
  316. // CHECK:STDOUT: %impl.elem0.loc5_49.3: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  317. // CHECK:STDOUT: %bound_method.loc5_49.5: <bound method> = bound_method %int_3, %impl.elem0.loc5_49.3 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.061]
  318. // CHECK:STDOUT: %specific_fn.loc5_49.3: <specific function> = specific_function %impl.elem0.loc5_49.3, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  319. // CHECK:STDOUT: %bound_method.loc5_49.6: <bound method> = bound_method %int_3, %specific_fn.loc5_49.3 [concrete = constants.%bound_method.fa7]
  320. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5_49.3: init %i32 = call %bound_method.loc5_49.6(%int_3) [concrete = constants.%int_3.822]
  321. // CHECK:STDOUT: %.loc5_49.6: init %i32 = converted %int_3, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc5_49.3 [concrete = constants.%int_3.822]
  322. // CHECK:STDOUT: %tuple.elem2: ref %i32 = tuple_access %return.param, element2
  323. // CHECK:STDOUT: %.loc5_49.7: init %i32 to %tuple.elem2 = in_place_init %.loc5_49.6 [concrete = constants.%int_3.822]
  324. // CHECK:STDOUT: %.loc5_49.8: init %tuple.type.189 to %return.param = tuple_init (%.loc5_49.3, %.loc5_49.5, %.loc5_49.7) [concrete = constants.%tuple.ee6]
  325. // CHECK:STDOUT: %.loc5_50: init %tuple.type.189 = converted %.loc5_49.1, %.loc5_49.8 [concrete = constants.%tuple.ee6]
  326. // CHECK:STDOUT: return %.loc5_50 to %return.param
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: fn @H() {
  330. // CHECK:STDOUT: !entry:
  331. // CHECK:STDOUT: name_binding_decl {
  332. // CHECK:STDOUT: %a.patt: <error> = ref_binding_pattern a [concrete]
  333. // CHECK:STDOUT: %a.var_patt: <error> = var_pattern %a.patt [concrete]
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT: %a.var: ref <error> = var %a.var_patt [concrete = <error>]
  336. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  337. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  338. // CHECK:STDOUT: %.loc17_43: %tuple.type.f94 = tuple_literal (%int_1, %int_2) [concrete = constants.%tuple.ad8]
  339. // CHECK:STDOUT: assign %a.var, <error>
  340. // CHECK:STDOUT: <elided>
  341. // CHECK:STDOUT: %a: ref <error> = ref_binding a, <error> [concrete = <error>]
  342. // CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.43f)
  343. // CHECK:STDOUT: <elided>
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: fn @Destroy.Op.loc17_32.1(%self.param: ref %i32.builtin) = "no_op";
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: fn @Destroy.Op.loc17_32.2(%self.param: ref %i32) {
  349. // CHECK:STDOUT: !entry:
  350. // CHECK:STDOUT: return
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: fn @Destroy.Op.loc17_32.3(%self.param: ref %tuple.type.189) {
  354. // CHECK:STDOUT: !entry:
  355. // CHECK:STDOUT: return
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: --- return_in_place_class.carbon
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: constants {
  361. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  362. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  363. // CHECK:STDOUT: %.a69: Core.Form = init_form %C [concrete]
  364. // CHECK:STDOUT: %pattern_type.7c7: type = pattern_type %C [concrete]
  365. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  366. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  367. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  368. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  369. // CHECK:STDOUT: %C.val: %C = struct_value () [concrete]
  370. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  371. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  372. // CHECK:STDOUT: %.5ea: ref %C = temporary invalid, %C.val [concrete]
  373. // CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G, @G(%C.val) [concrete]
  374. // CHECK:STDOUT: %Destroy.Op.type.bae255.2: type = fn_type @Destroy.Op.loc13_7.2 [concrete]
  375. // CHECK:STDOUT: %Destroy.Op.651ba6.2: %Destroy.Op.type.bae255.2 = struct_value () [concrete]
  376. // CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %.5ea, %Destroy.Op.651ba6.2 [concrete]
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: file {
  380. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  381. // CHECK:STDOUT: %return.param_patt: %pattern_type.7c7 = out_param_pattern [concrete]
  382. // CHECK:STDOUT: %return.patt: %pattern_type.7c7 = return_slot_pattern %return.param_patt, %C.ref [concrete]
  383. // CHECK:STDOUT: } {
  384. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  385. // CHECK:STDOUT: %.loc6_16: Core.Form = init_form %C.ref [concrete = constants.%.a69]
  386. // CHECK:STDOUT: %return.param: ref %C = out_param call_param0
  387. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: fn @F() -> out %return.param: %C {
  392. // CHECK:STDOUT: !entry:
  393. // CHECK:STDOUT: %.loc6_28.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  394. // CHECK:STDOUT: %.loc6_28.2: init %C to %return.param = class_init () [concrete = constants.%C.val]
  395. // CHECK:STDOUT: %.loc6_29: init %C = converted %.loc6_28.1, %.loc6_28.2 [concrete = constants.%C.val]
  396. // CHECK:STDOUT: return %.loc6_29 to %return.param
  397. // CHECK:STDOUT: }
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: fn @H() {
  400. // CHECK:STDOUT: !entry:
  401. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, file.%G.decl [concrete = constants.%G]
  402. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  403. // CHECK:STDOUT: %.loc13_7.1: ref %C = temporary_storage
  404. // CHECK:STDOUT: %F.call: init %C to %.loc13_7.1 = call %F.ref() [concrete = constants.%C.val]
  405. // CHECK:STDOUT: %.loc13_7.2: ref %C = temporary %.loc13_7.1, %F.call [concrete = constants.%.5ea]
  406. // CHECK:STDOUT: %.loc13_7.3: %C = acquire_value %.loc13_7.2 [concrete = constants.%C.val]
  407. // CHECK:STDOUT: %G.specific_fn: <specific function> = specific_function %G.ref, @G(constants.%C.val) [concrete = constants.%G.specific_fn]
  408. // CHECK:STDOUT: %G.call: init %empty_tuple.type = call %G.specific_fn()
  409. // CHECK:STDOUT: %Destroy.Op.call: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.5ea)
  410. // CHECK:STDOUT: <elided>
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: fn @Destroy.Op.loc13_7.1(%self.param: ref %empty_struct_type) = "no_op";
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: fn @Destroy.Op.loc13_7.2(%self.param: ref %C) {
  416. // CHECK:STDOUT: !entry:
  417. // CHECK:STDOUT: return
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT: