compile_time_bindings.carbon 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  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 `ImplicitAs` [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: %.1: 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: %tuple: %.1 = tuple_value () [template]
  139. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  140. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [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/operators
  147. // CHECK:STDOUT: import Core//prelude/types
  148. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  149. // CHECK:STDOUT: import Core//prelude/operators/as
  150. // CHECK:STDOUT: import Core//prelude/operators/index
  151. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  152. // CHECK:STDOUT: import Core//prelude/operators/comparison
  153. // CHECK:STDOUT: import Core//prelude/types/bool
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: file {
  158. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  159. // CHECK:STDOUT: .Core = imports.%Core
  160. // CHECK:STDOUT: .C = %C.decl
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: %Core.import = import Core
  163. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: class @C {
  167. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  168. // CHECK:STDOUT: %return.patt: %.1 = return_slot_pattern
  169. // CHECK:STDOUT: %return.param_patt: %.1 = out_param_pattern %return.patt, runtime_param0
  170. // CHECK:STDOUT: } {
  171. // CHECK:STDOUT: %.loc5_14.1: %.1 = tuple_literal ()
  172. // CHECK:STDOUT: %.loc5_14.2: type = converted %.loc5_14.1, constants.%.1 [template = constants.%.1]
  173. // CHECK:STDOUT: %return.param: ref %.1 = out_param runtime_param0
  174. // CHECK:STDOUT: %return: ref %.1 = return_slot %return.param
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT: %.loc10_12.1: %.1 = tuple_literal ()
  177. // CHECK:STDOUT: %.loc10_12.2: type = converted %.loc10_12.1, constants.%.1 [template = constants.%.1]
  178. // CHECK:STDOUT: %.loc10_17: %.1 = tuple_literal ()
  179. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  180. // CHECK:STDOUT: %.loc10_18: %.1 = converted %.loc10_17, %tuple [template = constants.%tuple]
  181. // CHECK:STDOUT: %x: %.1 = bind_name x, %.loc10_18
  182. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.2 [template = constants.%.3]
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: !members:
  185. // CHECK:STDOUT: .Self = constants.%C
  186. // CHECK:STDOUT: .F = %F.decl
  187. // CHECK:STDOUT: .x = %x
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: fn @F() -> %.1 {
  191. // CHECK:STDOUT: !entry:
  192. // CHECK:STDOUT: %x.ref: %.1 = name_ref x, @C.%x
  193. // CHECK:STDOUT: return %x.ref
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: --- fail_let_before.carbon
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: constants {
  199. // CHECK:STDOUT: %C: type = class_type @C [template]
  200. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  201. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  202. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  203. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  204. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  205. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: imports {
  209. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  210. // CHECK:STDOUT: import Core//prelude
  211. // CHECK:STDOUT: import Core//prelude/operators
  212. // CHECK:STDOUT: import Core//prelude/types
  213. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  214. // CHECK:STDOUT: import Core//prelude/operators/as
  215. // CHECK:STDOUT: import Core//prelude/operators/index
  216. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  217. // CHECK:STDOUT: import Core//prelude/operators/comparison
  218. // CHECK:STDOUT: import Core//prelude/types/bool
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: file {
  223. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  224. // CHECK:STDOUT: .Core = imports.%Core
  225. // CHECK:STDOUT: .C = %C.decl
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT: %Core.import = import Core
  228. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: class @C {
  232. // CHECK:STDOUT: %.loc9_12.1: %.1 = tuple_literal ()
  233. // CHECK:STDOUT: %.loc9_12.2: type = converted %.loc9_12.1, constants.%.1 [template = constants.%.1]
  234. // CHECK:STDOUT: %.loc9_17: %.1 = tuple_literal ()
  235. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  236. // CHECK:STDOUT: %.loc9_18: %.1 = converted %.loc9_17, %tuple [template = constants.%tuple]
  237. // CHECK:STDOUT: %x: %.1 = bind_name x, %.loc9_18
  238. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  239. // CHECK:STDOUT: %return.patt: %.1 = return_slot_pattern
  240. // CHECK:STDOUT: %return.param_patt: %.1 = out_param_pattern %return.patt, runtime_param0
  241. // CHECK:STDOUT: } {
  242. // CHECK:STDOUT: %.loc10_14.1: %.1 = tuple_literal ()
  243. // CHECK:STDOUT: %.loc10_14.2: type = converted %.loc10_14.1, constants.%.1 [template = constants.%.1]
  244. // CHECK:STDOUT: %return.param: ref %.1 = out_param runtime_param0
  245. // CHECK:STDOUT: %return: ref %.1 = return_slot %return.param
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.2 [template = constants.%.3]
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: !members:
  250. // CHECK:STDOUT: .Self = constants.%C
  251. // CHECK:STDOUT: .x = %x
  252. // CHECK:STDOUT: .F = %F.decl
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: fn @F() -> %.1 {
  256. // CHECK:STDOUT: !entry:
  257. // CHECK:STDOUT: %x.ref: %.1 = name_ref x, @C.%x
  258. // CHECK:STDOUT: return %x.ref
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: --- fail_multiple_lets.carbon
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: constants {
  264. // CHECK:STDOUT: %C: type = class_type @C [template]
  265. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  266. // CHECK:STDOUT: %tuple.1: %.1 = tuple_value () [template]
  267. // CHECK:STDOUT: %.2: type = tuple_type (%.1) [template]
  268. // CHECK:STDOUT: %b: %.2 = bind_symbolic_name b, 0 [symbolic]
  269. // CHECK:STDOUT: %b.patt: %.2 = symbolic_binding_pattern b, 0 [symbolic]
  270. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  271. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  272. // CHECK:STDOUT: %.3: type = tuple_type (%.1, %.1, %.1) [template]
  273. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  274. // CHECK:STDOUT: %tuple.2: %.3 = tuple_value (%tuple.1, %tuple.1, %tuple.1) [template]
  275. // CHECK:STDOUT: %.5: type = struct_type {} [template]
  276. // CHECK:STDOUT: %.6: <witness> = complete_type_witness %.5 [template]
  277. // CHECK:STDOUT: %.7: type = tuple_type (%.1, %.1) [template]
  278. // CHECK:STDOUT: %.8: type = ptr_type %.7 [template]
  279. // CHECK:STDOUT: %tuple.3: %.7 = tuple_value (%tuple.1, %tuple.1) [template]
  280. // CHECK:STDOUT: %c: %.7 = bind_symbolic_name c, 1 [symbolic]
  281. // CHECK:STDOUT: %tuple.4: %.2 = tuple_value (%tuple.1) [template]
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: imports {
  285. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  286. // CHECK:STDOUT: import Core//prelude
  287. // CHECK:STDOUT: import Core//prelude/operators
  288. // CHECK:STDOUT: import Core//prelude/types
  289. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  290. // CHECK:STDOUT: import Core//prelude/operators/as
  291. // CHECK:STDOUT: import Core//prelude/operators/index
  292. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  293. // CHECK:STDOUT: import Core//prelude/operators/comparison
  294. // CHECK:STDOUT: import Core//prelude/types/bool
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: file {
  299. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  300. // CHECK:STDOUT: .Core = imports.%Core
  301. // CHECK:STDOUT: .C = %C.decl
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %Core.import = import Core
  304. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: class @C {
  308. // CHECK:STDOUT: %.loc9_12.1: %.1 = tuple_literal ()
  309. // CHECK:STDOUT: %.loc9_12.2: type = converted %.loc9_12.1, constants.%.1 [template = constants.%.1]
  310. // CHECK:STDOUT: %.loc9_17: %.1 = tuple_literal ()
  311. // CHECK:STDOUT: %tuple.loc9: %.1 = tuple_value () [template = constants.%tuple.1]
  312. // CHECK:STDOUT: %.loc9_18: %.1 = converted %.loc9_17, %tuple.loc9 [template = constants.%tuple.1]
  313. // CHECK:STDOUT: %a: %.1 = bind_name a, %.loc9_18
  314. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  315. // CHECK:STDOUT: %b.patt.loc10_8.2: %.2 = symbolic_binding_pattern b, 0 [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)]
  316. // CHECK:STDOUT: %b.param_patt: %.2 = value_param_pattern %b.patt.loc10_8.2, runtime_param<invalid> [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)]
  317. // CHECK:STDOUT: } {
  318. // CHECK:STDOUT: %.loc10_14: %.1 = tuple_literal ()
  319. // CHECK:STDOUT: %.loc10_16.1: %.2 = tuple_literal (%.loc10_14)
  320. // CHECK:STDOUT: %.loc10_16.2: type = converted %.loc10_14, constants.%.1 [template = constants.%.1]
  321. // CHECK:STDOUT: %.loc10_16.3: type = converted %.loc10_16.1, constants.%.2 [template = constants.%.2]
  322. // CHECK:STDOUT: %b.param: %.2 = value_param runtime_param<invalid>
  323. // CHECK:STDOUT: %b.loc10_8.2: %.2 = bind_symbolic_name b, 0, %b.param [symbolic = %b.loc10_8.1 (constants.%b)]
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT: %.loc22_13: %.1 = tuple_literal ()
  326. // CHECK:STDOUT: %.loc22_17: %.1 = tuple_literal ()
  327. // CHECK:STDOUT: %.loc22_21: %.1 = tuple_literal ()
  328. // CHECK:STDOUT: %.loc22_22.1: %.3 = tuple_literal (%.loc22_13, %.loc22_17, %.loc22_21)
  329. // CHECK:STDOUT: %.loc22_22.2: type = converted %.loc22_13, constants.%.1 [template = constants.%.1]
  330. // CHECK:STDOUT: %.loc22_22.3: type = converted %.loc22_17, constants.%.1 [template = constants.%.1]
  331. // CHECK:STDOUT: %.loc22_22.4: type = converted %.loc22_21, constants.%.1 [template = constants.%.1]
  332. // CHECK:STDOUT: %.loc22_22.5: type = converted %.loc22_22.1, constants.%.3 [template = constants.%.3]
  333. // CHECK:STDOUT: %.loc22_28: %.1 = tuple_literal ()
  334. // CHECK:STDOUT: %.loc22_32: %.1 = tuple_literal ()
  335. // CHECK:STDOUT: %.loc22_36: %.1 = tuple_literal ()
  336. // CHECK:STDOUT: %.loc22_37.1: %.3 = tuple_literal (%.loc22_28, %.loc22_32, %.loc22_36)
  337. // CHECK:STDOUT: %tuple.loc22_28: %.1 = tuple_value () [template = constants.%tuple.1]
  338. // CHECK:STDOUT: %.loc22_37.2: %.1 = converted %.loc22_28, %tuple.loc22_28 [template = constants.%tuple.1]
  339. // CHECK:STDOUT: %tuple.loc22_32: %.1 = tuple_value () [template = constants.%tuple.1]
  340. // CHECK:STDOUT: %.loc22_37.3: %.1 = converted %.loc22_32, %tuple.loc22_32 [template = constants.%tuple.1]
  341. // CHECK:STDOUT: %tuple.loc22_36: %.1 = tuple_value () [template = constants.%tuple.1]
  342. // CHECK:STDOUT: %.loc22_37.4: %.1 = converted %.loc22_36, %tuple.loc22_36 [template = constants.%tuple.1]
  343. // CHECK:STDOUT: %tuple.loc22_37: %.3 = tuple_value (%.loc22_37.2, %.loc22_37.3, %.loc22_37.4) [template = constants.%tuple.2]
  344. // CHECK:STDOUT: %.loc22_38: %.3 = converted %.loc22_37.1, %tuple.loc22_37 [template = constants.%tuple.2]
  345. // CHECK:STDOUT: %d: %.3 = bind_name d, %.loc22_38
  346. // CHECK:STDOUT: %.loc23: <witness> = complete_type_witness %.5 [template = constants.%.6]
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: !members:
  349. // CHECK:STDOUT: .Self = constants.%C
  350. // CHECK:STDOUT: .a = %a
  351. // CHECK:STDOUT: .F = %F.decl
  352. // CHECK:STDOUT: .d = %d
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: generic fn @F(%b.loc10_8.2: %.2) {
  356. // CHECK:STDOUT: %b.loc10_8.1: %.2 = bind_symbolic_name b, 0 [symbolic = %b.loc10_8.1 (constants.%b)]
  357. // CHECK:STDOUT: %b.patt.loc10_8.1: %.2 = symbolic_binding_pattern b, 0 [symbolic = %b.patt.loc10_8.1 (constants.%b.patt)]
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: !definition:
  360. // CHECK:STDOUT: %c.loc11_9.2: %.7 = bind_symbolic_name c, 1 [symbolic = %c.loc11_9.2 (constants.%c)]
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: fn(%b.param_patt: %.2) {
  363. // CHECK:STDOUT: !entry:
  364. // CHECK:STDOUT: %.loc11_15: %.1 = tuple_literal ()
  365. // CHECK:STDOUT: %.loc11_19: %.1 = tuple_literal ()
  366. // CHECK:STDOUT: %.loc11_20.1: %.7 = tuple_literal (%.loc11_15, %.loc11_19)
  367. // CHECK:STDOUT: %.loc11_20.2: type = converted %.loc11_15, constants.%.1 [template = constants.%.1]
  368. // CHECK:STDOUT: %.loc11_20.3: type = converted %.loc11_19, constants.%.1 [template = constants.%.1]
  369. // CHECK:STDOUT: %.loc11_20.4: type = converted %.loc11_20.1, constants.%.7 [template = constants.%.7]
  370. // CHECK:STDOUT: %.loc11_26: %.1 = tuple_literal ()
  371. // CHECK:STDOUT: %.loc11_30: %.1 = tuple_literal ()
  372. // CHECK:STDOUT: %.loc11_31.1: %.7 = tuple_literal (%.loc11_26, %.loc11_30)
  373. // CHECK:STDOUT: %tuple.loc11_26: %.1 = tuple_value () [template = constants.%tuple.1]
  374. // CHECK:STDOUT: %.loc11_31.2: %.1 = converted %.loc11_26, %tuple.loc11_26 [template = constants.%tuple.1]
  375. // CHECK:STDOUT: %tuple.loc11_30: %.1 = tuple_value () [template = constants.%tuple.1]
  376. // CHECK:STDOUT: %.loc11_31.3: %.1 = converted %.loc11_30, %tuple.loc11_30 [template = constants.%tuple.1]
  377. // CHECK:STDOUT: %tuple.loc11_31: %.7 = tuple_value (%.loc11_31.2, %.loc11_31.3) [template = constants.%tuple.3]
  378. // CHECK:STDOUT: %.loc11_32: %.7 = converted %.loc11_31.1, %tuple.loc11_31 [template = constants.%tuple.3]
  379. // CHECK:STDOUT: %c.loc11_9.1: %.7 = bind_symbolic_name c, 1, %.loc11_32 [symbolic = %c.loc11_9.2 (constants.%c)]
  380. // CHECK:STDOUT: %.loc13_14.1: %.1 = tuple_literal ()
  381. // CHECK:STDOUT: %.loc13_14.2: type = converted %.loc13_14.1, constants.%.1 [template = constants.%.1]
  382. // CHECK:STDOUT: %a1.var: ref %.1 = var a1
  383. // CHECK:STDOUT: %a1: ref %.1 = bind_name a1, %a1.var
  384. // CHECK:STDOUT: %a.ref: %.1 = name_ref a, @C.%a
  385. // CHECK:STDOUT: %.loc13_18: init %.1 = tuple_init () to %a1.var [template = constants.%tuple.1]
  386. // CHECK:STDOUT: %.loc13_19: init %.1 = converted %a.ref, %.loc13_18 [template = constants.%tuple.1]
  387. // CHECK:STDOUT: assign %a1.var, %.loc13_19
  388. // CHECK:STDOUT: %.loc14_15: %.1 = tuple_literal ()
  389. // CHECK:STDOUT: %.loc14_17.1: %.2 = tuple_literal (%.loc14_15)
  390. // CHECK:STDOUT: %.loc14_17.2: type = converted %.loc14_15, constants.%.1 [template = constants.%.1]
  391. // CHECK:STDOUT: %.loc14_17.3: type = converted %.loc14_17.1, constants.%.2 [template = constants.%.2]
  392. // CHECK:STDOUT: %b1.var: ref %.2 = var b1
  393. // CHECK:STDOUT: %b1: ref %.2 = bind_name b1, %b1.var
  394. // CHECK:STDOUT: %b.ref: %.2 = name_ref b, %b.loc10_8.2 [symbolic = %b.loc10_8.1 (constants.%b)]
  395. // CHECK:STDOUT: %.loc14_21.1: %.1 = tuple_access %b.ref, element0
  396. // CHECK:STDOUT: %.loc14_21.2: ref %.1 = tuple_access %b1.var, element0
  397. // CHECK:STDOUT: %.loc14_21.3: init %.1 = tuple_init () to %.loc14_21.2 [template = constants.%tuple.1]
  398. // CHECK:STDOUT: %.loc14_21.4: init %.1 = converted %.loc14_21.1, %.loc14_21.3 [template = constants.%tuple.1]
  399. // CHECK:STDOUT: %.loc14_21.5: init %.2 = tuple_init (%.loc14_21.4) to %b1.var [template = constants.%tuple.4]
  400. // CHECK:STDOUT: %.loc14_22: init %.2 = converted %b.ref, %.loc14_21.5 [template = constants.%tuple.4]
  401. // CHECK:STDOUT: assign %b1.var, %.loc14_22
  402. // CHECK:STDOUT: %.loc15_15: %.1 = tuple_literal ()
  403. // CHECK:STDOUT: %.loc15_19: %.1 = tuple_literal ()
  404. // CHECK:STDOUT: %.loc15_20.1: %.7 = tuple_literal (%.loc15_15, %.loc15_19)
  405. // CHECK:STDOUT: %.loc15_20.2: type = converted %.loc15_15, constants.%.1 [template = constants.%.1]
  406. // CHECK:STDOUT: %.loc15_20.3: type = converted %.loc15_19, constants.%.1 [template = constants.%.1]
  407. // CHECK:STDOUT: %.loc15_20.4: type = converted %.loc15_20.1, constants.%.7 [template = constants.%.7]
  408. // CHECK:STDOUT: %c1.var: ref %.7 = var c1
  409. // CHECK:STDOUT: %c1: ref %.7 = bind_name c1, %c1.var
  410. // CHECK:STDOUT: %c.ref: %.7 = name_ref c, %c.loc11_9.1 [symbolic = %c.loc11_9.2 (constants.%c)]
  411. // CHECK:STDOUT: %.loc15_24.1: %.1 = tuple_access %c.ref, element0
  412. // CHECK:STDOUT: %.loc15_24.2: ref %.1 = tuple_access %c1.var, element0
  413. // CHECK:STDOUT: %.loc15_24.3: init %.1 = tuple_init () to %.loc15_24.2 [template = constants.%tuple.1]
  414. // CHECK:STDOUT: %.loc15_24.4: init %.1 = converted %.loc15_24.1, %.loc15_24.3 [template = constants.%tuple.1]
  415. // CHECK:STDOUT: %.loc15_24.5: %.1 = tuple_access %c.ref, element1
  416. // CHECK:STDOUT: %.loc15_24.6: ref %.1 = tuple_access %c1.var, element1
  417. // CHECK:STDOUT: %.loc15_24.7: init %.1 = tuple_init () to %.loc15_24.6 [template = constants.%tuple.1]
  418. // CHECK:STDOUT: %.loc15_24.8: init %.1 = converted %.loc15_24.5, %.loc15_24.7 [template = constants.%tuple.1]
  419. // CHECK:STDOUT: %.loc15_24.9: init %.7 = tuple_init (%.loc15_24.4, %.loc15_24.8) to %c1.var [template = constants.%tuple.3]
  420. // CHECK:STDOUT: %.loc15_25: init %.7 = converted %c.ref, %.loc15_24.9 [template = constants.%tuple.3]
  421. // CHECK:STDOUT: assign %c1.var, %.loc15_25
  422. // CHECK:STDOUT: %.loc16_15: %.1 = tuple_literal ()
  423. // CHECK:STDOUT: %.loc16_19: %.1 = tuple_literal ()
  424. // CHECK:STDOUT: %.loc16_23: %.1 = tuple_literal ()
  425. // CHECK:STDOUT: %.loc16_24.1: %.3 = tuple_literal (%.loc16_15, %.loc16_19, %.loc16_23)
  426. // CHECK:STDOUT: %.loc16_24.2: type = converted %.loc16_15, constants.%.1 [template = constants.%.1]
  427. // CHECK:STDOUT: %.loc16_24.3: type = converted %.loc16_19, constants.%.1 [template = constants.%.1]
  428. // CHECK:STDOUT: %.loc16_24.4: type = converted %.loc16_23, constants.%.1 [template = constants.%.1]
  429. // CHECK:STDOUT: %.loc16_24.5: type = converted %.loc16_24.1, constants.%.3 [template = constants.%.3]
  430. // CHECK:STDOUT: %d1.var: ref %.3 = var d1
  431. // CHECK:STDOUT: %d1: ref %.3 = bind_name d1, %d1.var
  432. // CHECK:STDOUT: %d.ref: %.3 = name_ref d, @C.%d
  433. // CHECK:STDOUT: %.loc16_28.1: %.1 = tuple_access %d.ref, element0
  434. // CHECK:STDOUT: %.loc16_28.2: ref %.1 = tuple_access %d1.var, element0
  435. // CHECK:STDOUT: %.loc16_28.3: init %.1 = tuple_init () to %.loc16_28.2 [template = constants.%tuple.1]
  436. // CHECK:STDOUT: %.loc16_28.4: init %.1 = converted %.loc16_28.1, %.loc16_28.3 [template = constants.%tuple.1]
  437. // CHECK:STDOUT: %.loc16_28.5: %.1 = tuple_access %d.ref, element1
  438. // CHECK:STDOUT: %.loc16_28.6: ref %.1 = tuple_access %d1.var, element1
  439. // CHECK:STDOUT: %.loc16_28.7: init %.1 = tuple_init () to %.loc16_28.6 [template = constants.%tuple.1]
  440. // CHECK:STDOUT: %.loc16_28.8: init %.1 = converted %.loc16_28.5, %.loc16_28.7 [template = constants.%tuple.1]
  441. // CHECK:STDOUT: %.loc16_28.9: %.1 = tuple_access %d.ref, element2
  442. // CHECK:STDOUT: %.loc16_28.10: ref %.1 = tuple_access %d1.var, element2
  443. // CHECK:STDOUT: %.loc16_28.11: init %.1 = tuple_init () to %.loc16_28.10 [template = constants.%tuple.1]
  444. // CHECK:STDOUT: %.loc16_28.12: init %.1 = converted %.loc16_28.9, %.loc16_28.11 [template = constants.%tuple.1]
  445. // 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]
  446. // CHECK:STDOUT: %.loc16_29: init %.3 = converted %d.ref, %.loc16_28.13 [template = constants.%tuple.2]
  447. // CHECK:STDOUT: assign %d1.var, %.loc16_29
  448. // CHECK:STDOUT: return
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT: }
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: specific @F(constants.%b) {
  453. // CHECK:STDOUT: %b.loc10_8.1 => constants.%b
  454. // CHECK:STDOUT: %b.patt.loc10_8.1 => constants.%b
  455. // CHECK:STDOUT: }
  456. // CHECK:STDOUT:
  457. // CHECK:STDOUT: --- fail_invalid_let_after.carbon
  458. // CHECK:STDOUT:
  459. // CHECK:STDOUT: constants {
  460. // CHECK:STDOUT: %C: type = class_type @C [template]
  461. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  462. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  463. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  464. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  465. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  466. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: imports {
  470. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  471. // CHECK:STDOUT: import Core//prelude
  472. // CHECK:STDOUT: import Core//prelude/operators
  473. // CHECK:STDOUT: import Core//prelude/types
  474. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  475. // CHECK:STDOUT: import Core//prelude/operators/as
  476. // CHECK:STDOUT: import Core//prelude/operators/index
  477. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  478. // CHECK:STDOUT: import Core//prelude/operators/comparison
  479. // CHECK:STDOUT: import Core//prelude/types/bool
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT: }
  482. // CHECK:STDOUT:
  483. // CHECK:STDOUT: file {
  484. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  485. // CHECK:STDOUT: .Core = imports.%Core
  486. // CHECK:STDOUT: .C = %C.decl
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT: %Core.import = import Core
  489. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  490. // CHECK:STDOUT: }
  491. // CHECK:STDOUT:
  492. // CHECK:STDOUT: class @C {
  493. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  494. // CHECK:STDOUT: %return.patt: %.1 = return_slot_pattern
  495. // CHECK:STDOUT: %return.param_patt: %.1 = out_param_pattern %return.patt, runtime_param0
  496. // CHECK:STDOUT: } {
  497. // CHECK:STDOUT: %.loc5_14.1: %.1 = tuple_literal ()
  498. // CHECK:STDOUT: %.loc5_14.2: type = converted %.loc5_14.1, constants.%.1 [template = constants.%.1]
  499. // CHECK:STDOUT: %return.param: ref %.1 = out_param runtime_param0
  500. // CHECK:STDOUT: %return: ref %.1 = return_slot %return.param
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT: %.loc14_12.1: %.1 = tuple_literal ()
  503. // CHECK:STDOUT: %.loc14_12.2: type = converted %.loc14_12.1, constants.%.1 [template = constants.%.1]
  504. // CHECK:STDOUT: %x: %.1 = bind_name x, <error>
  505. // CHECK:STDOUT: %.loc15: <witness> = complete_type_witness %.2 [template = constants.%.3]
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: !members:
  508. // CHECK:STDOUT: .Self = constants.%C
  509. // CHECK:STDOUT: .F = %F.decl
  510. // CHECK:STDOUT: .x = %x
  511. // CHECK:STDOUT: }
  512. // CHECK:STDOUT:
  513. // CHECK:STDOUT: fn @F() -> %.1 {
  514. // CHECK:STDOUT: !entry:
  515. // CHECK:STDOUT: %x.ref: %.1 = name_ref x, @C.%x
  516. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  517. // CHECK:STDOUT: %.loc5_26: %.1 = converted %x.ref, %tuple [template = constants.%tuple]
  518. // CHECK:STDOUT: return %.loc5_26
  519. // CHECK:STDOUT: }
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: --- use_in_function.carbon
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: constants {
  524. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  525. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  526. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  527. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  528. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  529. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  530. // CHECK:STDOUT: %Zero: i32 = bind_symbolic_name Zero, 0 [symbolic]
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT:
  533. // CHECK:STDOUT: imports {
  534. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  535. // CHECK:STDOUT: .Int32 = %import_ref
  536. // CHECK:STDOUT: import Core//prelude
  537. // CHECK:STDOUT: import Core//prelude/operators
  538. // CHECK:STDOUT: import Core//prelude/types
  539. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  540. // CHECK:STDOUT: import Core//prelude/operators/as
  541. // CHECK:STDOUT: import Core//prelude/operators/index
  542. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  543. // CHECK:STDOUT: import Core//prelude/operators/comparison
  544. // CHECK:STDOUT: import Core//prelude/types/bool
  545. // CHECK:STDOUT: }
  546. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: file {
  550. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  551. // CHECK:STDOUT: .Core = imports.%Core
  552. // CHECK:STDOUT: .F = %F.decl
  553. // CHECK:STDOUT: }
  554. // CHECK:STDOUT: %Core.import = import Core
  555. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  556. // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern
  557. // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param0
  558. // CHECK:STDOUT: } {
  559. // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
  560. // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
  561. // CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_32.loc4, %.loc4_11.1 [template = i32]
  562. // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param0
  563. // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
  564. // CHECK:STDOUT: }
  565. // CHECK:STDOUT: }
  566. // CHECK:STDOUT:
  567. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: fn @F() -> i32 {
  570. // CHECK:STDOUT: !entry:
  571. // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
  572. // CHECK:STDOUT: %.loc5_14.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
  573. // CHECK:STDOUT: %.loc5_14.2: type = converted %int.make_type_32.loc5, %.loc5_14.1 [template = i32]
  574. // CHECK:STDOUT: %.loc5_20: i32 = int_literal 0 [template = constants.%.2]
  575. // CHECK:STDOUT: %Zero: i32 = bind_symbolic_name Zero, 0, %.loc5_20 [symbolic = constants.%Zero]
  576. // CHECK:STDOUT: %Zero.ref: i32 = name_ref Zero, %Zero [symbolic = constants.%Zero]
  577. // CHECK:STDOUT: return %Zero.ref
  578. // CHECK:STDOUT: }
  579. // CHECK:STDOUT:
  580. // CHECK:STDOUT: --- use_in_block.carbon
  581. // CHECK:STDOUT:
  582. // CHECK:STDOUT: constants {
  583. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  584. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  585. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  586. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  587. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  588. // CHECK:STDOUT: %.2: bool = bool_literal true [template]
  589. // CHECK:STDOUT: %.3: i32 = int_literal 0 [template]
  590. // CHECK:STDOUT: %Zero: i32 = bind_symbolic_name Zero, 0 [symbolic]
  591. // CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
  592. // CHECK:STDOUT: }
  593. // CHECK:STDOUT:
  594. // CHECK:STDOUT: imports {
  595. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  596. // CHECK:STDOUT: .Int32 = %import_ref
  597. // CHECK:STDOUT: import Core//prelude
  598. // CHECK:STDOUT: import Core//prelude/operators
  599. // CHECK:STDOUT: import Core//prelude/types
  600. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  601. // CHECK:STDOUT: import Core//prelude/operators/as
  602. // CHECK:STDOUT: import Core//prelude/operators/index
  603. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  604. // CHECK:STDOUT: import Core//prelude/operators/comparison
  605. // CHECK:STDOUT: import Core//prelude/types/bool
  606. // CHECK:STDOUT: }
  607. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  608. // CHECK:STDOUT: }
  609. // CHECK:STDOUT:
  610. // CHECK:STDOUT: file {
  611. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  612. // CHECK:STDOUT: .Core = imports.%Core
  613. // CHECK:STDOUT: .F = %F.decl
  614. // CHECK:STDOUT: }
  615. // CHECK:STDOUT: %Core.import = import Core
  616. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  617. // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern
  618. // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param0
  619. // CHECK:STDOUT: } {
  620. // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
  621. // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
  622. // CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_32.loc4, %.loc4_11.1 [template = i32]
  623. // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param0
  624. // CHECK:STDOUT: %return: ref i32 = return_slot %return.param
  625. // CHECK:STDOUT: }
  626. // CHECK:STDOUT: }
  627. // CHECK:STDOUT:
  628. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  629. // CHECK:STDOUT:
  630. // CHECK:STDOUT: fn @F() -> i32 {
  631. // CHECK:STDOUT: !entry:
  632. // CHECK:STDOUT: %.loc5: bool = bool_literal true [template = constants.%.2]
  633. // CHECK:STDOUT: if %.loc5 br !if.then else br !if.else
  634. // CHECK:STDOUT:
  635. // CHECK:STDOUT: !if.then:
  636. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  637. // CHECK:STDOUT: %.loc6_16.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  638. // CHECK:STDOUT: %.loc6_16.2: type = converted %int.make_type_32.loc6, %.loc6_16.1 [template = i32]
  639. // CHECK:STDOUT: %.loc6_22: i32 = int_literal 0 [template = constants.%.3]
  640. // CHECK:STDOUT: %Zero: i32 = bind_symbolic_name Zero, 0, %.loc6_22 [symbolic = constants.%Zero]
  641. // CHECK:STDOUT: %Zero.ref: i32 = name_ref Zero, %Zero [symbolic = constants.%Zero]
  642. // CHECK:STDOUT: return %Zero.ref
  643. // CHECK:STDOUT:
  644. // CHECK:STDOUT: !if.else:
  645. // CHECK:STDOUT: %.loc9: i32 = int_literal 1 [template = constants.%.4]
  646. // CHECK:STDOUT: return %.loc9
  647. // CHECK:STDOUT: }
  648. // CHECK:STDOUT:
  649. // CHECK:STDOUT: --- fail_return_in_interface.carbon
  650. // CHECK:STDOUT:
  651. // CHECK:STDOUT: constants {
  652. // CHECK:STDOUT: %I.type: type = interface_type @I [template]
  653. // CHECK:STDOUT: %Self.1: %I.type = bind_symbolic_name Self, 0 [symbolic]
  654. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  655. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  656. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  657. // CHECK:STDOUT: %.2: type = assoc_entity_type %I.type, type [template]
  658. // CHECK:STDOUT: %.3: %.2 = assoc_entity element0, @I.%T [template]
  659. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  660. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  661. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  662. // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  663. // CHECK:STDOUT: %Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  664. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  665. // CHECK:STDOUT: %Self.3: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  666. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  667. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  668. // CHECK:STDOUT: %.4: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  669. // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic]
  670. // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(type) [template]
  671. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(type) [template]
  672. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  673. // CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  674. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [template]
  675. // CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.7 [symbolic]
  676. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  677. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  678. // CHECK:STDOUT: %.9: type = assoc_entity_type %I.type, %F.type [template]
  679. // CHECK:STDOUT: %.10: %.9 = assoc_entity element1, @I.%F.decl [template]
  680. // CHECK:STDOUT: }
  681. // CHECK:STDOUT:
  682. // CHECK:STDOUT: imports {
  683. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  684. // CHECK:STDOUT: .Int32 = %import_ref.1
  685. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  686. // CHECK:STDOUT: import Core//prelude
  687. // CHECK:STDOUT: import Core//prelude/operators
  688. // CHECK:STDOUT: import Core//prelude/types
  689. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  690. // CHECK:STDOUT: import Core//prelude/operators/as
  691. // CHECK:STDOUT: import Core//prelude/operators/index
  692. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  693. // CHECK:STDOUT: import Core//prelude/operators/comparison
  694. // CHECK:STDOUT: import Core//prelude/types/bool
  695. // CHECK:STDOUT: }
  696. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  697. // CHECK:STDOUT: %import_ref.2: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs]
  698. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/as, inst+55, unloaded
  699. // CHECK:STDOUT: %import_ref.4: @ImplicitAs.%.1 (%.4) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.8)]
  700. // CHECK:STDOUT: %import_ref.5 = import_ref Core//prelude/operators/as, inst+70, unloaded
  701. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/as, inst+70, unloaded
  702. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+70, unloaded
  703. // CHECK:STDOUT: }
  704. // CHECK:STDOUT:
  705. // CHECK:STDOUT: file {
  706. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  707. // CHECK:STDOUT: .Core = imports.%Core
  708. // CHECK:STDOUT: .I = %I.decl
  709. // CHECK:STDOUT: }
  710. // CHECK:STDOUT: %Core.import = import Core
  711. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  712. // CHECK:STDOUT: }
  713. // CHECK:STDOUT:
  714. // CHECK:STDOUT: interface @I {
  715. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  716. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  717. // CHECK:STDOUT: %.loc5_21.1: type = value_of_initializer %int.make_type_32 [template = i32]
  718. // CHECK:STDOUT: %.loc5_21.2: type = converted %int.make_type_32, %.loc5_21.1 [template = i32]
  719. // CHECK:STDOUT: %T: type = assoc_const_decl T [template]
  720. // CHECK:STDOUT: %.loc5_21.3: %.2 = assoc_entity element0, %T [template = constants.%.3]
  721. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  722. // CHECK:STDOUT: %return.patt: <error> = return_slot_pattern
  723. // CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, runtime_param0
  724. // CHECK:STDOUT: } {
  725. // CHECK:STDOUT: %T.ref: %.2 = name_ref T, @I.%.loc5_21.3 [template = constants.%.3]
  726. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(type) [template = constants.%ImplicitAs.type.3]
  727. // CHECK:STDOUT: %.loc13_13.1: %.6 = specific_constant imports.%import_ref.4, @ImplicitAs(type) [template = constants.%.7]
  728. // CHECK:STDOUT: %Convert.ref: %.6 = name_ref Convert, %.loc13_13.1 [template = constants.%.7]
  729. // CHECK:STDOUT: %.loc13_13.2: type = converted %T.ref, <error> [template = <error>]
  730. // CHECK:STDOUT: %return.param: ref <error> = out_param runtime_param0
  731. // CHECK:STDOUT: %return: ref <error> = return_slot %return.param
  732. // CHECK:STDOUT: }
  733. // CHECK:STDOUT: %.loc13: %.9 = assoc_entity element1, %F.decl [template = constants.%.10]
  734. // CHECK:STDOUT:
  735. // CHECK:STDOUT: !members:
  736. // CHECK:STDOUT: .Self = %Self
  737. // CHECK:STDOUT: .T = %.loc5_21.3
  738. // CHECK:STDOUT: .F = %.loc13
  739. // CHECK:STDOUT: witness = (%T, %F.decl)
  740. // CHECK:STDOUT: }
  741. // CHECK:STDOUT:
  742. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  743. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  744. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  745. // CHECK:STDOUT:
  746. // CHECK:STDOUT: !definition:
  747. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  748. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)]
  749. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  750. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  751. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.4)]
  752. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.4) = assoc_entity element0, imports.%import_ref.6 [symbolic = %.2 (constants.%.5)]
  753. // CHECK:STDOUT:
  754. // CHECK:STDOUT: interface {
  755. // CHECK:STDOUT: !members:
  756. // CHECK:STDOUT: .Self = imports.%import_ref.3
  757. // CHECK:STDOUT: .Convert = imports.%import_ref.4
  758. // CHECK:STDOUT: witness = (imports.%import_ref.5)
  759. // CHECK:STDOUT: }
  760. // CHECK:STDOUT: }
  761. // CHECK:STDOUT:
  762. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  763. // CHECK:STDOUT:
  764. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  765. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  766. // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  767. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.3)]
  768. // CHECK:STDOUT:
  769. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest);
  770. // CHECK:STDOUT: }
  771. // CHECK:STDOUT:
  772. // CHECK:STDOUT: generic fn @F(@I.%Self: %I.type) {
  773. // CHECK:STDOUT:
  774. // CHECK:STDOUT: fn() -> <error>;
  775. // CHECK:STDOUT: }
  776. // CHECK:STDOUT:
  777. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  778. // CHECK:STDOUT: %Dest => constants.%Dest
  779. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  780. // CHECK:STDOUT: }
  781. // CHECK:STDOUT:
  782. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  783. // CHECK:STDOUT: %Dest => constants.%Dest
  784. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  785. // CHECK:STDOUT: }
  786. // CHECK:STDOUT:
  787. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  788. // CHECK:STDOUT: %Dest => constants.%Dest
  789. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  790. // CHECK:STDOUT: }
  791. // CHECK:STDOUT:
  792. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.2) {
  793. // CHECK:STDOUT: %Dest => constants.%Dest
  794. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  795. // CHECK:STDOUT: %Self => constants.%Self.2
  796. // CHECK:STDOUT: }
  797. // CHECK:STDOUT:
  798. // CHECK:STDOUT: specific @ImplicitAs(type) {
  799. // CHECK:STDOUT: %Dest => type
  800. // CHECK:STDOUT: %Dest.patt => type
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: !definition:
  803. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  804. // CHECK:STDOUT: %Self => constants.%Self.3
  805. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  806. // CHECK:STDOUT: %Convert => constants.%Convert.2
  807. // CHECK:STDOUT: %.1 => constants.%.6
  808. // CHECK:STDOUT: %.2 => constants.%.7
  809. // CHECK:STDOUT: }
  810. // CHECK:STDOUT:
  811. // CHECK:STDOUT: specific @F(constants.%Self.1) {}
  812. // CHECK:STDOUT:
  813. // CHECK:STDOUT: --- fail_return_in_class.carbon
  814. // CHECK:STDOUT:
  815. // CHECK:STDOUT: constants {
  816. // CHECK:STDOUT: %I: type = class_type @I [template]
  817. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  818. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  819. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  820. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  821. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  822. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  823. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  824. // CHECK:STDOUT: }
  825. // CHECK:STDOUT:
  826. // CHECK:STDOUT: imports {
  827. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  828. // CHECK:STDOUT: .Int32 = %import_ref
  829. // CHECK:STDOUT: import Core//prelude
  830. // CHECK:STDOUT: import Core//prelude/operators
  831. // CHECK:STDOUT: import Core//prelude/types
  832. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  833. // CHECK:STDOUT: import Core//prelude/operators/as
  834. // CHECK:STDOUT: import Core//prelude/operators/index
  835. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  836. // CHECK:STDOUT: import Core//prelude/operators/comparison
  837. // CHECK:STDOUT: import Core//prelude/types/bool
  838. // CHECK:STDOUT: }
  839. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  840. // CHECK:STDOUT: }
  841. // CHECK:STDOUT:
  842. // CHECK:STDOUT: file {
  843. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  844. // CHECK:STDOUT: .Core = imports.%Core
  845. // CHECK:STDOUT: .I = %I.decl
  846. // CHECK:STDOUT: }
  847. // CHECK:STDOUT: %Core.import = import Core
  848. // CHECK:STDOUT: %I.decl: type = class_decl @I [template = constants.%I] {} {}
  849. // CHECK:STDOUT: }
  850. // CHECK:STDOUT:
  851. // CHECK:STDOUT: class @I {
  852. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  853. // CHECK:STDOUT: %.loc9_21.1: type = value_of_initializer %int.make_type_32 [template = i32]
  854. // CHECK:STDOUT: %.loc9_21.2: type = converted %int.make_type_32, %.loc9_21.1 [template = i32]
  855. // CHECK:STDOUT: %T: type = bind_name T, %.loc9_21.2
  856. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  857. // CHECK:STDOUT: %return.patt: <error> = return_slot_pattern
  858. // CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, runtime_param0
  859. // CHECK:STDOUT: } {
  860. // CHECK:STDOUT: %T.ref: type = name_ref T, @I.%T
  861. // CHECK:STDOUT: %return.param: ref <error> = out_param runtime_param0
  862. // CHECK:STDOUT: %return: ref <error> = return_slot %return.param
  863. // CHECK:STDOUT: }
  864. // CHECK:STDOUT: %.loc15: <witness> = complete_type_witness %.2 [template = constants.%.3]
  865. // CHECK:STDOUT:
  866. // CHECK:STDOUT: !members:
  867. // CHECK:STDOUT: .Self = constants.%I
  868. // CHECK:STDOUT: .T = %T
  869. // CHECK:STDOUT: .F = %F.decl
  870. // CHECK:STDOUT: }
  871. // CHECK:STDOUT:
  872. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  873. // CHECK:STDOUT:
  874. // CHECK:STDOUT: fn @F() -> <error>;
  875. // CHECK:STDOUT:
  876. // CHECK:STDOUT: --- fail_return_in_package_scope.carbon
  877. // CHECK:STDOUT:
  878. // CHECK:STDOUT: constants {
  879. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  880. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  881. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  882. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  883. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  884. // CHECK:STDOUT: }
  885. // CHECK:STDOUT:
  886. // CHECK:STDOUT: imports {
  887. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  888. // CHECK:STDOUT: .Int32 = %import_ref
  889. // CHECK:STDOUT: import Core//prelude
  890. // CHECK:STDOUT: import Core//prelude/operators
  891. // CHECK:STDOUT: import Core//prelude/types
  892. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  893. // CHECK:STDOUT: import Core//prelude/operators/as
  894. // CHECK:STDOUT: import Core//prelude/operators/index
  895. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  896. // CHECK:STDOUT: import Core//prelude/operators/comparison
  897. // CHECK:STDOUT: import Core//prelude/types/bool
  898. // CHECK:STDOUT: }
  899. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  900. // CHECK:STDOUT: }
  901. // CHECK:STDOUT:
  902. // CHECK:STDOUT: file {
  903. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  904. // CHECK:STDOUT: .Core = imports.%Core
  905. // CHECK:STDOUT: .T = @__global_init.%T
  906. // CHECK:STDOUT: .F = %F.decl
  907. // CHECK:STDOUT: }
  908. // CHECK:STDOUT: %Core.import = import Core
  909. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  910. // CHECK:STDOUT: %return.patt: <error> = return_slot_pattern
  911. // CHECK:STDOUT: %return.param_patt: <error> = out_param_pattern %return.patt, runtime_param0
  912. // CHECK:STDOUT: } {
  913. // CHECK:STDOUT: %T.ref: type = name_ref T, @__global_init.%T
  914. // CHECK:STDOUT: %return.param: ref <error> = out_param runtime_param0
  915. // CHECK:STDOUT: %return: ref <error> = return_slot %return.param
  916. // CHECK:STDOUT: }
  917. // CHECK:STDOUT: }
  918. // CHECK:STDOUT:
  919. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  920. // CHECK:STDOUT:
  921. // CHECK:STDOUT: fn @F() -> <error>;
  922. // CHECK:STDOUT:
  923. // CHECK:STDOUT: fn @__global_init() {
  924. // CHECK:STDOUT: !entry:
  925. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  926. // CHECK:STDOUT: %.loc8_19.1: type = value_of_initializer %int.make_type_32 [template = i32]
  927. // CHECK:STDOUT: %.loc8_19.2: type = converted %int.make_type_32, %.loc8_19.1 [template = i32]
  928. // CHECK:STDOUT: %T: type = bind_name T, %.loc8_19.2
  929. // CHECK:STDOUT: return
  930. // CHECK:STDOUT: }
  931. // CHECK:STDOUT:
  932. // CHECK:STDOUT: --- fail_use_in_impl.carbon
  933. // CHECK:STDOUT:
  934. // CHECK:STDOUT: constants {
  935. // CHECK:STDOUT: %Empty.type: type = interface_type @Empty [template]
  936. // CHECK:STDOUT: %Self: %Empty.type = bind_symbolic_name Self, 0 [symbolic]
  937. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  938. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  939. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  940. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  941. // CHECK:STDOUT: %.3: <witness> = interface_witness () [template]
  942. // CHECK:STDOUT: }
  943. // CHECK:STDOUT:
  944. // CHECK:STDOUT: imports {
  945. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  946. // CHECK:STDOUT: .Int32 = %import_ref
  947. // CHECK:STDOUT: import Core//prelude
  948. // CHECK:STDOUT: import Core//prelude/operators
  949. // CHECK:STDOUT: import Core//prelude/types
  950. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  951. // CHECK:STDOUT: import Core//prelude/operators/as
  952. // CHECK:STDOUT: import Core//prelude/operators/index
  953. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  954. // CHECK:STDOUT: import Core//prelude/operators/comparison
  955. // CHECK:STDOUT: import Core//prelude/types/bool
  956. // CHECK:STDOUT: }
  957. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  958. // CHECK:STDOUT: }
  959. // CHECK:STDOUT:
  960. // CHECK:STDOUT: file {
  961. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  962. // CHECK:STDOUT: .Core = imports.%Core
  963. // CHECK:STDOUT: .Empty = %Empty.decl
  964. // CHECK:STDOUT: }
  965. // CHECK:STDOUT: %Core.import = import Core
  966. // CHECK:STDOUT: %Empty.decl: type = interface_decl @Empty [template = constants.%Empty.type] {} {}
  967. // CHECK:STDOUT: impl_decl @impl [template] {} {
  968. // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32]
  969. // CHECK:STDOUT: %.loc6_6.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32]
  970. // CHECK:STDOUT: %.loc6_6.2: type = converted %int.make_type_32.loc6, %.loc6_6.1 [template = i32]
  971. // CHECK:STDOUT: %Empty.ref: type = name_ref Empty, file.%Empty.decl [template = constants.%Empty.type]
  972. // CHECK:STDOUT: }
  973. // CHECK:STDOUT: }
  974. // CHECK:STDOUT:
  975. // CHECK:STDOUT: interface @Empty {
  976. // CHECK:STDOUT: %Self: %Empty.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  977. // CHECK:STDOUT:
  978. // CHECK:STDOUT: !members:
  979. // CHECK:STDOUT: .Self = %Self
  980. // CHECK:STDOUT: witness = ()
  981. // CHECK:STDOUT: }
  982. // CHECK:STDOUT:
  983. // CHECK:STDOUT: impl @impl: %.loc6_6.2 as %Empty.ref {
  984. // CHECK:STDOUT: %int.make_type_32.loc10: init type = call constants.%Int32() [template = i32]
  985. // CHECK:STDOUT: %.loc10_14.1: type = value_of_initializer %int.make_type_32.loc10 [template = i32]
  986. // CHECK:STDOUT: %.loc10_14.2: type = converted %int.make_type_32.loc10, %.loc10_14.1 [template = i32]
  987. // CHECK:STDOUT: %.loc10_20: i32 = int_literal 0 [template = constants.%.2]
  988. // CHECK:STDOUT: %Zero: i32 = bind_name Zero, %.loc10_20
  989. // CHECK:STDOUT: %.loc6_19: <witness> = interface_witness () [template = constants.%.3]
  990. // CHECK:STDOUT:
  991. // CHECK:STDOUT: !members:
  992. // CHECK:STDOUT: .Zero = %Zero
  993. // CHECK:STDOUT: witness = %.loc6_19
  994. // CHECK:STDOUT: }
  995. // CHECK:STDOUT:
  996. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  997. // CHECK:STDOUT: