compile_time_bindings.carbon 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  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. // This is mostly checking against crashes for compile time bindings in
  6. // difficult contexts.
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/let/compile_time_bindings.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/compile_time_bindings.carbon
  13. // --- fail_let_after.carbon
  14. library "[[@TEST_NAME]]";
  15. class C {
  16. fn F() -> () { return x; }
  17. // CHECK:STDERR: fail_let_after.carbon:[[@LINE+4]]:7: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  18. // CHECK:STDERR: let x:! () = ();
  19. // CHECK:STDERR: ^~~~~~
  20. // CHECK:STDERR:
  21. let x:! () = ();
  22. }
  23. // --- fail_let_before.carbon
  24. library "[[@TEST_NAME]]";
  25. class C {
  26. // CHECK:STDERR: fail_let_before.carbon:[[@LINE+4]]:7: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  27. // CHECK:STDERR: let x:! () = ();
  28. // CHECK:STDERR: ^~~~~~
  29. // CHECK:STDERR:
  30. let x:! () = ();
  31. fn F() -> () { return x; }
  32. }
  33. // --- fail_multiple_lets.carbon
  34. library "[[@TEST_NAME]]";
  35. class C {
  36. // CHECK:STDERR: fail_multiple_lets.carbon:[[@LINE+4]]:7: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  37. // CHECK:STDERR: let a:! () = ();
  38. // CHECK:STDERR: ^~~~~~
  39. // CHECK:STDERR:
  40. let a:! () = ();
  41. fn F(b:! ((),)) {
  42. let c:! ((), ()) = ((), ());
  43. var a1: () = a;
  44. var b1: ((),) = b;
  45. var c1: ((), ()) = c;
  46. var d1: ((), (), ()) = d;
  47. }
  48. // CHECK:STDERR: fail_multiple_lets.carbon:[[@LINE+4]]:7: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  49. // CHECK:STDERR: let d:! ((), (), ()) = ((), (), ());
  50. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  51. // CHECK:STDERR:
  52. let d:! ((), (), ()) = ((), (), ());
  53. }
  54. // --- fail_invalid_let_after.carbon
  55. library "[[@TEST_NAME]]";
  56. class C {
  57. fn F() -> () { return x; }
  58. // CHECK:STDERR: fail_invalid_let_after.carbon:[[@LINE+8]]:7: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  59. // CHECK:STDERR: let x:! ();
  60. // CHECK:STDERR: ^~~~~~
  61. // CHECK:STDERR:
  62. // CHECK:STDERR: fail_invalid_let_after.carbon:[[@LINE+4]]:13: error: expected `=`; `let` declaration must have an initializer [ExpectedInitializerAfterLet]
  63. // CHECK:STDERR: let x:! ();
  64. // CHECK:STDERR: ^
  65. // CHECK:STDERR:
  66. let x:! ();
  67. }
  68. // --- use_in_function.carbon
  69. library "[[@TEST_NAME]]";
  70. fn F() -> i32 {
  71. let Zero:! i32 = 0;
  72. return Zero;
  73. }
  74. // --- use_in_block.carbon
  75. library "[[@TEST_NAME]]";
  76. fn F() -> i32 {
  77. if (true) {
  78. let Zero:! i32 = 0;
  79. return Zero;
  80. }
  81. return 1;
  82. }
  83. // --- fail_return_in_interface.carbon
  84. library "[[@TEST_NAME]]";
  85. interface I {
  86. let T:! type = i32;
  87. // CHECK:STDERR: fail_return_in_interface.carbon:[[@LINE+7]]:13: error: cannot implicitly convert from `<associated type in I>` to `type` [ImplicitAsConversionFailure]
  88. // CHECK:STDERR: fn F() -> T;
  89. // CHECK:STDERR: ^
  90. // CHECK:STDERR: fail_return_in_interface.carbon:[[@LINE+4]]:13: note: type `<associated type in I>` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  91. // CHECK:STDERR: fn F() -> T;
  92. // CHECK:STDERR: ^
  93. // CHECK:STDERR:
  94. fn F() -> T;
  95. }
  96. // --- fail_return_in_class.carbon
  97. library "[[@TEST_NAME]]";
  98. class I {
  99. // CHECK:STDERR: fail_return_in_class.carbon:[[@LINE+4]]:7: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  100. // CHECK:STDERR: let T:! type = i32;
  101. // CHECK:STDERR: ^~~~~~~~
  102. // CHECK:STDERR:
  103. let T:! type = i32;
  104. // CHECK:STDERR: fail_return_in_class.carbon:[[@LINE+4]]:13: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  105. // CHECK:STDERR: fn F() -> T;
  106. // CHECK:STDERR: ^
  107. // CHECK:STDERR:
  108. fn F() -> T;
  109. }
  110. // --- fail_return_in_package_scope.carbon
  111. library "[[@TEST_NAME]]";
  112. // CHECK:STDERR: fail_return_in_package_scope.carbon:[[@LINE+4]]:5: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  113. // CHECK:STDERR: let T:! type = i32;
  114. // CHECK:STDERR: ^~~~~~~~
  115. // CHECK:STDERR:
  116. let T:! type = i32;
  117. // CHECK:STDERR: fail_return_in_package_scope.carbon:[[@LINE+4]]:11: error: cannot evaluate type expression [TypeExprEvaluationFailure]
  118. // CHECK:STDERR: fn F() -> T;
  119. // CHECK:STDERR: ^
  120. // CHECK:STDERR:
  121. fn F() -> T;
  122. // --- fail_use_in_impl.carbon
  123. library "[[@TEST_NAME]]";
  124. interface Empty {}
  125. impl i32 as Empty {
  126. // CHECK:STDERR: fail_use_in_impl.carbon:[[@LINE+3]]:7: error: semantics TODO: ``let` compile time binding outside function or interface` [SemanticsTodo]
  127. // CHECK:STDERR: let Zero:! i32 = 0;
  128. // CHECK:STDERR: ^~~~~~~~~~
  129. let Zero:! i32 = 0;
  130. }
  131. // CHECK:STDOUT: --- fail_let_after.carbon
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: constants {
  134. // CHECK:STDOUT: %C: type = class_type @C [template]
  135. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  136. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  137. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  138. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  139. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  140. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: imports {
  144. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  145. // CHECK:STDOUT: import Core//prelude
  146. // CHECK:STDOUT: import Core//prelude/...
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: file {
  151. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  152. // CHECK:STDOUT: .Core = imports.%Core
  153. // CHECK:STDOUT: .C = %C.decl
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: %Core.import = import Core
  156. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: class @C {
  160. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  161. // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern
  162. // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, runtime_param0
  163. // CHECK:STDOUT: } {
  164. // CHECK:STDOUT: %.loc5_14.1: %empty_tuple.type = tuple_literal ()
  165. // CHECK:STDOUT: %.loc5_14.2: type = converted %.loc5_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  166. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param0
  167. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: %.loc10_17: %empty_tuple.type = tuple_literal ()
  170. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  171. // CHECK:STDOUT: %.loc10_18: %empty_tuple.type = converted %.loc10_17, %empty_tuple [template = constants.%empty_tuple]
  172. // CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc10_18
  173. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: !members:
  176. // CHECK:STDOUT: .Self = constants.%C
  177. // CHECK:STDOUT: .F = %F.decl
  178. // CHECK:STDOUT: .x = %x
  179. // CHECK:STDOUT: complete_type_witness = %complete_type
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: fn @F() -> %empty_tuple.type {
  183. // CHECK:STDOUT: !entry:
  184. // CHECK:STDOUT: %x.ref: %empty_tuple.type = name_ref x, @C.%x
  185. // CHECK:STDOUT: return %x.ref
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: --- fail_let_before.carbon
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: constants {
  191. // CHECK:STDOUT: %C: type = class_type @C [template]
  192. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  193. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  194. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  195. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  196. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  197. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: imports {
  201. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  202. // CHECK:STDOUT: import Core//prelude
  203. // CHECK:STDOUT: import Core//prelude/...
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: file {
  208. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  209. // CHECK:STDOUT: .Core = imports.%Core
  210. // CHECK:STDOUT: .C = %C.decl
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT: %Core.import = import Core
  213. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: class @C {
  217. // CHECK:STDOUT: %.loc9_17: %empty_tuple.type = tuple_literal ()
  218. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  219. // CHECK:STDOUT: %.loc9_18: %empty_tuple.type = converted %.loc9_17, %empty_tuple [template = constants.%empty_tuple]
  220. // CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, %.loc9_18
  221. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  222. // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern
  223. // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, runtime_param0
  224. // CHECK:STDOUT: } {
  225. // CHECK:STDOUT: %.loc10_14.1: %empty_tuple.type = tuple_literal ()
  226. // CHECK:STDOUT: %.loc10_14.2: type = converted %.loc10_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  227. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param0
  228. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: !members:
  233. // CHECK:STDOUT: .Self = constants.%C
  234. // CHECK:STDOUT: .x = %x
  235. // CHECK:STDOUT: .F = %F.decl
  236. // CHECK:STDOUT: complete_type_witness = %complete_type
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: fn @F() -> %empty_tuple.type {
  240. // CHECK:STDOUT: !entry:
  241. // CHECK:STDOUT: %x.ref: %empty_tuple.type = name_ref x, @C.%x
  242. // CHECK:STDOUT: return %x.ref
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: --- fail_multiple_lets.carbon
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: constants {
  248. // CHECK:STDOUT: %C: type = class_type @C [template]
  249. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  250. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  251. // CHECK:STDOUT: %tuple.type.9fb: type = tuple_type (%empty_tuple.type) [template]
  252. // CHECK:STDOUT: %b: %tuple.type.9fb = bind_symbolic_name b, 0 [symbolic]
  253. // CHECK:STDOUT: %b.patt: %tuple.type.9fb = symbolic_binding_pattern b, 0 [symbolic]
  254. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  255. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  256. // CHECK:STDOUT: %tuple.type.2d5: type = tuple_type (%empty_tuple.type, %empty_tuple.type, %empty_tuple.type) [template]
  257. // CHECK:STDOUT: %tuple.7e4: %tuple.type.2d5 = tuple_value (%empty_tuple, %empty_tuple, %empty_tuple) [template]
  258. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  259. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  260. // CHECK:STDOUT: %tuple.type.bcd: type = tuple_type (%empty_tuple.type, %empty_tuple.type) [template]
  261. // CHECK:STDOUT: %tuple.d8f: %tuple.type.bcd = tuple_value (%empty_tuple, %empty_tuple) [template]
  262. // CHECK:STDOUT: %c: %tuple.type.bcd = bind_symbolic_name c, 1 [symbolic]
  263. // CHECK:STDOUT: %tuple.elem0.98f: %empty_tuple.type = tuple_access %b, element0 [symbolic]
  264. // CHECK:STDOUT: %tuple.f41: %tuple.type.9fb = tuple_value (%empty_tuple) [template]
  265. // CHECK:STDOUT: %tuple.elem0.11f: %empty_tuple.type = tuple_access %c, element0 [symbolic]
  266. // CHECK:STDOUT: %tuple.elem1: %empty_tuple.type = tuple_access %c, element1 [symbolic]
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: imports {
  270. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  271. // CHECK:STDOUT: import Core//prelude
  272. // CHECK:STDOUT: import Core//prelude/...
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: file {
  277. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  278. // CHECK:STDOUT: .Core = imports.%Core
  279. // CHECK:STDOUT: .C = %C.decl
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT: %Core.import = import Core
  282. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  283. // CHECK:STDOUT: }
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: class @C {
  286. // CHECK:STDOUT: %.loc9_17: %empty_tuple.type = tuple_literal ()
  287. // CHECK:STDOUT: %empty_tuple.loc9: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  288. // CHECK:STDOUT: %.loc9_18: %empty_tuple.type = converted %.loc9_17, %empty_tuple.loc9 [template = constants.%empty_tuple]
  289. // CHECK:STDOUT: %a: %empty_tuple.type = bind_name a, %.loc9_18
  290. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  291. // CHECK:STDOUT: %b.patt.loc10_8.2: %tuple.type.9fb = symbolic_binding_pattern b, 0 [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)]
  292. // CHECK:STDOUT: %b.param_patt: %tuple.type.9fb = value_param_pattern %b.patt.loc10_8.2, runtime_param<invalid> [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)]
  293. // CHECK:STDOUT: } {
  294. // CHECK:STDOUT: %b.param: %tuple.type.9fb = value_param runtime_param<invalid>
  295. // CHECK:STDOUT: %.loc10_16.1: type = splice_block %.loc10_16.4 [template = constants.%tuple.type.9fb] {
  296. // CHECK:STDOUT: %.loc10_14: %empty_tuple.type = tuple_literal ()
  297. // CHECK:STDOUT: %.loc10_16.2: %tuple.type.9fb = tuple_literal (%.loc10_14)
  298. // CHECK:STDOUT: %.loc10_16.3: type = converted %.loc10_14, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  299. // CHECK:STDOUT: %.loc10_16.4: type = converted %.loc10_16.2, constants.%tuple.type.9fb [template = constants.%tuple.type.9fb]
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT: %b.loc10_8.2: %tuple.type.9fb = bind_symbolic_name b, 0, %b.param [symbolic = %b.loc10_8.1 (constants.%b)]
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %.loc22_28: %empty_tuple.type = tuple_literal ()
  304. // CHECK:STDOUT: %.loc22_32: %empty_tuple.type = tuple_literal ()
  305. // CHECK:STDOUT: %.loc22_36: %empty_tuple.type = tuple_literal ()
  306. // CHECK:STDOUT: %.loc22_37.1: %tuple.type.2d5 = tuple_literal (%.loc22_28, %.loc22_32, %.loc22_36)
  307. // CHECK:STDOUT: %empty_tuple.loc22_28: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  308. // CHECK:STDOUT: %.loc22_37.2: %empty_tuple.type = converted %.loc22_28, %empty_tuple.loc22_28 [template = constants.%empty_tuple]
  309. // CHECK:STDOUT: %empty_tuple.loc22_32: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  310. // CHECK:STDOUT: %.loc22_37.3: %empty_tuple.type = converted %.loc22_32, %empty_tuple.loc22_32 [template = constants.%empty_tuple]
  311. // CHECK:STDOUT: %empty_tuple.loc22_36: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  312. // CHECK:STDOUT: %.loc22_37.4: %empty_tuple.type = converted %.loc22_36, %empty_tuple.loc22_36 [template = constants.%empty_tuple]
  313. // CHECK:STDOUT: %tuple: %tuple.type.2d5 = tuple_value (%.loc22_37.2, %.loc22_37.3, %.loc22_37.4) [template = constants.%tuple.7e4]
  314. // CHECK:STDOUT: %.loc22_38: %tuple.type.2d5 = converted %.loc22_37.1, %tuple [template = constants.%tuple.7e4]
  315. // CHECK:STDOUT: %d: %tuple.type.2d5 = bind_name d, %.loc22_38
  316. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: !members:
  319. // CHECK:STDOUT: .Self = constants.%C
  320. // CHECK:STDOUT: .a = %a
  321. // CHECK:STDOUT: .F = %F.decl
  322. // CHECK:STDOUT: .d = %d
  323. // CHECK:STDOUT: complete_type_witness = %complete_type
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: generic fn @F(%b.loc10_8.2: %tuple.type.9fb) {
  327. // CHECK:STDOUT: %b.loc10_8.1: %tuple.type.9fb = bind_symbolic_name b, 0 [symbolic = %b.loc10_8.1 (constants.%b)]
  328. // CHECK:STDOUT: %b.patt.loc10_8.1: %tuple.type.9fb = symbolic_binding_pattern b, 0 [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)]
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: !definition:
  331. // CHECK:STDOUT: %c.loc11_9.2: %tuple.type.bcd = bind_symbolic_name c, 1 [symbolic = %c.loc11_9.2 (constants.%c)]
  332. // CHECK:STDOUT: %tuple.elem0.loc14_21.3: %empty_tuple.type = tuple_access %b.loc10_8.1, element0 [symbolic = %tuple.elem0.loc14_21.3 (constants.%tuple.elem0.98f)]
  333. // CHECK:STDOUT: %tuple.elem0.loc15_24.3: %empty_tuple.type = tuple_access %c.loc11_9.2, element0 [symbolic = %tuple.elem0.loc15_24.3 (constants.%tuple.elem0.11f)]
  334. // CHECK:STDOUT: %tuple.elem1.loc15_24.3: %empty_tuple.type = tuple_access %c.loc11_9.2, element1 [symbolic = %tuple.elem1.loc15_24.3 (constants.%tuple.elem1)]
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: fn(%b.param_patt: %tuple.type.9fb) {
  337. // CHECK:STDOUT: !entry:
  338. // CHECK:STDOUT: %.loc11_26: %empty_tuple.type = tuple_literal ()
  339. // CHECK:STDOUT: %.loc11_30: %empty_tuple.type = tuple_literal ()
  340. // CHECK:STDOUT: %.loc11_31.1: %tuple.type.bcd = tuple_literal (%.loc11_26, %.loc11_30)
  341. // CHECK:STDOUT: %empty_tuple.loc11_26: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  342. // CHECK:STDOUT: %.loc11_31.2: %empty_tuple.type = converted %.loc11_26, %empty_tuple.loc11_26 [template = constants.%empty_tuple]
  343. // CHECK:STDOUT: %empty_tuple.loc11_30: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  344. // CHECK:STDOUT: %.loc11_31.3: %empty_tuple.type = converted %.loc11_30, %empty_tuple.loc11_30 [template = constants.%empty_tuple]
  345. // CHECK:STDOUT: %tuple: %tuple.type.bcd = tuple_value (%.loc11_31.2, %.loc11_31.3) [template = constants.%tuple.d8f]
  346. // CHECK:STDOUT: %.loc11_32: %tuple.type.bcd = converted %.loc11_31.1, %tuple [template = constants.%tuple.d8f]
  347. // CHECK:STDOUT: %c.loc11_9.1: %tuple.type.bcd = bind_symbolic_name c, 1, %.loc11_32 [symbolic = %c.loc11_9.2 (constants.%c)]
  348. // CHECK:STDOUT: %a1.var: ref %empty_tuple.type = var a1
  349. // CHECK:STDOUT: %a1: ref %empty_tuple.type = bind_name a1, %a1.var
  350. // CHECK:STDOUT: %a.ref: %empty_tuple.type = name_ref a, @C.%a
  351. // CHECK:STDOUT: %.loc13_18: init %empty_tuple.type = tuple_init () to %a1.var [template = constants.%empty_tuple]
  352. // CHECK:STDOUT: %.loc13_19: init %empty_tuple.type = converted %a.ref, %.loc13_18 [template = constants.%empty_tuple]
  353. // CHECK:STDOUT: assign %a1.var, %.loc13_19
  354. // CHECK:STDOUT: %b1.var: ref %tuple.type.9fb = var b1
  355. // CHECK:STDOUT: %b1: ref %tuple.type.9fb = bind_name b1, %b1.var
  356. // CHECK:STDOUT: %b.ref: %tuple.type.9fb = name_ref b, %b.loc10_8.2 [symbolic = %b.loc10_8.1 (constants.%b)]
  357. // CHECK:STDOUT: %tuple.elem0.loc14_21.1: %empty_tuple.type = tuple_access %b.ref, element0 [symbolic = %tuple.elem0.loc14_21.3 (constants.%tuple.elem0.98f)]
  358. // CHECK:STDOUT: %tuple.elem0.loc14_21.2: ref %empty_tuple.type = tuple_access %b1.var, element0
  359. // CHECK:STDOUT: %.loc14_21.1: init %empty_tuple.type = tuple_init () to %tuple.elem0.loc14_21.2 [template = constants.%empty_tuple]
  360. // CHECK:STDOUT: %.loc14_21.2: init %empty_tuple.type = converted %tuple.elem0.loc14_21.1, %.loc14_21.1 [template = constants.%empty_tuple]
  361. // CHECK:STDOUT: %.loc14_21.3: init %tuple.type.9fb = tuple_init (%.loc14_21.2) to %b1.var [template = constants.%tuple.f41]
  362. // CHECK:STDOUT: %.loc14_22: init %tuple.type.9fb = converted %b.ref, %.loc14_21.3 [template = constants.%tuple.f41]
  363. // CHECK:STDOUT: assign %b1.var, %.loc14_22
  364. // CHECK:STDOUT: %c1.var: ref %tuple.type.bcd = var c1
  365. // CHECK:STDOUT: %c1: ref %tuple.type.bcd = bind_name c1, %c1.var
  366. // CHECK:STDOUT: %c.ref: %tuple.type.bcd = name_ref c, %c.loc11_9.1 [symbolic = %c.loc11_9.2 (constants.%c)]
  367. // CHECK:STDOUT: %tuple.elem0.loc15_24.1: %empty_tuple.type = tuple_access %c.ref, element0 [symbolic = %tuple.elem0.loc15_24.3 (constants.%tuple.elem0.11f)]
  368. // CHECK:STDOUT: %tuple.elem0.loc15_24.2: ref %empty_tuple.type = tuple_access %c1.var, element0
  369. // CHECK:STDOUT: %.loc15_24.1: init %empty_tuple.type = tuple_init () to %tuple.elem0.loc15_24.2 [template = constants.%empty_tuple]
  370. // CHECK:STDOUT: %.loc15_24.2: init %empty_tuple.type = converted %tuple.elem0.loc15_24.1, %.loc15_24.1 [template = constants.%empty_tuple]
  371. // CHECK:STDOUT: %tuple.elem1.loc15_24.1: %empty_tuple.type = tuple_access %c.ref, element1 [symbolic = %tuple.elem1.loc15_24.3 (constants.%tuple.elem1)]
  372. // CHECK:STDOUT: %tuple.elem1.loc15_24.2: ref %empty_tuple.type = tuple_access %c1.var, element1
  373. // CHECK:STDOUT: %.loc15_24.3: init %empty_tuple.type = tuple_init () to %tuple.elem1.loc15_24.2 [template = constants.%empty_tuple]
  374. // CHECK:STDOUT: %.loc15_24.4: init %empty_tuple.type = converted %tuple.elem1.loc15_24.1, %.loc15_24.3 [template = constants.%empty_tuple]
  375. // CHECK:STDOUT: %.loc15_24.5: init %tuple.type.bcd = tuple_init (%.loc15_24.2, %.loc15_24.4) to %c1.var [template = constants.%tuple.d8f]
  376. // CHECK:STDOUT: %.loc15_25: init %tuple.type.bcd = converted %c.ref, %.loc15_24.5 [template = constants.%tuple.d8f]
  377. // CHECK:STDOUT: assign %c1.var, %.loc15_25
  378. // CHECK:STDOUT: %d1.var: ref %tuple.type.2d5 = var d1
  379. // CHECK:STDOUT: %d1: ref %tuple.type.2d5 = bind_name d1, %d1.var
  380. // CHECK:STDOUT: %d.ref: %tuple.type.2d5 = name_ref d, @C.%d
  381. // CHECK:STDOUT: %tuple.elem0.loc16_28.1: %empty_tuple.type = tuple_access %d.ref, element0
  382. // CHECK:STDOUT: %tuple.elem0.loc16_28.2: ref %empty_tuple.type = tuple_access %d1.var, element0
  383. // CHECK:STDOUT: %.loc16_28.1: init %empty_tuple.type = tuple_init () to %tuple.elem0.loc16_28.2 [template = constants.%empty_tuple]
  384. // CHECK:STDOUT: %.loc16_28.2: init %empty_tuple.type = converted %tuple.elem0.loc16_28.1, %.loc16_28.1 [template = constants.%empty_tuple]
  385. // CHECK:STDOUT: %tuple.elem1.loc16_28.1: %empty_tuple.type = tuple_access %d.ref, element1
  386. // CHECK:STDOUT: %tuple.elem1.loc16_28.2: ref %empty_tuple.type = tuple_access %d1.var, element1
  387. // CHECK:STDOUT: %.loc16_28.3: init %empty_tuple.type = tuple_init () to %tuple.elem1.loc16_28.2 [template = constants.%empty_tuple]
  388. // CHECK:STDOUT: %.loc16_28.4: init %empty_tuple.type = converted %tuple.elem1.loc16_28.1, %.loc16_28.3 [template = constants.%empty_tuple]
  389. // CHECK:STDOUT: %tuple.elem2.loc16_28.1: %empty_tuple.type = tuple_access %d.ref, element2
  390. // CHECK:STDOUT: %tuple.elem2.loc16_28.2: ref %empty_tuple.type = tuple_access %d1.var, element2
  391. // CHECK:STDOUT: %.loc16_28.5: init %empty_tuple.type = tuple_init () to %tuple.elem2.loc16_28.2 [template = constants.%empty_tuple]
  392. // CHECK:STDOUT: %.loc16_28.6: init %empty_tuple.type = converted %tuple.elem2.loc16_28.1, %.loc16_28.5 [template = constants.%empty_tuple]
  393. // CHECK:STDOUT: %.loc16_28.7: init %tuple.type.2d5 = tuple_init (%.loc16_28.2, %.loc16_28.4, %.loc16_28.6) to %d1.var [template = constants.%tuple.7e4]
  394. // CHECK:STDOUT: %.loc16_29: init %tuple.type.2d5 = converted %d.ref, %.loc16_28.7 [template = constants.%tuple.7e4]
  395. // CHECK:STDOUT: assign %d1.var, %.loc16_29
  396. // CHECK:STDOUT: return
  397. // CHECK:STDOUT: }
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: specific @F(constants.%b) {
  401. // CHECK:STDOUT: %b.loc10_8.1 => constants.%b
  402. // CHECK:STDOUT: %b.patt.loc10_8.1 => constants.%b
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: --- fail_invalid_let_after.carbon
  406. // CHECK:STDOUT:
  407. // CHECK:STDOUT: constants {
  408. // CHECK:STDOUT: %C: type = class_type @C [template]
  409. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  410. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  411. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  412. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  413. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  414. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: imports {
  418. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  419. // CHECK:STDOUT: import Core//prelude
  420. // CHECK:STDOUT: import Core//prelude/...
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: file {
  425. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  426. // CHECK:STDOUT: .Core = imports.%Core
  427. // CHECK:STDOUT: .C = %C.decl
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT: %Core.import = import Core
  430. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: class @C {
  434. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  435. // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern
  436. // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, runtime_param0
  437. // CHECK:STDOUT: } {
  438. // CHECK:STDOUT: %.loc5_14.1: %empty_tuple.type = tuple_literal ()
  439. // CHECK:STDOUT: %.loc5_14.2: type = converted %.loc5_14.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  440. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param runtime_param0
  441. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  442. // CHECK:STDOUT: }
  443. // CHECK:STDOUT: %x: %empty_tuple.type = bind_name x, <error>
  444. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: !members:
  447. // CHECK:STDOUT: .Self = constants.%C
  448. // CHECK:STDOUT: .F = %F.decl
  449. // CHECK:STDOUT: .x = %x
  450. // CHECK:STDOUT: complete_type_witness = %complete_type
  451. // CHECK:STDOUT: }
  452. // CHECK:STDOUT:
  453. // CHECK:STDOUT: fn @F() -> %empty_tuple.type {
  454. // CHECK:STDOUT: !entry:
  455. // CHECK:STDOUT: %x.ref: %empty_tuple.type = name_ref x, @C.%x
  456. // CHECK:STDOUT: %tuple: %empty_tuple.type = tuple_value () [template = constants.%empty_tuple]
  457. // CHECK:STDOUT: %.loc5_26: %empty_tuple.type = converted %x.ref, %tuple [template = constants.%empty_tuple]
  458. // CHECK:STDOUT: return %.loc5_26
  459. // CHECK:STDOUT: }
  460. // CHECK:STDOUT:
  461. // CHECK:STDOUT: --- use_in_function.carbon
  462. // CHECK:STDOUT:
  463. // CHECK:STDOUT: constants {
  464. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  465. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  466. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  467. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  468. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template]
  469. // CHECK:STDOUT: %Convert.type.cd1: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  470. // CHECK:STDOUT: %impl_witness.5b0: <witness> = impl_witness (imports.%import_ref.723), @impl.1(%int_32) [template]
  471. // CHECK:STDOUT: %Convert.type.466: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  472. // CHECK:STDOUT: %Convert.925: %Convert.type.466 = struct_value () [template]
  473. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.5c6, %Convert.925 [template]
  474. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  475. // CHECK:STDOUT: %int_0.f61: %i32 = int_value 0 [template]
  476. // CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0 [symbolic]
  477. // CHECK:STDOUT: }
  478. // CHECK:STDOUT:
  479. // CHECK:STDOUT: imports {
  480. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  481. // CHECK:STDOUT: .Int = %import_ref.187
  482. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  483. // CHECK:STDOUT: import Core//prelude
  484. // CHECK:STDOUT: import Core//prelude/...
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT:
  488. // CHECK:STDOUT: file {
  489. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  490. // CHECK:STDOUT: .Core = imports.%Core
  491. // CHECK:STDOUT: .F = %F.decl
  492. // CHECK:STDOUT: }
  493. // CHECK:STDOUT: %Core.import = import Core
  494. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  495. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  496. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  497. // CHECK:STDOUT: } {
  498. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  499. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  500. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  501. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT: }
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: fn @F() -> %i32 {
  506. // CHECK:STDOUT: !entry:
  507. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  508. // CHECK:STDOUT: %impl.elem0: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  509. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  510. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  511. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.f61]
  512. // CHECK:STDOUT: %.loc5_21.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.f61]
  513. // CHECK:STDOUT: %.loc5_21.2: %i32 = converted %int_0, %.loc5_21.1 [template = constants.%int_0.f61]
  514. // CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0, %.loc5_21.2 [symbolic = constants.%Zero]
  515. // CHECK:STDOUT: %Zero.ref: %i32 = name_ref Zero, %Zero [symbolic = constants.%Zero]
  516. // CHECK:STDOUT: return %Zero.ref
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT:
  519. // CHECK:STDOUT: --- use_in_block.carbon
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: constants {
  522. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  523. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  524. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  525. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  526. // CHECK:STDOUT: %true: bool = bool_literal true [template]
  527. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template]
  528. // CHECK:STDOUT: %Convert.type.cd1: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  529. // CHECK:STDOUT: %impl_witness.5b0: <witness> = impl_witness (imports.%import_ref.723), @impl.1(%int_32) [template]
  530. // CHECK:STDOUT: %Convert.type.466: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  531. // CHECK:STDOUT: %Convert.925: %Convert.type.466 = struct_value () [template]
  532. // CHECK:STDOUT: %Convert.bound.b41: <bound method> = bound_method %int_0.5c6, %Convert.925 [template]
  533. // CHECK:STDOUT: %Convert.specific_fn.c35: <specific function> = specific_function %Convert.bound.b41, @Convert.2(%int_32) [template]
  534. // CHECK:STDOUT: %int_0.f61: %i32 = int_value 0 [template]
  535. // CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0 [symbolic]
  536. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  537. // CHECK:STDOUT: %Convert.bound.afd: <bound method> = bound_method %int_1.5b8, %Convert.925 [template]
  538. // CHECK:STDOUT: %Convert.specific_fn.b73: <specific function> = specific_function %Convert.bound.afd, @Convert.2(%int_32) [template]
  539. // CHECK:STDOUT: %int_1.c60: %i32 = int_value 1 [template]
  540. // CHECK:STDOUT: }
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: imports {
  543. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  544. // CHECK:STDOUT: .Int = %import_ref.187
  545. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  546. // CHECK:STDOUT: import Core//prelude
  547. // CHECK:STDOUT: import Core//prelude/...
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: file {
  552. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  553. // CHECK:STDOUT: .Core = imports.%Core
  554. // CHECK:STDOUT: .F = %F.decl
  555. // CHECK:STDOUT: }
  556. // CHECK:STDOUT: %Core.import = import Core
  557. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  558. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  559. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  560. // CHECK:STDOUT: } {
  561. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  562. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  563. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  564. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  565. // CHECK:STDOUT: }
  566. // CHECK:STDOUT: }
  567. // CHECK:STDOUT:
  568. // CHECK:STDOUT: fn @F() -> %i32 {
  569. // CHECK:STDOUT: !entry:
  570. // CHECK:STDOUT: %true: bool = bool_literal true [template = constants.%true]
  571. // CHECK:STDOUT: if %true br !if.then else br !if.else
  572. // CHECK:STDOUT:
  573. // CHECK:STDOUT: !if.then:
  574. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  575. // CHECK:STDOUT: %impl.elem0.loc6: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  576. // CHECK:STDOUT: %Convert.bound.loc6: <bound method> = bound_method %int_0, %impl.elem0.loc6 [template = constants.%Convert.bound.b41]
  577. // CHECK:STDOUT: %Convert.specific_fn.loc6: <specific function> = specific_function %Convert.bound.loc6, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.c35]
  578. // CHECK:STDOUT: %int.convert_checked.loc6: init %i32 = call %Convert.specific_fn.loc6(%int_0) [template = constants.%int_0.f61]
  579. // CHECK:STDOUT: %.loc6_23.1: %i32 = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_0.f61]
  580. // CHECK:STDOUT: %.loc6_23.2: %i32 = converted %int_0, %.loc6_23.1 [template = constants.%int_0.f61]
  581. // CHECK:STDOUT: %Zero: %i32 = bind_symbolic_name Zero, 0, %.loc6_23.2 [symbolic = constants.%Zero]
  582. // CHECK:STDOUT: %Zero.ref: %i32 = name_ref Zero, %Zero [symbolic = constants.%Zero]
  583. // CHECK:STDOUT: return %Zero.ref
  584. // CHECK:STDOUT:
  585. // CHECK:STDOUT: !if.else:
  586. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  587. // CHECK:STDOUT: %impl.elem0.loc9: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  588. // CHECK:STDOUT: %Convert.bound.loc9: <bound method> = bound_method %int_1, %impl.elem0.loc9 [template = constants.%Convert.bound.afd]
  589. // CHECK:STDOUT: %Convert.specific_fn.loc9: <specific function> = specific_function %Convert.bound.loc9, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b73]
  590. // CHECK:STDOUT: %int.convert_checked.loc9: init %i32 = call %Convert.specific_fn.loc9(%int_1) [template = constants.%int_1.c60]
  591. // CHECK:STDOUT: %.loc9_11.1: %i32 = value_of_initializer %int.convert_checked.loc9 [template = constants.%int_1.c60]
  592. // CHECK:STDOUT: %.loc9_11.2: %i32 = converted %int_1, %.loc9_11.1 [template = constants.%int_1.c60]
  593. // CHECK:STDOUT: return %.loc9_11.2
  594. // CHECK:STDOUT: }
  595. // CHECK:STDOUT:
  596. // CHECK:STDOUT: --- fail_return_in_interface.carbon
  597. // CHECK:STDOUT:
  598. // CHECK:STDOUT: constants {
  599. // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
  600. // CHECK:STDOUT: %Self.fb7: %I.type = bind_symbolic_name Self, 0 [symbolic]
  601. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  602. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  603. // CHECK:STDOUT: %assoc_type: type = assoc_entity_type %I.type, type [template]
  604. // CHECK:STDOUT: %assoc0.790: %assoc_type = assoc_entity element0, @I.%T [template]
  605. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  606. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  607. // CHECK:STDOUT: %F.assoc_type: type = assoc_entity_type %I.type, %F.type [template]
  608. // CHECK:STDOUT: %assoc1: %F.assoc_type = assoc_entity element1, @I.%F.decl [template]
  609. // CHECK:STDOUT: }
  610. // CHECK:STDOUT:
  611. // CHECK:STDOUT: imports {
  612. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  613. // CHECK:STDOUT: .Int = %import_ref.187
  614. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  615. // CHECK:STDOUT: import Core//prelude
  616. // CHECK:STDOUT: import Core//prelude/...
  617. // CHECK:STDOUT: }
  618. // CHECK:STDOUT: }
  619. // CHECK:STDOUT:
  620. // CHECK:STDOUT: file {
  621. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  622. // CHECK:STDOUT: .Core = imports.%Core
  623. // CHECK:STDOUT: .I = %I.decl
  624. // CHECK:STDOUT: }
  625. // CHECK:STDOUT: %Core.import = import Core
  626. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  627. // CHECK:STDOUT: }
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: interface @I {
  630. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.fb7]
  631. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  632. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  633. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  634. // CHECK:STDOUT: %assoc0: %assoc_type = assoc_entity element0, %T [template = constants.%assoc0.790]
  635. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  636. // CHECK:STDOUT: %return.patt: <error> = return_slot_pattern
  637. // CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, runtime_param0
  638. // CHECK:STDOUT: } {
  639. // CHECK:STDOUT: %T.ref: %assoc_type = name_ref T, @I.%assoc0 [template = constants.%assoc0.790]
  640. // CHECK:STDOUT: %.loc13: type = converted %T.ref, <error> [template = <error>]
  641. // CHECK:STDOUT: %return.param: ref <error> = out_param runtime_param0
  642. // CHECK:STDOUT: %return: ref <error> = return_slot %return.param
  643. // CHECK:STDOUT: }
  644. // CHECK:STDOUT: %assoc1: %F.assoc_type = assoc_entity element1, %F.decl [template = constants.%assoc1]
  645. // CHECK:STDOUT:
  646. // CHECK:STDOUT: !members:
  647. // CHECK:STDOUT: .Self = %Self
  648. // CHECK:STDOUT: .T = %assoc0
  649. // CHECK:STDOUT: .F = %assoc1
  650. // CHECK:STDOUT: witness = (%T, %F.decl)
  651. // CHECK:STDOUT: }
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: generic fn @F(@I.%Self: %I.type) {
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: fn() -> <error>;
  656. // CHECK:STDOUT: }
  657. // CHECK:STDOUT:
  658. // CHECK:STDOUT: specific @F(constants.%Self.fb7) {}
  659. // CHECK:STDOUT:
  660. // CHECK:STDOUT: --- fail_return_in_class.carbon
  661. // CHECK:STDOUT:
  662. // CHECK:STDOUT: constants {
  663. // CHECK:STDOUT: %I: type = class_type @I [template]
  664. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  665. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  666. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  667. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  668. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  669. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT:
  672. // CHECK:STDOUT: imports {
  673. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  674. // CHECK:STDOUT: .Int = %import_ref.187
  675. // CHECK:STDOUT: import Core//prelude
  676. // CHECK:STDOUT: import Core//prelude/...
  677. // CHECK:STDOUT: }
  678. // CHECK:STDOUT: }
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: file {
  681. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  682. // CHECK:STDOUT: .Core = imports.%Core
  683. // CHECK:STDOUT: .I = %I.decl
  684. // CHECK:STDOUT: }
  685. // CHECK:STDOUT: %Core.import = import Core
  686. // CHECK:STDOUT: %I.decl: type = class_decl @I [template = constants.%I] {} {}
  687. // CHECK:STDOUT: }
  688. // CHECK:STDOUT:
  689. // CHECK:STDOUT: class @I {
  690. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  691. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  692. // CHECK:STDOUT: %T: type = bind_name T, %i32
  693. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  694. // CHECK:STDOUT: %return.patt: <error> = return_slot_pattern
  695. // CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, runtime_param0
  696. // CHECK:STDOUT: } {
  697. // CHECK:STDOUT: %T.ref: type = name_ref T, @I.%T
  698. // CHECK:STDOUT: %return.param: ref <error> = out_param runtime_param0
  699. // CHECK:STDOUT: %return: ref <error> = return_slot %return.param
  700. // CHECK:STDOUT: }
  701. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  702. // CHECK:STDOUT:
  703. // CHECK:STDOUT: !members:
  704. // CHECK:STDOUT: .Self = constants.%I
  705. // CHECK:STDOUT: .T = %T
  706. // CHECK:STDOUT: .F = %F.decl
  707. // CHECK:STDOUT: complete_type_witness = %complete_type
  708. // CHECK:STDOUT: }
  709. // CHECK:STDOUT:
  710. // CHECK:STDOUT: fn @F() -> <error>;
  711. // CHECK:STDOUT:
  712. // CHECK:STDOUT: --- fail_return_in_package_scope.carbon
  713. // CHECK:STDOUT:
  714. // CHECK:STDOUT: constants {
  715. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  716. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  717. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  718. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  719. // CHECK:STDOUT: }
  720. // CHECK:STDOUT:
  721. // CHECK:STDOUT: imports {
  722. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  723. // CHECK:STDOUT: .Int = %import_ref.187
  724. // CHECK:STDOUT: import Core//prelude
  725. // CHECK:STDOUT: import Core//prelude/...
  726. // CHECK:STDOUT: }
  727. // CHECK:STDOUT: }
  728. // CHECK:STDOUT:
  729. // CHECK:STDOUT: file {
  730. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  731. // CHECK:STDOUT: .Core = imports.%Core
  732. // CHECK:STDOUT: .T = @__global_init.%T
  733. // CHECK:STDOUT: .F = %F.decl
  734. // CHECK:STDOUT: }
  735. // CHECK:STDOUT: %Core.import = import Core
  736. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  737. // CHECK:STDOUT: %return.patt: <error> = return_slot_pattern
  738. // CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, runtime_param0
  739. // CHECK:STDOUT: } {
  740. // CHECK:STDOUT: %T.ref: type = name_ref T, @__global_init.%T
  741. // CHECK:STDOUT: %return.param: ref <error> = out_param runtime_param0
  742. // CHECK:STDOUT: %return: ref <error> = return_slot %return.param
  743. // CHECK:STDOUT: }
  744. // CHECK:STDOUT: }
  745. // CHECK:STDOUT:
  746. // CHECK:STDOUT: fn @F() -> <error>;
  747. // CHECK:STDOUT:
  748. // CHECK:STDOUT: fn @__global_init() {
  749. // CHECK:STDOUT: !entry:
  750. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  751. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  752. // CHECK:STDOUT: %T: type = bind_name T, %i32
  753. // CHECK:STDOUT: return
  754. // CHECK:STDOUT: }
  755. // CHECK:STDOUT:
  756. // CHECK:STDOUT: --- fail_use_in_impl.carbon
  757. // CHECK:STDOUT:
  758. // CHECK:STDOUT: constants {
  759. // CHECK:STDOUT: %Empty.type: type = facet_type <@Empty> [template]
  760. // CHECK:STDOUT: %Self.e1a: %Empty.type = bind_symbolic_name Self, 0 [symbolic]
  761. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  762. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  763. // CHECK:STDOUT: %impl_witness.1bc: <witness> = impl_witness () [template]
  764. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template]
  765. // CHECK:STDOUT: %Convert.type.cd1: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  766. // CHECK:STDOUT: %impl_witness.5b0: <witness> = impl_witness (imports.%import_ref.723), @impl.2(%int_32) [template]
  767. // CHECK:STDOUT: %Convert.type.466: type = fn_type @Convert.2, @impl.2(%int_32) [template]
  768. // CHECK:STDOUT: %Convert.925: %Convert.type.466 = struct_value () [template]
  769. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.5c6, %Convert.925 [template]
  770. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  771. // CHECK:STDOUT: %int_0.f61: %i32 = int_value 0 [template]
  772. // CHECK:STDOUT: }
  773. // CHECK:STDOUT:
  774. // CHECK:STDOUT: imports {
  775. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  776. // CHECK:STDOUT: .Int = %import_ref.187
  777. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  778. // CHECK:STDOUT: import Core//prelude
  779. // CHECK:STDOUT: import Core//prelude/...
  780. // CHECK:STDOUT: }
  781. // CHECK:STDOUT: }
  782. // CHECK:STDOUT:
  783. // CHECK:STDOUT: file {
  784. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  785. // CHECK:STDOUT: .Core = imports.%Core
  786. // CHECK:STDOUT: .Empty = %Empty.decl
  787. // CHECK:STDOUT: }
  788. // CHECK:STDOUT: %Core.import = import Core
  789. // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%Empty.type] {} {}
  790. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  791. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  792. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  793. // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, file.%Empty.decl [template = constants.%Empty.type]
  794. // CHECK:STDOUT: }
  795. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness () [template = constants.%impl_witness.1bc]
  796. // CHECK:STDOUT: }
  797. // CHECK:STDOUT:
  798. // CHECK:STDOUT: interface @Empty {
  799. // CHECK:STDOUT: %Self: %Empty.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.e1a]
  800. // CHECK:STDOUT:
  801. // CHECK:STDOUT: !members:
  802. // CHECK:STDOUT: .Self = %Self
  803. // CHECK:STDOUT: witness = ()
  804. // CHECK:STDOUT: }
  805. // CHECK:STDOUT:
  806. // CHECK:STDOUT: impl @impl.1: %i32 as %Empty.ref {
  807. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  808. // CHECK:STDOUT: %impl.elem0: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  809. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  810. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  811. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_0) [template = constants.%int_0.f61]
  812. // CHECK:STDOUT: %.loc10_21.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.f61]
  813. // CHECK:STDOUT: %.loc10_21.2: %i32 = converted %int_0, %.loc10_21.1 [template = constants.%int_0.f61]
  814. // CHECK:STDOUT: %Zero: %i32 = bind_name Zero, %.loc10_21.2
  815. // CHECK:STDOUT:
  816. // CHECK:STDOUT: !members:
  817. // CHECK:STDOUT: .Zero = %Zero
  818. // CHECK:STDOUT: witness = file.%impl_witness
  819. // CHECK:STDOUT: }
  820. // CHECK:STDOUT: