stringify.carbon 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/stringify.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/stringify.carbon
  10. // --- fail_empty_params.carbon
  11. library "[[@TEST_NAME]]";
  12. class NoParams {}
  13. class EmptyParams() {}
  14. var v: NoParams;
  15. // CHECK:STDERR: fail_empty_params.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `NoParams` to `EmptyParams()` [ImplicitAsConversionFailure]
  16. // CHECK:STDERR: var w: EmptyParams() = v;
  17. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
  18. // CHECK:STDERR: fail_empty_params.carbon:[[@LINE+4]]:1: note: type `NoParams` does not implement interface `Core.ImplicitAs(EmptyParams())` [MissingImplInMemberAccessNote]
  19. // CHECK:STDERR: var w: EmptyParams() = v;
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. var w: EmptyParams() = v;
  23. // --- fail_nested.carbon
  24. library "[[@TEST_NAME]]";
  25. class Outer(T:! type) {
  26. class Inner(U:! type) {
  27. }
  28. }
  29. var v: Outer({}*);
  30. // TODO: It would be nice to include the `Outer({}*).` prefix in the name of `Inner`.
  31. // CHECK:STDERR: fail_nested.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `Outer({}*)` to `Inner({.a: i32}*)` [ImplicitAsConversionFailure]
  32. // CHECK:STDERR: var w: Outer({}*).Inner({.a: i32}*) = v;
  33. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. // CHECK:STDERR: fail_nested.carbon:[[@LINE+4]]:1: note: type `Outer({}*)` does not implement interface `Core.ImplicitAs(Inner({.a: i32}*))` [MissingImplInMemberAccessNote]
  35. // CHECK:STDERR: var w: Outer({}*).Inner({.a: i32}*) = v;
  36. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. // CHECK:STDERR:
  38. var w: Outer({}*).Inner({.a: i32}*) = v;
  39. // --- fail_int_value.carbon
  40. library "[[@TEST_NAME]]";
  41. class C(N:! i32) {}
  42. // CHECK:STDERR: fail_int_value.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `()` to `C(123)` [ImplicitAsConversionFailure]
  43. // CHECK:STDERR: var v: C(123) = ();
  44. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  45. // CHECK:STDERR: fail_int_value.carbon:[[@LINE+4]]:1: note: type `()` does not implement interface `Core.ImplicitAs(C(123))` [MissingImplInMemberAccessNote]
  46. // CHECK:STDERR: var v: C(123) = ();
  47. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  48. // CHECK:STDERR:
  49. var v: C(123) = ();
  50. // --- fail_class_param.carbon
  51. library "[[@TEST_NAME]]";
  52. class D {
  53. var a: i32;
  54. var b: i32;
  55. }
  56. class E(F:! D) {}
  57. // CHECK:STDERR: fail_class_param.carbon:[[@LINE+13]]:8: error: argument for generic parameter is not a compile-time constant [CompTimeArgumentNotConstant]
  58. // CHECK:STDERR: var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
  59. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  60. // CHECK:STDERR: fail_class_param.carbon:[[@LINE-5]]:9: note: initializing generic parameter `F` declared here [InitializingGenericParam]
  61. // CHECK:STDERR: class E(F:! D) {}
  62. // CHECK:STDERR: ^
  63. // CHECK:STDERR:
  64. // CHECK:STDERR: fail_class_param.carbon:[[@LINE+6]]:36: error: argument for generic parameter is not a compile-time constant [CompTimeArgumentNotConstant]
  65. // CHECK:STDERR: var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
  66. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~
  67. // CHECK:STDERR: fail_class_param.carbon:[[@LINE-12]]:9: note: initializing generic parameter `F` declared here [InitializingGenericParam]
  68. // CHECK:STDERR: class E(F:! D) {}
  69. // CHECK:STDERR: ^
  70. var g: E({.a = 1, .b = 2}) = {} as E({.a = 3, .b = 4} as D);
  71. // CHECK:STDOUT: --- fail_empty_params.carbon
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: constants {
  74. // CHECK:STDOUT: %NoParams: type = class_type @NoParams [template]
  75. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  76. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  77. // CHECK:STDOUT: %EmptyParams.type: type = generic_class_type @EmptyParams [template]
  78. // CHECK:STDOUT: %EmptyParams.generic: %EmptyParams.type = struct_value () [template]
  79. // CHECK:STDOUT: %EmptyParams: type = class_type @EmptyParams [template]
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: imports {
  83. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  84. // CHECK:STDOUT: .ImplicitAs = %import_ref.d44
  85. // CHECK:STDOUT: import Core//prelude
  86. // CHECK:STDOUT: import Core//prelude/...
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: file {
  91. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  92. // CHECK:STDOUT: .Core = imports.%Core
  93. // CHECK:STDOUT: .NoParams = %NoParams.decl
  94. // CHECK:STDOUT: .EmptyParams = %EmptyParams.decl
  95. // CHECK:STDOUT: .v = %v
  96. // CHECK:STDOUT: .w = %w
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: %Core.import = import Core
  99. // CHECK:STDOUT: %NoParams.decl: type = class_decl @NoParams [template = constants.%NoParams] {} {}
  100. // CHECK:STDOUT: %EmptyParams.decl: %EmptyParams.type = class_decl @EmptyParams [template = constants.%EmptyParams.generic] {} {}
  101. // CHECK:STDOUT: %v.var: ref %NoParams = var v
  102. // CHECK:STDOUT: %v: ref %NoParams = bind_name v, %v.var
  103. // CHECK:STDOUT: %w.var: ref %EmptyParams = var w
  104. // CHECK:STDOUT: %w: ref %EmptyParams = bind_name w, %w.var
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: class @NoParams {
  108. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  109. // CHECK:STDOUT: complete_type_witness = %complete_type
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: !members:
  112. // CHECK:STDOUT: .Self = constants.%NoParams
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: class @EmptyParams {
  116. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  117. // CHECK:STDOUT: complete_type_witness = %complete_type
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: !members:
  120. // CHECK:STDOUT: .Self = constants.%EmptyParams
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: fn @__global_init() {
  124. // CHECK:STDOUT: !entry:
  125. // CHECK:STDOUT: %v.ref: ref %NoParams = name_ref v, file.%v
  126. // CHECK:STDOUT: %.loc15: %EmptyParams = converted %v.ref, <error> [template = <error>]
  127. // CHECK:STDOUT: assign file.%w.var, <error>
  128. // CHECK:STDOUT: return
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: --- fail_nested.carbon
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: constants {
  134. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  135. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  136. // CHECK:STDOUT: %Outer.type: type = generic_class_type @Outer [template]
  137. // CHECK:STDOUT: %Outer.generic: %Outer.type = struct_value () [template]
  138. // CHECK:STDOUT: %Outer.9d6: type = class_type @Outer, @Outer(%T) [symbolic]
  139. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 1 [symbolic]
  140. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 1 [symbolic]
  141. // CHECK:STDOUT: %Inner.type.eae: type = generic_class_type @Inner, @Outer(%T) [symbolic]
  142. // CHECK:STDOUT: %Inner.generic.137: %Inner.type.eae = struct_value () [symbolic]
  143. // CHECK:STDOUT: %Inner.c71: type = class_type @Inner, @Inner(%T, %U) [symbolic]
  144. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  145. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  146. // CHECK:STDOUT: %ptr.c28: type = ptr_type %empty_struct_type [template]
  147. // CHECK:STDOUT: %Outer.614: type = class_type @Outer, @Outer(%ptr.c28) [template]
  148. // CHECK:STDOUT: %Inner.type.5d2: type = generic_class_type @Inner, @Outer(%ptr.c28) [template]
  149. // CHECK:STDOUT: %Inner.generic.8e6: %Inner.type.5d2 = struct_value () [template]
  150. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  151. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  152. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [template]
  153. // CHECK:STDOUT: %ptr.1bb: type = ptr_type %struct_type.a [template]
  154. // CHECK:STDOUT: %Inner.277: type = class_type @Inner, @Inner(%ptr.c28, %ptr.1bb) [template]
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: imports {
  158. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  159. // CHECK:STDOUT: .Int = %import_ref.485
  160. // CHECK:STDOUT: .ImplicitAs = %import_ref.d44
  161. // CHECK:STDOUT: import Core//prelude
  162. // CHECK:STDOUT: import Core//prelude/...
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: file {
  167. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  168. // CHECK:STDOUT: .Core = imports.%Core
  169. // CHECK:STDOUT: .Outer = %Outer.decl
  170. // CHECK:STDOUT: .v = %v
  171. // CHECK:STDOUT: .w = %w
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT: %Core.import = import Core
  174. // CHECK:STDOUT: %Outer.decl: %Outer.type = class_decl @Outer [template = constants.%Outer.generic] {
  175. // CHECK:STDOUT: %T.patt.loc4_13.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  176. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_13.1, runtime_param<invalid> [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  177. // CHECK:STDOUT: } {
  178. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  179. // CHECK:STDOUT: %T.loc4_13.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_13.2 (constants.%T)]
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT: %v.var: ref %Outer.614 = var v
  182. // CHECK:STDOUT: %v: ref %Outer.614 = bind_name v, %v.var
  183. // CHECK:STDOUT: %w.var: ref %Inner.277 = var w
  184. // CHECK:STDOUT: %w: ref %Inner.277 = bind_name w, %w.var
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: generic class @Outer(%T.loc4_13.1: type) {
  188. // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_13.2 (constants.%T)]
  189. // CHECK:STDOUT: %T.patt.loc4_13.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)]
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: !definition:
  192. // CHECK:STDOUT: %Inner.type: type = generic_class_type @Inner, @Outer(%T.loc4_13.2) [symbolic = %Inner.type (constants.%Inner.type.eae)]
  193. // CHECK:STDOUT: %Inner.generic: @Outer.%Inner.type (%Inner.type.eae) = struct_value () [symbolic = %Inner.generic (constants.%Inner.generic.137)]
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: class {
  196. // CHECK:STDOUT: %Inner.decl: @Outer.%Inner.type (%Inner.type.eae) = class_decl @Inner [symbolic = @Outer.%Inner.generic (constants.%Inner.generic.137)] {
  197. // CHECK:STDOUT: %U.patt.loc5_15.1: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_15.2 (constants.%U.patt)]
  198. // CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc5_15.1, runtime_param<invalid> [symbolic = %U.patt.loc5_15.2 (constants.%U.patt)]
  199. // CHECK:STDOUT: } {
  200. // CHECK:STDOUT: %U.param: type = value_param runtime_param<invalid>
  201. // CHECK:STDOUT: %U.loc5_15.1: type = bind_symbolic_name U, 1, %U.param [symbolic = %U.loc5_15.2 (constants.%U)]
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  204. // CHECK:STDOUT: complete_type_witness = %complete_type
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: !members:
  207. // CHECK:STDOUT: .Self = constants.%Outer.9d6
  208. // CHECK:STDOUT: .Inner = %Inner.decl
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: generic class @Inner(@Outer.%T.loc4_13.1: type, %U.loc5_15.1: type) {
  213. // CHECK:STDOUT: %U.loc5_15.2: type = bind_symbolic_name U, 1 [symbolic = %U.loc5_15.2 (constants.%U)]
  214. // CHECK:STDOUT: %U.patt.loc5_15.2: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc5_15.2 (constants.%U.patt)]
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: !definition:
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: class {
  219. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  220. // CHECK:STDOUT: complete_type_witness = %complete_type
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: !members:
  223. // CHECK:STDOUT: .Self = constants.%Inner.c71
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: fn @__global_init() {
  228. // CHECK:STDOUT: !entry:
  229. // CHECK:STDOUT: %v.ref: ref %Outer.614 = name_ref v, file.%v
  230. // CHECK:STDOUT: %.loc19: %Inner.277 = converted %v.ref, <error> [template = <error>]
  231. // CHECK:STDOUT: assign file.%w.var, <error>
  232. // CHECK:STDOUT: return
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: specific @Outer(constants.%T) {
  236. // CHECK:STDOUT: %T.loc4_13.2 => constants.%T
  237. // CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%T
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: specific @Inner(constants.%T, constants.%U) {
  241. // CHECK:STDOUT: %U.loc5_15.2 => constants.%U
  242. // CHECK:STDOUT: %U.patt.loc5_15.2 => constants.%U
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: specific @Outer(%T.loc4_13.2) {}
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: specific @Outer(constants.%ptr.c28) {
  248. // CHECK:STDOUT: %T.loc4_13.2 => constants.%ptr.c28
  249. // CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%ptr.c28
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: !definition:
  252. // CHECK:STDOUT: %Inner.type => constants.%Inner.type.5d2
  253. // CHECK:STDOUT: %Inner.generic => constants.%Inner.generic.8e6
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: specific @Inner(constants.%ptr.c28, constants.%ptr.1bb) {
  257. // CHECK:STDOUT: %U.loc5_15.2 => constants.%ptr.1bb
  258. // CHECK:STDOUT: %U.patt.loc5_15.2 => constants.%ptr.1bb
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: !definition:
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: --- fail_int_value.carbon
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: constants {
  266. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  267. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  268. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  269. // CHECK:STDOUT: %N.51e: %i32 = bind_symbolic_name N, 0 [symbolic]
  270. // CHECK:STDOUT: %N.patt.8e2: %i32 = symbolic_binding_pattern N, 0 [symbolic]
  271. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  272. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [template]
  273. // CHECK:STDOUT: %C.506: type = class_type @C, @C(%N.51e) [symbolic]
  274. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  275. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  276. // CHECK:STDOUT: %int_123.f7f: %i32 = int_value 123 [template]
  277. // CHECK:STDOUT: %C.4c3: type = class_type @C, @C(%int_123.f7f) [template]
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: imports {
  281. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  282. // CHECK:STDOUT: .Int = %import_ref.485
  283. // CHECK:STDOUT: .ImplicitAs = %import_ref.d44
  284. // CHECK:STDOUT: import Core//prelude
  285. // CHECK:STDOUT: import Core//prelude/...
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: file {
  290. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  291. // CHECK:STDOUT: .Core = imports.%Core
  292. // CHECK:STDOUT: .C = %C.decl
  293. // CHECK:STDOUT: .v = %v
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: %Core.import = import Core
  296. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.generic] {
  297. // CHECK:STDOUT: %N.patt.loc4_9.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc4_9.2 (constants.%N.patt.8e2)]
  298. // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc4_9.1, runtime_param<invalid> [symbolic = %N.patt.loc4_9.2 (constants.%N.patt.8e2)]
  299. // CHECK:STDOUT: } {
  300. // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<invalid>
  301. // CHECK:STDOUT: %.loc4: type = splice_block %i32 [template = constants.%i32] {
  302. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  303. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT: %N.loc4_9.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc4_9.2 (constants.%N.51e)]
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT: %v.var: ref %C.4c3 = var v
  308. // CHECK:STDOUT: %v: ref %C.4c3 = bind_name v, %v.var
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: generic class @C(%N.loc4_9.1: %i32) {
  312. // CHECK:STDOUT: %N.loc4_9.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc4_9.2 (constants.%N.51e)]
  313. // CHECK:STDOUT: %N.patt.loc4_9.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc4_9.2 (constants.%N.patt.8e2)]
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: !definition:
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: class {
  318. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  319. // CHECK:STDOUT: complete_type_witness = %complete_type
  320. // CHECK:STDOUT:
  321. // CHECK:STDOUT: !members:
  322. // CHECK:STDOUT: .Self = constants.%C.506
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: fn @__global_init() {
  327. // CHECK:STDOUT: !entry:
  328. // CHECK:STDOUT: %.loc13_18: %empty_tuple.type = tuple_literal ()
  329. // CHECK:STDOUT: %.loc13_19: %C.4c3 = converted %.loc13_18, <error> [template = <error>]
  330. // CHECK:STDOUT: assign file.%v.var, <error>
  331. // CHECK:STDOUT: return
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: specific @C(constants.%N.51e) {
  335. // CHECK:STDOUT: %N.loc4_9.2 => constants.%N.51e
  336. // CHECK:STDOUT: %N.patt.loc4_9.2 => constants.%N.51e
  337. // CHECK:STDOUT: }
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: specific @C(constants.%int_123.f7f) {
  340. // CHECK:STDOUT: %N.loc4_9.2 => constants.%int_123.f7f
  341. // CHECK:STDOUT: %N.patt.loc4_9.2 => constants.%int_123.f7f
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: !definition:
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: --- fail_class_param.carbon
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: constants {
  349. // CHECK:STDOUT: %D: type = class_type @D [template]
  350. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  351. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  352. // CHECK:STDOUT: %D.elem: type = unbound_element_type %D, %i32 [template]
  353. // CHECK:STDOUT: %struct_type.a.b.501: type = struct_type {.a: %i32, .b: %i32} [template]
  354. // CHECK:STDOUT: %complete_type.705: <witness> = complete_type_witness %struct_type.a.b.501 [template]
  355. // CHECK:STDOUT: %F: %D = bind_symbolic_name F, 0 [symbolic]
  356. // CHECK:STDOUT: %F.patt: %D = symbolic_binding_pattern F, 0 [symbolic]
  357. // CHECK:STDOUT: %E.type: type = generic_class_type @E [template]
  358. // CHECK:STDOUT: %E.generic: %E.type = struct_value () [template]
  359. // CHECK:STDOUT: %E: type = class_type @E, @E(%F) [symbolic]
  360. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  361. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  362. // CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [template]
  363. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  364. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%import_ref.a5b), @impl.1(%int_32) [template]
  365. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  366. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  367. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  368. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template]
  369. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [template]
  370. // CHECK:STDOUT: %Convert.specific_fn.b42: <specific function> = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template]
  371. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template]
  372. // CHECK:STDOUT: %Convert.bound.ac3: <bound method> = bound_method %int_4.0c1, %Convert.956 [template]
  373. // CHECK:STDOUT: %Convert.specific_fn.450: <specific function> = specific_function %Convert.bound.ac3, @Convert.2(%int_32) [template]
  374. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [template]
  375. // CHECK:STDOUT: %D.val.835: %D = struct_value (%int_3.822, %int_4.940) [template]
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: imports {
  379. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  380. // CHECK:STDOUT: .Int = %import_ref.485
  381. // CHECK:STDOUT: .ImplicitAs = %import_ref.d44
  382. // CHECK:STDOUT: import Core//prelude
  383. // CHECK:STDOUT: import Core//prelude/...
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: file {
  388. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  389. // CHECK:STDOUT: .Core = imports.%Core
  390. // CHECK:STDOUT: .D = %D.decl
  391. // CHECK:STDOUT: .E = %E.decl
  392. // CHECK:STDOUT: .g = %g
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT: %Core.import = import Core
  395. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  396. // CHECK:STDOUT: %E.decl: %E.type = class_decl @E [template = constants.%E.generic] {
  397. // CHECK:STDOUT: %F.patt.loc9_9.1: %D = symbolic_binding_pattern F, 0 [symbolic = %F.patt.loc9_9.2 (constants.%F.patt)]
  398. // CHECK:STDOUT: %F.param_patt: %D = value_param_pattern %F.patt.loc9_9.1, runtime_param<invalid> [symbolic = %F.patt.loc9_9.2 (constants.%F.patt)]
  399. // CHECK:STDOUT: } {
  400. // CHECK:STDOUT: %F.param: %D = value_param runtime_param<invalid>
  401. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  402. // CHECK:STDOUT: %F.loc9_9.1: %D = bind_symbolic_name F, 0, %F.param [symbolic = %F.loc9_9.2 (constants.%F)]
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT: %g.var: ref <error> = var g
  405. // CHECK:STDOUT: %g: ref <error> = bind_name g, %g.var
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: class @D {
  409. // CHECK:STDOUT: %.loc5: %D.elem = field_decl a, element0 [template]
  410. // CHECK:STDOUT: %.loc6: %D.elem = field_decl b, element1 [template]
  411. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.a.b.501 [template = constants.%complete_type.705]
  412. // CHECK:STDOUT: complete_type_witness = %complete_type
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: !members:
  415. // CHECK:STDOUT: .Self = constants.%D
  416. // CHECK:STDOUT: .a = %.loc5
  417. // CHECK:STDOUT: .b = %.loc6
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: generic class @E(%F.loc9_9.1: %D) {
  421. // CHECK:STDOUT: %F.loc9_9.2: %D = bind_symbolic_name F, 0 [symbolic = %F.loc9_9.2 (constants.%F)]
  422. // CHECK:STDOUT: %F.patt.loc9_9.2: %D = symbolic_binding_pattern F, 0 [symbolic = %F.patt.loc9_9.2 (constants.%F.patt)]
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: !definition:
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: class {
  427. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  428. // CHECK:STDOUT: complete_type_witness = %complete_type
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: !members:
  431. // CHECK:STDOUT: .Self = constants.%E
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT: }
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: fn @__global_init() {
  436. // CHECK:STDOUT: !entry:
  437. // CHECK:STDOUT: %.loc24_31: %empty_struct_type = struct_literal ()
  438. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E.generic]
  439. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  440. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  441. // CHECK:STDOUT: %.loc24_53.1: %struct_type.a.b.cfd = struct_literal (%int_3, %int_4)
  442. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  443. // CHECK:STDOUT: %impl.elem0.loc24_53.1: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  444. // CHECK:STDOUT: %Convert.bound.loc24_53.1: <bound method> = bound_method %int_3, %impl.elem0.loc24_53.1 [template = constants.%Convert.bound.b30]
  445. // CHECK:STDOUT: %Convert.specific_fn.loc24_53.1: <specific function> = specific_function %Convert.bound.loc24_53.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.b42]
  446. // CHECK:STDOUT: %int.convert_checked.loc24_53.1: init %i32 = call %Convert.specific_fn.loc24_53.1(%int_3) [template = constants.%int_3.822]
  447. // CHECK:STDOUT: %.loc24_53.2: init %i32 = converted %int_3, %int.convert_checked.loc24_53.1 [template = constants.%int_3.822]
  448. // CHECK:STDOUT: %.loc24_53.3: ref %D = temporary_storage
  449. // CHECK:STDOUT: %.loc24_53.4: ref %i32 = class_element_access %.loc24_53.3, element0
  450. // CHECK:STDOUT: %.loc24_53.5: init %i32 = initialize_from %.loc24_53.2 to %.loc24_53.4 [template = constants.%int_3.822]
  451. // CHECK:STDOUT: %impl.elem0.loc24_53.2: %Convert.type.1b6 = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  452. // CHECK:STDOUT: %Convert.bound.loc24_53.2: <bound method> = bound_method %int_4, %impl.elem0.loc24_53.2 [template = constants.%Convert.bound.ac3]
  453. // CHECK:STDOUT: %Convert.specific_fn.loc24_53.2: <specific function> = specific_function %Convert.bound.loc24_53.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.450]
  454. // CHECK:STDOUT: %int.convert_checked.loc24_53.2: init %i32 = call %Convert.specific_fn.loc24_53.2(%int_4) [template = constants.%int_4.940]
  455. // CHECK:STDOUT: %.loc24_53.6: init %i32 = converted %int_4, %int.convert_checked.loc24_53.2 [template = constants.%int_4.940]
  456. // CHECK:STDOUT: %.loc24_53.7: ref %i32 = class_element_access %.loc24_53.3, element1
  457. // CHECK:STDOUT: %.loc24_53.8: init %i32 = initialize_from %.loc24_53.6 to %.loc24_53.7 [template = constants.%int_4.940]
  458. // CHECK:STDOUT: %.loc24_53.9: init %D = class_init (%.loc24_53.5, %.loc24_53.8), %.loc24_53.3 [template = constants.%D.val.835]
  459. // CHECK:STDOUT: %.loc24_53.10: ref %D = temporary %.loc24_53.3, %.loc24_53.9
  460. // CHECK:STDOUT: %.loc24_55.1: ref %D = converted %.loc24_53.1, %.loc24_53.10
  461. // CHECK:STDOUT: %.loc24_55.2: %D = bind_value %.loc24_55.1
  462. // CHECK:STDOUT: assign file.%g.var, <error>
  463. // CHECK:STDOUT: return
  464. // CHECK:STDOUT: }
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: specific @E(constants.%F) {
  467. // CHECK:STDOUT: %F.loc9_9.2 => constants.%F
  468. // CHECK:STDOUT: %F.patt.loc9_9.2 => constants.%F
  469. // CHECK:STDOUT: }
  470. // CHECK:STDOUT: