compile_time_bindings.carbon 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  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`
  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`
  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`
  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`
  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`
  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
  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. // --- fail_return_in_interface.carbon
  75. library "[[@TEST_NAME]]";
  76. interface I {
  77. let T:! type = i32;
  78. // CHECK:STDERR: fail_return_in_interface.carbon:[[@LINE+7]]:13: error: cannot implicitly convert from `<associated type in I>` to `type`
  79. // CHECK:STDERR: fn F() -> T;
  80. // CHECK:STDERR: ^
  81. // CHECK:STDERR: fail_return_in_interface.carbon:[[@LINE+4]]:13: note: type `<associated type in I>` does not implement interface `ImplicitAs`
  82. // CHECK:STDERR: fn F() -> T;
  83. // CHECK:STDERR: ^
  84. // CHECK:STDERR:
  85. fn F() -> T;
  86. }
  87. // --- fail_return_in_class.carbon
  88. library "[[@TEST_NAME]]";
  89. class I {
  90. // CHECK:STDERR: fail_return_in_class.carbon:[[@LINE+4]]:7: error: semantics TODO: ``let` compile time binding outside function or interface`
  91. // CHECK:STDERR: let T:! type = i32;
  92. // CHECK:STDERR: ^~~~~~~~
  93. // CHECK:STDERR:
  94. let T:! type = i32;
  95. // CHECK:STDERR: fail_return_in_class.carbon:[[@LINE+4]]:13: error: cannot evaluate type expression
  96. // CHECK:STDERR: fn F() -> T;
  97. // CHECK:STDERR: ^
  98. // CHECK:STDERR:
  99. fn F() -> T;
  100. }
  101. // --- fail_return_in_package_scope.carbon
  102. library "[[@TEST_NAME]]";
  103. // CHECK:STDERR: fail_return_in_package_scope.carbon:[[@LINE+4]]:5: error: semantics TODO: ``let` compile time binding outside function or interface`
  104. // CHECK:STDERR: let T:! type = i32;
  105. // CHECK:STDERR: ^~~~~~~~
  106. // CHECK:STDERR:
  107. let T:! type = i32;
  108. // CHECK:STDERR: fail_return_in_package_scope.carbon:[[@LINE+3]]:11: error: cannot evaluate type expression
  109. // CHECK:STDERR: fn F() -> T;
  110. // CHECK:STDERR: ^
  111. fn F() -> T;
  112. // CHECK:STDOUT: --- fail_let_after.carbon
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: constants {
  115. // CHECK:STDOUT: %C: type = class_type @C [template]
  116. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  117. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  118. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  119. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  120. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  121. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT:
  124. // CHECK:STDOUT: imports {
  125. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  126. // CHECK:STDOUT: import Core//prelude
  127. // CHECK:STDOUT: import Core//prelude/operators
  128. // CHECK:STDOUT: import Core//prelude/types
  129. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  130. // CHECK:STDOUT: import Core//prelude/operators/as
  131. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  132. // CHECK:STDOUT: import Core//prelude/operators/comparison
  133. // CHECK:STDOUT: import Core//prelude/types/bool
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: file {
  138. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  139. // CHECK:STDOUT: .Core = imports.%Core
  140. // CHECK:STDOUT: .C = %C.decl
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %Core.import = import Core
  143. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: class @C {
  147. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  148. // CHECK:STDOUT: %.loc5_14.1: %.1 = tuple_literal ()
  149. // CHECK:STDOUT: %.loc5_14.2: type = converted %.loc5_14.1, constants.%.1 [template = constants.%.1]
  150. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: %.loc10_12.1: %.1 = tuple_literal ()
  153. // CHECK:STDOUT: %.loc10_12.2: type = converted %.loc10_12.1, constants.%.1 [template = constants.%.1]
  154. // CHECK:STDOUT: %.loc10_17: %.1 = tuple_literal ()
  155. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  156. // CHECK:STDOUT: %.loc10_18: %.1 = converted %.loc10_17, %tuple [template = constants.%tuple]
  157. // CHECK:STDOUT: %x: %.1 = bind_name x, %.loc10_18
  158. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.2 [template = constants.%.3]
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: !members:
  161. // CHECK:STDOUT: .Self = constants.%C
  162. // CHECK:STDOUT: .F = %F.decl
  163. // CHECK:STDOUT: .x = %x
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: fn @F() -> %.1 {
  167. // CHECK:STDOUT: !entry:
  168. // CHECK:STDOUT: %x.ref: %.1 = name_ref x, @C.%x
  169. // CHECK:STDOUT: return %x.ref
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: --- fail_let_before.carbon
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: constants {
  175. // CHECK:STDOUT: %C: type = class_type @C [template]
  176. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  177. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  178. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  179. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  180. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  181. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: imports {
  185. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  186. // CHECK:STDOUT: import Core//prelude
  187. // CHECK:STDOUT: import Core//prelude/operators
  188. // CHECK:STDOUT: import Core//prelude/types
  189. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  190. // CHECK:STDOUT: import Core//prelude/operators/as
  191. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  192. // CHECK:STDOUT: import Core//prelude/operators/comparison
  193. // CHECK:STDOUT: import Core//prelude/types/bool
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: file {
  198. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  199. // CHECK:STDOUT: .Core = imports.%Core
  200. // CHECK:STDOUT: .C = %C.decl
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %Core.import = import Core
  203. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  204. // CHECK:STDOUT: }
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: class @C {
  207. // CHECK:STDOUT: %.loc9_12.1: %.1 = tuple_literal ()
  208. // CHECK:STDOUT: %.loc9_12.2: type = converted %.loc9_12.1, constants.%.1 [template = constants.%.1]
  209. // CHECK:STDOUT: %.loc9_17: %.1 = tuple_literal ()
  210. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  211. // CHECK:STDOUT: %.loc9_18: %.1 = converted %.loc9_17, %tuple [template = constants.%tuple]
  212. // CHECK:STDOUT: %x: %.1 = bind_name x, %.loc9_18
  213. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  214. // CHECK:STDOUT: %.loc10_14.1: %.1 = tuple_literal ()
  215. // CHECK:STDOUT: %.loc10_14.2: type = converted %.loc10_14.1, constants.%.1 [template = constants.%.1]
  216. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  217. // CHECK:STDOUT: }
  218. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.2 [template = constants.%.3]
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: !members:
  221. // CHECK:STDOUT: .Self = constants.%C
  222. // CHECK:STDOUT: .x = %x
  223. // CHECK:STDOUT: .F = %F.decl
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: fn @F() -> %.1 {
  227. // CHECK:STDOUT: !entry:
  228. // CHECK:STDOUT: %x.ref: %.1 = name_ref x, @C.%x
  229. // CHECK:STDOUT: return %x.ref
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: --- fail_multiple_lets.carbon
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: constants {
  235. // CHECK:STDOUT: %C: type = class_type @C [template]
  236. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  237. // CHECK:STDOUT: %tuple.1: %.1 = tuple_value () [template]
  238. // CHECK:STDOUT: %.2: type = tuple_type (%.1) [template]
  239. // CHECK:STDOUT: %b: %.2 = bind_symbolic_name b 0 [symbolic]
  240. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  241. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  242. // CHECK:STDOUT: %.3: type = tuple_type (%.1, %.1, %.1) [template]
  243. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  244. // CHECK:STDOUT: %tuple.2: %.3 = tuple_value (%tuple.1, %tuple.1, %tuple.1) [template]
  245. // CHECK:STDOUT: %.5: type = struct_type {} [template]
  246. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %.5 [template]
  247. // CHECK:STDOUT: %.7: type = tuple_type (%.1, %.1) [template]
  248. // CHECK:STDOUT: %.8: type = ptr_type %.7 [template]
  249. // CHECK:STDOUT: %tuple.3: %.7 = tuple_value (%tuple.1, %tuple.1) [template]
  250. // CHECK:STDOUT: %c: %.7 = bind_symbolic_name c 1 [symbolic]
  251. // CHECK:STDOUT: %tuple.4: %.2 = tuple_value (%tuple.1) [template]
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: imports {
  255. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  256. // CHECK:STDOUT: import Core//prelude
  257. // CHECK:STDOUT: import Core//prelude/operators
  258. // CHECK:STDOUT: import Core//prelude/types
  259. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  260. // CHECK:STDOUT: import Core//prelude/operators/as
  261. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  262. // CHECK:STDOUT: import Core//prelude/operators/comparison
  263. // CHECK:STDOUT: import Core//prelude/types/bool
  264. // CHECK:STDOUT: }
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: file {
  268. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  269. // CHECK:STDOUT: .Core = imports.%Core
  270. // CHECK:STDOUT: .C = %C.decl
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT: %Core.import = import Core
  273. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  274. // CHECK:STDOUT: }
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: class @C {
  277. // CHECK:STDOUT: %.loc9_12.1: %.1 = tuple_literal ()
  278. // CHECK:STDOUT: %.loc9_12.2: type = converted %.loc9_12.1, constants.%.1 [template = constants.%.1]
  279. // CHECK:STDOUT: %.loc9_17: %.1 = tuple_literal ()
  280. // CHECK:STDOUT: %tuple.loc9: %.1 = tuple_value () [template = constants.%tuple.1]
  281. // CHECK:STDOUT: %.loc9_18: %.1 = converted %.loc9_17, %tuple.loc9 [template = constants.%tuple.1]
  282. // CHECK:STDOUT: %a: %.1 = bind_name a, %.loc9_18
  283. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  284. // CHECK:STDOUT: %b.patt: %.2 = symbolic_binding_pattern b 0
  285. // CHECK:STDOUT: } {
  286. // CHECK:STDOUT: %.loc10_14: %.1 = tuple_literal ()
  287. // CHECK:STDOUT: %.loc10_16.1: %.2 = tuple_literal (%.loc10_14)
  288. // CHECK:STDOUT: %.loc10_16.2: type = converted %.loc10_14, constants.%.1 [template = constants.%.1]
  289. // CHECK:STDOUT: %.loc10_16.3: type = converted %.loc10_16.1, constants.%.2 [template = constants.%.2]
  290. // CHECK:STDOUT: %b.param: %.2 = param b, runtime_param<invalid>
  291. // CHECK:STDOUT: %b.loc10: %.2 = bind_symbolic_name b 0, %b.param [symbolic = %b.1 (constants.%b)]
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT: %.loc22_13: %.1 = tuple_literal ()
  294. // CHECK:STDOUT: %.loc22_17: %.1 = tuple_literal ()
  295. // CHECK:STDOUT: %.loc22_21: %.1 = tuple_literal ()
  296. // CHECK:STDOUT: %.loc22_22.1: %.3 = tuple_literal (%.loc22_13, %.loc22_17, %.loc22_21)
  297. // CHECK:STDOUT: %.loc22_22.2: type = converted %.loc22_13, constants.%.1 [template = constants.%.1]
  298. // CHECK:STDOUT: %.loc22_22.3: type = converted %.loc22_17, constants.%.1 [template = constants.%.1]
  299. // CHECK:STDOUT: %.loc22_22.4: type = converted %.loc22_21, constants.%.1 [template = constants.%.1]
  300. // CHECK:STDOUT: %.loc22_22.5: type = converted %.loc22_22.1, constants.%.3 [template = constants.%.3]
  301. // CHECK:STDOUT: %.loc22_28: %.1 = tuple_literal ()
  302. // CHECK:STDOUT: %.loc22_32: %.1 = tuple_literal ()
  303. // CHECK:STDOUT: %.loc22_36: %.1 = tuple_literal ()
  304. // CHECK:STDOUT: %.loc22_37.1: %.3 = tuple_literal (%.loc22_28, %.loc22_32, %.loc22_36)
  305. // CHECK:STDOUT: %tuple.loc22_28: %.1 = tuple_value () [template = constants.%tuple.1]
  306. // CHECK:STDOUT: %.loc22_37.2: %.1 = converted %.loc22_28, %tuple.loc22_28 [template = constants.%tuple.1]
  307. // CHECK:STDOUT: %tuple.loc22_32: %.1 = tuple_value () [template = constants.%tuple.1]
  308. // CHECK:STDOUT: %.loc22_37.3: %.1 = converted %.loc22_32, %tuple.loc22_32 [template = constants.%tuple.1]
  309. // CHECK:STDOUT: %tuple.loc22_36: %.1 = tuple_value () [template = constants.%tuple.1]
  310. // CHECK:STDOUT: %.loc22_37.4: %.1 = converted %.loc22_36, %tuple.loc22_36 [template = constants.%tuple.1]
  311. // CHECK:STDOUT: %tuple.loc22_37: %.3 = tuple_value (%.loc22_37.2, %.loc22_37.3, %.loc22_37.4) [template = constants.%tuple.2]
  312. // CHECK:STDOUT: %.loc22_38: %.3 = converted %.loc22_37.1, %tuple.loc22_37 [template = constants.%tuple.2]
  313. // CHECK:STDOUT: %d: %.3 = bind_name d, %.loc22_38
  314. // CHECK:STDOUT: %.loc23: <witness> = complete_type_witness %.5 [template = constants.%.6]
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: !members:
  317. // CHECK:STDOUT: .Self = constants.%C
  318. // CHECK:STDOUT: .a = %a
  319. // CHECK:STDOUT: .F = %F.decl
  320. // CHECK:STDOUT: .d = %d
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: generic fn @F(%b.loc10: %.2) {
  324. // CHECK:STDOUT: %b.1: %.2 = bind_symbolic_name b 0 [symbolic = %b.1 (constants.%b)]
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: !definition:
  327. // CHECK:STDOUT: %c.1: %.7 = bind_symbolic_name c 1 [symbolic = %c.1 (constants.%c)]
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: fn(%b.loc10: %.2) {
  330. // CHECK:STDOUT: !entry:
  331. // CHECK:STDOUT: %.loc11_15: %.1 = tuple_literal ()
  332. // CHECK:STDOUT: %.loc11_19: %.1 = tuple_literal ()
  333. // CHECK:STDOUT: %.loc11_20.1: %.7 = tuple_literal (%.loc11_15, %.loc11_19)
  334. // CHECK:STDOUT: %.loc11_20.2: type = converted %.loc11_15, constants.%.1 [template = constants.%.1]
  335. // CHECK:STDOUT: %.loc11_20.3: type = converted %.loc11_19, constants.%.1 [template = constants.%.1]
  336. // CHECK:STDOUT: %.loc11_20.4: type = converted %.loc11_20.1, constants.%.7 [template = constants.%.7]
  337. // CHECK:STDOUT: %.loc11_26: %.1 = tuple_literal ()
  338. // CHECK:STDOUT: %.loc11_30: %.1 = tuple_literal ()
  339. // CHECK:STDOUT: %.loc11_31.1: %.7 = tuple_literal (%.loc11_26, %.loc11_30)
  340. // CHECK:STDOUT: %tuple.loc11_26: %.1 = tuple_value () [template = constants.%tuple.1]
  341. // CHECK:STDOUT: %.loc11_31.2: %.1 = converted %.loc11_26, %tuple.loc11_26 [template = constants.%tuple.1]
  342. // CHECK:STDOUT: %tuple.loc11_30: %.1 = tuple_value () [template = constants.%tuple.1]
  343. // CHECK:STDOUT: %.loc11_31.3: %.1 = converted %.loc11_30, %tuple.loc11_30 [template = constants.%tuple.1]
  344. // CHECK:STDOUT: %tuple.loc11_31: %.7 = tuple_value (%.loc11_31.2, %.loc11_31.3) [template = constants.%tuple.3]
  345. // CHECK:STDOUT: %.loc11_32: %.7 = converted %.loc11_31.1, %tuple.loc11_31 [template = constants.%tuple.3]
  346. // CHECK:STDOUT: %c.loc11: %.7 = bind_symbolic_name c 1, %.loc11_32 [symbolic = %c.1 (constants.%c)]
  347. // CHECK:STDOUT: %.loc13_14.1: %.1 = tuple_literal ()
  348. // CHECK:STDOUT: %.loc13_14.2: type = converted %.loc13_14.1, constants.%.1 [template = constants.%.1]
  349. // CHECK:STDOUT: %a1.var: ref %.1 = var a1
  350. // CHECK:STDOUT: %a1: ref %.1 = bind_name a1, %a1.var
  351. // CHECK:STDOUT: %a.ref: %.1 = name_ref a, @C.%a
  352. // CHECK:STDOUT: %.loc13_18: init %.1 = tuple_init () to %a1.var [template = constants.%tuple.1]
  353. // CHECK:STDOUT: %.loc13_19: init %.1 = converted %a.ref, %.loc13_18 [template = constants.%tuple.1]
  354. // CHECK:STDOUT: assign %a1.var, %.loc13_19
  355. // CHECK:STDOUT: %.loc14_15: %.1 = tuple_literal ()
  356. // CHECK:STDOUT: %.loc14_17.1: %.2 = tuple_literal (%.loc14_15)
  357. // CHECK:STDOUT: %.loc14_17.2: type = converted %.loc14_15, constants.%.1 [template = constants.%.1]
  358. // CHECK:STDOUT: %.loc14_17.3: type = converted %.loc14_17.1, constants.%.2 [template = constants.%.2]
  359. // CHECK:STDOUT: %b1.var: ref %.2 = var b1
  360. // CHECK:STDOUT: %b1: ref %.2 = bind_name b1, %b1.var
  361. // CHECK:STDOUT: %b.ref: %.2 = name_ref b, %b.loc10 [symbolic = %b.1 (constants.%b)]
  362. // CHECK:STDOUT: %.loc14_21.1: %.1 = tuple_access %b.ref, element0
  363. // CHECK:STDOUT: %.loc14_21.2: ref %.1 = tuple_access %b1.var, element0
  364. // CHECK:STDOUT: %.loc14_21.3: init %.1 = tuple_init () to %.loc14_21.2 [template = constants.%tuple.1]
  365. // CHECK:STDOUT: %.loc14_21.4: init %.1 = converted %.loc14_21.1, %.loc14_21.3 [template = constants.%tuple.1]
  366. // CHECK:STDOUT: %.loc14_21.5: init %.2 = tuple_init (%.loc14_21.4) to %b1.var [template = constants.%tuple.4]
  367. // CHECK:STDOUT: %.loc14_22: init %.2 = converted %b.ref, %.loc14_21.5 [template = constants.%tuple.4]
  368. // CHECK:STDOUT: assign %b1.var, %.loc14_22
  369. // CHECK:STDOUT: %.loc15_15: %.1 = tuple_literal ()
  370. // CHECK:STDOUT: %.loc15_19: %.1 = tuple_literal ()
  371. // CHECK:STDOUT: %.loc15_20.1: %.7 = tuple_literal (%.loc15_15, %.loc15_19)
  372. // CHECK:STDOUT: %.loc15_20.2: type = converted %.loc15_15, constants.%.1 [template = constants.%.1]
  373. // CHECK:STDOUT: %.loc15_20.3: type = converted %.loc15_19, constants.%.1 [template = constants.%.1]
  374. // CHECK:STDOUT: %.loc15_20.4: type = converted %.loc15_20.1, constants.%.7 [template = constants.%.7]
  375. // CHECK:STDOUT: %c1.var: ref %.7 = var c1
  376. // CHECK:STDOUT: %c1: ref %.7 = bind_name c1, %c1.var
  377. // CHECK:STDOUT: %c.ref: %.7 = name_ref c, %c.loc11 [symbolic = %c.1 (constants.%c)]
  378. // CHECK:STDOUT: %.loc15_24.1: %.1 = tuple_access %c.ref, element0
  379. // CHECK:STDOUT: %.loc15_24.2: ref %.1 = tuple_access %c1.var, element0
  380. // CHECK:STDOUT: %.loc15_24.3: init %.1 = tuple_init () to %.loc15_24.2 [template = constants.%tuple.1]
  381. // CHECK:STDOUT: %.loc15_24.4: init %.1 = converted %.loc15_24.1, %.loc15_24.3 [template = constants.%tuple.1]
  382. // CHECK:STDOUT: %.loc15_24.5: %.1 = tuple_access %c.ref, element1
  383. // CHECK:STDOUT: %.loc15_24.6: ref %.1 = tuple_access %c1.var, element1
  384. // CHECK:STDOUT: %.loc15_24.7: init %.1 = tuple_init () to %.loc15_24.6 [template = constants.%tuple.1]
  385. // CHECK:STDOUT: %.loc15_24.8: init %.1 = converted %.loc15_24.5, %.loc15_24.7 [template = constants.%tuple.1]
  386. // CHECK:STDOUT: %.loc15_24.9: init %.7 = tuple_init (%.loc15_24.4, %.loc15_24.8) to %c1.var [template = constants.%tuple.3]
  387. // CHECK:STDOUT: %.loc15_25: init %.7 = converted %c.ref, %.loc15_24.9 [template = constants.%tuple.3]
  388. // CHECK:STDOUT: assign %c1.var, %.loc15_25
  389. // CHECK:STDOUT: %.loc16_15: %.1 = tuple_literal ()
  390. // CHECK:STDOUT: %.loc16_19: %.1 = tuple_literal ()
  391. // CHECK:STDOUT: %.loc16_23: %.1 = tuple_literal ()
  392. // CHECK:STDOUT: %.loc16_24.1: %.3 = tuple_literal (%.loc16_15, %.loc16_19, %.loc16_23)
  393. // CHECK:STDOUT: %.loc16_24.2: type = converted %.loc16_15, constants.%.1 [template = constants.%.1]
  394. // CHECK:STDOUT: %.loc16_24.3: type = converted %.loc16_19, constants.%.1 [template = constants.%.1]
  395. // CHECK:STDOUT: %.loc16_24.4: type = converted %.loc16_23, constants.%.1 [template = constants.%.1]
  396. // CHECK:STDOUT: %.loc16_24.5: type = converted %.loc16_24.1, constants.%.3 [template = constants.%.3]
  397. // CHECK:STDOUT: %d1.var: ref %.3 = var d1
  398. // CHECK:STDOUT: %d1: ref %.3 = bind_name d1, %d1.var
  399. // CHECK:STDOUT: %d.ref: %.3 = name_ref d, @C.%d
  400. // CHECK:STDOUT: %.loc16_28.1: %.1 = tuple_access %d.ref, element0
  401. // CHECK:STDOUT: %.loc16_28.2: ref %.1 = tuple_access %d1.var, element0
  402. // CHECK:STDOUT: %.loc16_28.3: init %.1 = tuple_init () to %.loc16_28.2 [template = constants.%tuple.1]
  403. // CHECK:STDOUT: %.loc16_28.4: init %.1 = converted %.loc16_28.1, %.loc16_28.3 [template = constants.%tuple.1]
  404. // CHECK:STDOUT: %.loc16_28.5: %.1 = tuple_access %d.ref, element1
  405. // CHECK:STDOUT: %.loc16_28.6: ref %.1 = tuple_access %d1.var, element1
  406. // CHECK:STDOUT: %.loc16_28.7: init %.1 = tuple_init () to %.loc16_28.6 [template = constants.%tuple.1]
  407. // CHECK:STDOUT: %.loc16_28.8: init %.1 = converted %.loc16_28.5, %.loc16_28.7 [template = constants.%tuple.1]
  408. // CHECK:STDOUT: %.loc16_28.9: %.1 = tuple_access %d.ref, element2
  409. // CHECK:STDOUT: %.loc16_28.10: ref %.1 = tuple_access %d1.var, element2
  410. // CHECK:STDOUT: %.loc16_28.11: init %.1 = tuple_init () to %.loc16_28.10 [template = constants.%tuple.1]
  411. // CHECK:STDOUT: %.loc16_28.12: init %.1 = converted %.loc16_28.9, %.loc16_28.11 [template = constants.%tuple.1]
  412. // CHECK:STDOUT: %.loc16_28.13: init %.3 = tuple_init (%.loc16_28.4, %.loc16_28.8, %.loc16_28.12) to %d1.var [template = constants.%tuple.2]
  413. // CHECK:STDOUT: %.loc16_29: init %.3 = converted %d.ref, %.loc16_28.13 [template = constants.%tuple.2]
  414. // CHECK:STDOUT: assign %d1.var, %.loc16_29
  415. // CHECK:STDOUT: return
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: specific @F(constants.%b) {
  420. // CHECK:STDOUT: %b.1 => constants.%b
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: --- fail_invalid_let_after.carbon
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: constants {
  426. // CHECK:STDOUT: %C: type = class_type @C [template]
  427. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  428. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  429. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  430. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  431. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  432. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  433. // CHECK:STDOUT: }
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: imports {
  436. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  437. // CHECK:STDOUT: import Core//prelude
  438. // CHECK:STDOUT: import Core//prelude/operators
  439. // CHECK:STDOUT: import Core//prelude/types
  440. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  441. // CHECK:STDOUT: import Core//prelude/operators/as
  442. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  443. // CHECK:STDOUT: import Core//prelude/operators/comparison
  444. // CHECK:STDOUT: import Core//prelude/types/bool
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT: }
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: file {
  449. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  450. // CHECK:STDOUT: .Core = imports.%Core
  451. // CHECK:STDOUT: .C = %C.decl
  452. // CHECK:STDOUT: }
  453. // CHECK:STDOUT: %Core.import = import Core
  454. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  455. // CHECK:STDOUT: }
  456. // CHECK:STDOUT:
  457. // CHECK:STDOUT: class @C {
  458. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  459. // CHECK:STDOUT: %.loc5_14.1: %.1 = tuple_literal ()
  460. // CHECK:STDOUT: %.loc5_14.2: type = converted %.loc5_14.1, constants.%.1 [template = constants.%.1]
  461. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  462. // CHECK:STDOUT: }
  463. // CHECK:STDOUT: %.loc14_12.1: %.1 = tuple_literal ()
  464. // CHECK:STDOUT: %.loc14_12.2: type = converted %.loc14_12.1, constants.%.1 [template = constants.%.1]
  465. // CHECK:STDOUT: %x: %.1 = bind_name x, <error>
  466. // CHECK:STDOUT: %.loc15: <witness> = complete_type_witness %.2 [template = constants.%.3]
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: !members:
  469. // CHECK:STDOUT: .Self = constants.%C
  470. // CHECK:STDOUT: .F = %F.decl
  471. // CHECK:STDOUT: .x = %x
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT:
  474. // CHECK:STDOUT: fn @F() -> %.1 {
  475. // CHECK:STDOUT: !entry:
  476. // CHECK:STDOUT: %x.ref: %.1 = name_ref x, @C.%x
  477. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  478. // CHECK:STDOUT: %.loc5_26: %.1 = converted %x.ref, %tuple [template = constants.%tuple]
  479. // CHECK:STDOUT: return %.loc5_26
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT:
  482. // CHECK:STDOUT: --- use_in_function.carbon
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: constants {
  485. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  486. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  487. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  488. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  489. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  490. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  491. // CHECK:STDOUT: %Zero: i32 = bind_symbolic_name Zero 0 [symbolic]
  492. // CHECK:STDOUT: }
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: imports {
  495. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  496. // CHECK:STDOUT: .Int32 = %import_ref
  497. // CHECK:STDOUT: import Core//prelude
  498. // CHECK:STDOUT: import Core//prelude/operators
  499. // CHECK:STDOUT: import Core//prelude/types
  500. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  501. // CHECK:STDOUT: import Core//prelude/operators/as
  502. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  503. // CHECK:STDOUT: import Core//prelude/operators/comparison
  504. // CHECK:STDOUT: import Core//prelude/types/bool
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: file {
  510. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  511. // CHECK:STDOUT: .Core = imports.%Core
  512. // CHECK:STDOUT: .F = %F.decl
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT: %Core.import = import Core
  515. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  516. // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
  517. // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
  518. // CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_32.loc4, %.loc4_11.1 [template = i32]
  519. // CHECK:STDOUT: %return: ref i32 = var <return slot>
  520. // CHECK:STDOUT: }
  521. // CHECK:STDOUT: }
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  524. // CHECK:STDOUT:
  525. // CHECK:STDOUT: fn @F() -> i32 {
  526. // CHECK:STDOUT: !entry:
  527. // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
  528. // CHECK:STDOUT: %.loc5_14.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
  529. // CHECK:STDOUT: %.loc5_14.2: type = converted %int.make_type_32.loc5, %.loc5_14.1 [template = i32]
  530. // CHECK:STDOUT: %.loc5_20: i32 = int_literal 0 [template = constants.%.2]
  531. // CHECK:STDOUT: %Zero: i32 = bind_symbolic_name Zero 0, %.loc5_20 [symbolic = constants.%Zero]
  532. // CHECK:STDOUT: %Zero.ref: i32 = name_ref Zero, %Zero [symbolic = constants.%Zero]
  533. // CHECK:STDOUT: return %Zero.ref
  534. // CHECK:STDOUT: }
  535. // CHECK:STDOUT:
  536. // CHECK:STDOUT: --- fail_return_in_interface.carbon
  537. // CHECK:STDOUT:
  538. // CHECK:STDOUT: constants {
  539. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  540. // CHECK:STDOUT: %Self.1: %.1 = bind_symbolic_name Self 0 [symbolic]
  541. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  542. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  543. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  544. // CHECK:STDOUT: %.3: type = assoc_entity_type %.1, type [template]
  545. // CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @I.%T [template]
  546. // CHECK:STDOUT: %ImplicitAs.type: type = generic_interface_type @ImplicitAs [template]
  547. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type = struct_value () [template]
  548. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic]
  549. // CHECK:STDOUT: %.5: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  550. // CHECK:STDOUT: %Self.2: @ImplicitAs.%.1 (%.5) = bind_symbolic_name Self 1 [symbolic]
  551. // CHECK:STDOUT: %Self.3: %.5 = bind_symbolic_name Self 1 [symbolic]
  552. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  553. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  554. // CHECK:STDOUT: %.6: type = assoc_entity_type %.5, %Convert.type.1 [symbolic]
  555. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  556. // CHECK:STDOUT: %.8: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
  557. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
  558. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  559. // CHECK:STDOUT: %.9: type = assoc_entity_type %.8, %Convert.type.2 [template]
  560. // CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.6 [template]
  561. // CHECK:STDOUT: %.11: %.6 = assoc_entity element0, imports.%import_ref.7 [symbolic]
  562. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  563. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  564. // CHECK:STDOUT: %.12: type = assoc_entity_type %.1, %F.type [template]
  565. // CHECK:STDOUT: %.13: %.12 = assoc_entity element1, @I.%F.decl [template]
  566. // CHECK:STDOUT: }
  567. // CHECK:STDOUT:
  568. // CHECK:STDOUT: imports {
  569. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  570. // CHECK:STDOUT: .Int32 = %import_ref.1
  571. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  572. // CHECK:STDOUT: import Core//prelude
  573. // CHECK:STDOUT: import Core//prelude/operators
  574. // CHECK:STDOUT: import Core//prelude/types
  575. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  576. // CHECK:STDOUT: import Core//prelude/operators/as
  577. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  578. // CHECK:STDOUT: import Core//prelude/operators/comparison
  579. // CHECK:STDOUT: import Core//prelude/types/bool
  580. // CHECK:STDOUT: }
  581. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  582. // CHECK:STDOUT: %import_ref.2: %ImplicitAs.type = import_ref Core//prelude/operators/as, inst+40, loaded [template = constants.%ImplicitAs]
  583. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/as, inst+45, unloaded
  584. // CHECK:STDOUT: %import_ref.4: @ImplicitAs.%.2 (%.6) = import_ref Core//prelude/operators/as, inst+63, loaded [symbolic = @ImplicitAs.%.3 (constants.%.11)]
  585. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+56, unloaded
  586. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+56, unloaded
  587. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+56, unloaded
  588. // CHECK:STDOUT: }
  589. // CHECK:STDOUT:
  590. // CHECK:STDOUT: file {
  591. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  592. // CHECK:STDOUT: .Core = imports.%Core
  593. // CHECK:STDOUT: .I = %I.decl
  594. // CHECK:STDOUT: }
  595. // CHECK:STDOUT: %Core.import = import Core
  596. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} {}
  597. // CHECK:STDOUT: }
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: interface @I {
  600. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
  601. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  602. // CHECK:STDOUT: %.loc5_21.1: type = value_of_initializer %int.make_type_32 [template = i32]
  603. // CHECK:STDOUT: %.loc5_21.2: type = converted %int.make_type_32, %.loc5_21.1 [template = i32]
  604. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  605. // CHECK:STDOUT: %.loc5_21.3: %.3 = assoc_entity element0, %T [template = constants.%.4]
  606. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  607. // CHECK:STDOUT: %T.ref: %.3 = name_ref T, @I.%.loc5_21.3 [template = constants.%.4]
  608. // CHECK:STDOUT: %.loc13_13.1: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%.8]
  609. // CHECK:STDOUT: %.loc13_13.2: %.9 = specific_constant imports.%import_ref.4, @ImplicitAs(type) [template = constants.%.10]
  610. // CHECK:STDOUT: %Convert.ref: %.9 = name_ref Convert, %.loc13_13.2 [template = constants.%.10]
  611. // CHECK:STDOUT: %.loc13_13.3: type = converted %T.ref, <error> [template = <error>]
  612. // CHECK:STDOUT: %return: ref <error> = var <return slot>
  613. // CHECK:STDOUT: }
  614. // CHECK:STDOUT: %.loc13: %.12 = assoc_entity element1, %F.decl [template = constants.%.13]
  615. // CHECK:STDOUT:
  616. // CHECK:STDOUT: !members:
  617. // CHECK:STDOUT: .Self = %Self
  618. // CHECK:STDOUT: .T = %.loc5_21.3
  619. // CHECK:STDOUT: .F = %.loc13
  620. // CHECK:STDOUT: witness = (%T, %F.decl)
  621. // CHECK:STDOUT: }
  622. // CHECK:STDOUT:
  623. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  624. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  625. // CHECK:STDOUT:
  626. // CHECK:STDOUT: !definition:
  627. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.5)]
  628. // CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.3)]
  629. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  630. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  631. // CHECK:STDOUT: %.2: type = assoc_entity_type @ImplicitAs.%.1 (%.5), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.2 (constants.%.6)]
  632. // CHECK:STDOUT: %.3: @ImplicitAs.%.2 (%.6) = assoc_entity element0, imports.%import_ref.6 [symbolic = %.3 (constants.%.7)]
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: interface {
  635. // CHECK:STDOUT: !members:
  636. // CHECK:STDOUT: .Self = imports.%import_ref.3
  637. // CHECK:STDOUT: .Convert = imports.%import_ref.4
  638. // CHECK:STDOUT: witness = (imports.%import_ref.5)
  639. // CHECK:STDOUT: }
  640. // CHECK:STDOUT: }
  641. // CHECK:STDOUT:
  642. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  643. // CHECK:STDOUT:
  644. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%.1 (%.5)) {
  645. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  646. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.5)]
  647. // CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.3)]
  648. // CHECK:STDOUT:
  649. // CHECK:STDOUT: fn[%self: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest);
  650. // CHECK:STDOUT: }
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: generic fn @F(@I.%Self: %.1) {
  653. // CHECK:STDOUT:
  654. // CHECK:STDOUT: fn() -> <error>;
  655. // CHECK:STDOUT: }
  656. // CHECK:STDOUT:
  657. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  658. // CHECK:STDOUT: %Dest => constants.%Dest
  659. // CHECK:STDOUT: }
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  662. // CHECK:STDOUT: %Dest => constants.%Dest
  663. // CHECK:STDOUT: }
  664. // CHECK:STDOUT:
  665. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  666. // CHECK:STDOUT: %Dest => constants.%Dest
  667. // CHECK:STDOUT: }
  668. // CHECK:STDOUT:
  669. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.2) {
  670. // CHECK:STDOUT: %Dest => constants.%Dest
  671. // CHECK:STDOUT: %.1 => constants.%.5
  672. // CHECK:STDOUT: %Self => constants.%Self.2
  673. // CHECK:STDOUT: }
  674. // CHECK:STDOUT:
  675. // CHECK:STDOUT: specific @ImplicitAs(type) {
  676. // CHECK:STDOUT: %Dest => type
  677. // CHECK:STDOUT:
  678. // CHECK:STDOUT: !definition:
  679. // CHECK:STDOUT: %.1 => constants.%.8
  680. // CHECK:STDOUT: %Self => constants.%Self.3
  681. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  682. // CHECK:STDOUT: %Convert => constants.%Convert.2
  683. // CHECK:STDOUT: %.2 => constants.%.9
  684. // CHECK:STDOUT: %.3 => constants.%.10
  685. // CHECK:STDOUT: }
  686. // CHECK:STDOUT:
  687. // CHECK:STDOUT: specific @F(constants.%Self.1) {}
  688. // CHECK:STDOUT:
  689. // CHECK:STDOUT: --- fail_return_in_class.carbon
  690. // CHECK:STDOUT:
  691. // CHECK:STDOUT: constants {
  692. // CHECK:STDOUT: %I: type = class_type @I [template]
  693. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  694. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  695. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  696. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  697. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  698. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  699. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  700. // CHECK:STDOUT: }
  701. // CHECK:STDOUT:
  702. // CHECK:STDOUT: imports {
  703. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  704. // CHECK:STDOUT: .Int32 = %import_ref
  705. // CHECK:STDOUT: import Core//prelude
  706. // CHECK:STDOUT: import Core//prelude/operators
  707. // CHECK:STDOUT: import Core//prelude/types
  708. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  709. // CHECK:STDOUT: import Core//prelude/operators/as
  710. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  711. // CHECK:STDOUT: import Core//prelude/operators/comparison
  712. // CHECK:STDOUT: import Core//prelude/types/bool
  713. // CHECK:STDOUT: }
  714. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  715. // CHECK:STDOUT: }
  716. // CHECK:STDOUT:
  717. // CHECK:STDOUT: file {
  718. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  719. // CHECK:STDOUT: .Core = imports.%Core
  720. // CHECK:STDOUT: .I = %I.decl
  721. // CHECK:STDOUT: }
  722. // CHECK:STDOUT: %Core.import = import Core
  723. // CHECK:STDOUT: %I.decl: type = class_decl @I [template = constants.%I] {} {}
  724. // CHECK:STDOUT: }
  725. // CHECK:STDOUT:
  726. // CHECK:STDOUT: class @I {
  727. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  728. // CHECK:STDOUT: %.loc9_21.1: type = value_of_initializer %int.make_type_32 [template = i32]
  729. // CHECK:STDOUT: %.loc9_21.2: type = converted %int.make_type_32, %.loc9_21.1 [template = i32]
  730. // CHECK:STDOUT: %T: type = bind_name T, %.loc9_21.2
  731. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  732. // CHECK:STDOUT: %T.ref: type = name_ref T, @I.%T
  733. // CHECK:STDOUT: %return: ref <error> = var <return slot>
  734. // CHECK:STDOUT: }
  735. // CHECK:STDOUT: %.loc15: <witness> = complete_type_witness %.2 [template = constants.%.3]
  736. // CHECK:STDOUT:
  737. // CHECK:STDOUT: !members:
  738. // CHECK:STDOUT: .Self = constants.%I
  739. // CHECK:STDOUT: .T = %T
  740. // CHECK:STDOUT: .F = %F.decl
  741. // CHECK:STDOUT: }
  742. // CHECK:STDOUT:
  743. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  744. // CHECK:STDOUT:
  745. // CHECK:STDOUT: fn @F() -> <error>;
  746. // CHECK:STDOUT:
  747. // CHECK:STDOUT: --- fail_return_in_package_scope.carbon
  748. // CHECK:STDOUT:
  749. // CHECK:STDOUT: constants {
  750. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  751. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  752. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  753. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  754. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  755. // CHECK:STDOUT: }
  756. // CHECK:STDOUT:
  757. // CHECK:STDOUT: imports {
  758. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  759. // CHECK:STDOUT: .Int32 = %import_ref
  760. // CHECK:STDOUT: import Core//prelude
  761. // CHECK:STDOUT: import Core//prelude/operators
  762. // CHECK:STDOUT: import Core//prelude/types
  763. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  764. // CHECK:STDOUT: import Core//prelude/operators/as
  765. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  766. // CHECK:STDOUT: import Core//prelude/operators/comparison
  767. // CHECK:STDOUT: import Core//prelude/types/bool
  768. // CHECK:STDOUT: }
  769. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  770. // CHECK:STDOUT: }
  771. // CHECK:STDOUT:
  772. // CHECK:STDOUT: file {
  773. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  774. // CHECK:STDOUT: .Core = imports.%Core
  775. // CHECK:STDOUT: .T = @__global_init.%T
  776. // CHECK:STDOUT: .F = %F.decl
  777. // CHECK:STDOUT: }
  778. // CHECK:STDOUT: %Core.import = import Core
  779. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {} {
  780. // CHECK:STDOUT: %T.ref: type = name_ref T, @__global_init.%T
  781. // CHECK:STDOUT: %return: ref <error> = var <return slot>
  782. // CHECK:STDOUT: }
  783. // CHECK:STDOUT: }
  784. // CHECK:STDOUT:
  785. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  786. // CHECK:STDOUT:
  787. // CHECK:STDOUT: fn @F() -> <error>;
  788. // CHECK:STDOUT:
  789. // CHECK:STDOUT: fn @__global_init() {
  790. // CHECK:STDOUT: !entry:
  791. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  792. // CHECK:STDOUT: %.loc8_19.1: type = value_of_initializer %int.make_type_32 [template = i32]
  793. // CHECK:STDOUT: %.loc8_19.2: type = converted %int.make_type_32, %.loc8_19.1 [template = i32]
  794. // CHECK:STDOUT: %T: type = bind_name T, %.loc8_19.2
  795. // CHECK:STDOUT: return
  796. // CHECK:STDOUT: }
  797. // CHECK:STDOUT: