import.carbon 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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/struct/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/import.carbon
  10. // --- implicit.carbon
  11. package Implicit;
  12. var a_ref: {.a: i32} = {.a = 0};
  13. var b_ref: {.a: {.b: i32, .c: (i32,)}, .d: i32} =
  14. {.a = {.b = 0, .c = (0,)}, .d = 0};
  15. class C(S:! {.a: i32, .b: i32}) {}
  16. fn F() -> C({.a = 1, .b = 2});
  17. // --- implicit.impl.carbon
  18. impl package Implicit;
  19. var a: {.a: i32} = a_ref;
  20. var b: {.a: {.b: i32, .c: (i32,)}, .d: i32} = b_ref;
  21. var c: C({.a = 1, .b = 2}) = F();
  22. // --- fail_bad_type.impl.carbon
  23. impl package Implicit;
  24. // CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+8]]:14: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
  25. // CHECK:STDERR: var c_bad: C({.c = 1, .d = 2}) = F();
  26. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  27. // CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE-4]]:6: in import [InImport]
  28. // CHECK:STDERR: implicit.carbon:8:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
  29. // CHECK:STDERR: class C(S:! {.a: i32, .b: i32}) {}
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. // CHECK:STDERR:
  32. var c_bad: C({.c = 1, .d = 2}) = F();
  33. // --- fail_bad_value.impl.carbon
  34. impl package Implicit;
  35. // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+6]]:1: error: cannot implicitly convert from `C(<cannot stringify inst+46>)` to `C(<cannot stringify inst+34>)` [ImplicitAsConversionFailure]
  36. // CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F();
  37. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+3]]:1: note: type `C(<cannot stringify inst+46>)` does not implement interface `ImplicitAs(C(<cannot stringify inst+34>))` [MissingImplInMemberAccessNote]
  39. // CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F();
  40. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. var c_bad: C({.a = 3, .b = 4}) = F();
  42. // CHECK:STDOUT: --- implicit.carbon
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: constants {
  45. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  46. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  47. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  48. // CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
  49. // CHECK:STDOUT: %.2: i32 = int_value 0 [template]
  50. // CHECK:STDOUT: %struct.1: %.1 = struct_value (%.2) [template]
  51. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  52. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (i32) [template]
  53. // CHECK:STDOUT: %.3: type = struct_type {.b: i32, .c: %tuple.type.2} [template]
  54. // CHECK:STDOUT: %.4: type = struct_type {.a: %.3, .d: i32} [template]
  55. // CHECK:STDOUT: %.5: type = ptr_type %.3 [template]
  56. // CHECK:STDOUT: %.6: type = struct_type {.a: %.5, .d: i32} [template]
  57. // CHECK:STDOUT: %.7: type = ptr_type %.6 [template]
  58. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.2) [template]
  59. // CHECK:STDOUT: %struct.2: %.3 = struct_value (%.2, %tuple) [template]
  60. // CHECK:STDOUT: %struct.3: %.4 = struct_value (%struct.2, %.2) [template]
  61. // CHECK:STDOUT: %.8: type = struct_type {.a: i32, .b: i32} [template]
  62. // CHECK:STDOUT: %S: %.8 = bind_symbolic_name S, 0 [symbolic]
  63. // CHECK:STDOUT: %S.patt: %.8 = symbolic_binding_pattern S, 0 [symbolic]
  64. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  65. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  66. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic]
  67. // CHECK:STDOUT: %.9: type = struct_type {} [template]
  68. // CHECK:STDOUT: %.10: <witness> = complete_type_witness %.9 [template]
  69. // CHECK:STDOUT: %.11: i32 = int_value 1 [template]
  70. // CHECK:STDOUT: %.12: i32 = int_value 2 [template]
  71. // CHECK:STDOUT: %.13: type = ptr_type %.8 [template]
  72. // CHECK:STDOUT: %struct.4: %.8 = struct_value (%.11, %.12) [template]
  73. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct.4) [template]
  74. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  75. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: imports {
  79. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  80. // CHECK:STDOUT: .Int32 = %import_ref
  81. // CHECK:STDOUT: import Core//prelude
  82. // CHECK:STDOUT: import Core//prelude/...
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: file {
  88. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  89. // CHECK:STDOUT: .Core = imports.%Core
  90. // CHECK:STDOUT: .a_ref = %a_ref
  91. // CHECK:STDOUT: .b_ref = %b_ref
  92. // CHECK:STDOUT: .C = %C.decl
  93. // CHECK:STDOUT: .F = %F.decl
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: %Core.import = import Core
  96. // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
  97. // CHECK:STDOUT: %.loc4_17.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
  98. // CHECK:STDOUT: %.loc4_17.2: type = converted %int.make_type_32.loc4, %.loc4_17.1 [template = i32]
  99. // CHECK:STDOUT: %.loc4_20: type = struct_type {.a: i32} [template = constants.%.1]
  100. // CHECK:STDOUT: %a_ref.var: ref %.1 = var a_ref
  101. // CHECK:STDOUT: %a_ref: ref %.1 = bind_name a_ref, %a_ref.var
  102. // CHECK:STDOUT: %int.make_type_32.loc5_22: init type = call constants.%Int32() [template = i32]
  103. // CHECK:STDOUT: %.loc5_22.1: type = value_of_initializer %int.make_type_32.loc5_22 [template = i32]
  104. // CHECK:STDOUT: %.loc5_22.2: type = converted %int.make_type_32.loc5_22, %.loc5_22.1 [template = i32]
  105. // CHECK:STDOUT: %int.make_type_32.loc5_32: init type = call constants.%Int32() [template = i32]
  106. // CHECK:STDOUT: %.loc5_36.1: %tuple.type.1 = tuple_literal (%int.make_type_32.loc5_32)
  107. // CHECK:STDOUT: %.loc5_36.2: type = value_of_initializer %int.make_type_32.loc5_32 [template = i32]
  108. // CHECK:STDOUT: %.loc5_36.3: type = converted %int.make_type_32.loc5_32, %.loc5_36.2 [template = i32]
  109. // CHECK:STDOUT: %.loc5_36.4: type = converted %.loc5_36.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  110. // CHECK:STDOUT: %.loc5_37: type = struct_type {.b: i32, .c: %tuple.type.2} [template = constants.%.3]
  111. // CHECK:STDOUT: %int.make_type_32.loc5_44: init type = call constants.%Int32() [template = i32]
  112. // CHECK:STDOUT: %.loc5_44.1: type = value_of_initializer %int.make_type_32.loc5_44 [template = i32]
  113. // CHECK:STDOUT: %.loc5_44.2: type = converted %int.make_type_32.loc5_44, %.loc5_44.1 [template = i32]
  114. // CHECK:STDOUT: %.loc5_47: type = struct_type {.a: %.3, .d: i32} [template = constants.%.4]
  115. // CHECK:STDOUT: %b_ref.var: ref %.4 = var b_ref
  116. // CHECK:STDOUT: %b_ref: ref %.4 = bind_name b_ref, %b_ref.var
  117. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] {
  118. // CHECK:STDOUT: %S.patt.loc8_9.1: %.8 = symbolic_binding_pattern S, 0 [symbolic = %S.patt.loc8_9.2 (constants.%S.patt)]
  119. // CHECK:STDOUT: %S.param_patt: %.8 = value_param_pattern %S.patt.loc8_9.1, runtime_param<invalid> [symbolic = %S.patt.loc8_9.2 (constants.%S.patt)]
  120. // CHECK:STDOUT: } {
  121. // CHECK:STDOUT: %int.make_type_32.loc8_18: init type = call constants.%Int32() [template = i32]
  122. // CHECK:STDOUT: %.loc8_18.1: type = value_of_initializer %int.make_type_32.loc8_18 [template = i32]
  123. // CHECK:STDOUT: %.loc8_18.2: type = converted %int.make_type_32.loc8_18, %.loc8_18.1 [template = i32]
  124. // CHECK:STDOUT: %int.make_type_32.loc8_27: init type = call constants.%Int32() [template = i32]
  125. // CHECK:STDOUT: %.loc8_27.1: type = value_of_initializer %int.make_type_32.loc8_27 [template = i32]
  126. // CHECK:STDOUT: %.loc8_27.2: type = converted %int.make_type_32.loc8_27, %.loc8_27.1 [template = i32]
  127. // CHECK:STDOUT: %.loc8_30: type = struct_type {.a: i32, .b: i32} [template = constants.%.8]
  128. // CHECK:STDOUT: %S.param: %.8 = value_param runtime_param<invalid>
  129. // CHECK:STDOUT: %S.loc8_9.1: %.8 = bind_symbolic_name S, 0, %S.param [symbolic = %S.loc8_9.2 (constants.%S)]
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  132. // CHECK:STDOUT: %return.patt: %C.3 = return_slot_pattern
  133. // CHECK:STDOUT: %return.param_patt: %C.3 = out_param_pattern %return.patt, runtime_param0
  134. // CHECK:STDOUT: } {
  135. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C.1]
  136. // CHECK:STDOUT: %.loc9_19: i32 = int_value 1 [template = constants.%.11]
  137. // CHECK:STDOUT: %.loc9_27: i32 = int_value 2 [template = constants.%.12]
  138. // CHECK:STDOUT: %.loc9_28: %.8 = struct_literal (%.loc9_19, %.loc9_27)
  139. // CHECK:STDOUT: %struct: %.8 = struct_value (%.loc9_19, %.loc9_27) [template = constants.%struct.4]
  140. // CHECK:STDOUT: %.loc9_12: %.8 = converted %.loc9_28, %struct [template = constants.%struct.4]
  141. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%struct.4) [template = constants.%C.3]
  142. // CHECK:STDOUT: %return.param: ref %C.3 = out_param runtime_param0
  143. // CHECK:STDOUT: %return: ref %C.3 = return_slot %return.param
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: generic class @C(%S.loc8_9.1: %.8) {
  148. // CHECK:STDOUT: %S.loc8_9.2: %.8 = bind_symbolic_name S, 0 [symbolic = %S.loc8_9.2 (constants.%S)]
  149. // CHECK:STDOUT: %S.patt.loc8_9.2: %.8 = symbolic_binding_pattern S, 0 [symbolic = %S.patt.loc8_9.2 (constants.%S.patt)]
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: !definition:
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: class {
  154. // CHECK:STDOUT: %.loc8_34: <witness> = complete_type_witness %.9 [template = constants.%.10]
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: !members:
  157. // CHECK:STDOUT: .Self = constants.%C.2
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: fn @F() -> %C.3;
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: fn @__global_init() {
  166. // CHECK:STDOUT: !entry:
  167. // CHECK:STDOUT: %.loc4_30: i32 = int_value 0 [template = constants.%.2]
  168. // CHECK:STDOUT: %.loc4_31.1: %.1 = struct_literal (%.loc4_30)
  169. // CHECK:STDOUT: %.loc4_31.2: init %.1 = struct_init (%.loc4_30) to file.%a_ref.var [template = constants.%struct.1]
  170. // CHECK:STDOUT: %.loc4_32: init %.1 = converted %.loc4_31.1, %.loc4_31.2 [template = constants.%struct.1]
  171. // CHECK:STDOUT: assign file.%a_ref.var, %.loc4_32
  172. // CHECK:STDOUT: %.loc6_17: i32 = int_value 0 [template = constants.%.2]
  173. // CHECK:STDOUT: %.loc6_26: i32 = int_value 0 [template = constants.%.2]
  174. // CHECK:STDOUT: %.loc6_28.1: %tuple.type.2 = tuple_literal (%.loc6_26)
  175. // CHECK:STDOUT: %.loc6_29.1: %.3 = struct_literal (%.loc6_17, %.loc6_28.1)
  176. // CHECK:STDOUT: %.loc6_37: i32 = int_value 0 [template = constants.%.2]
  177. // CHECK:STDOUT: %.loc6_38.1: %.4 = struct_literal (%.loc6_29.1, %.loc6_37)
  178. // CHECK:STDOUT: %.loc6_38.2: ref %.3 = struct_access file.%b_ref.var, element0
  179. // CHECK:STDOUT: %.loc6_29.2: ref i32 = struct_access %.loc6_38.2, element0
  180. // CHECK:STDOUT: %.loc6_29.3: init i32 = initialize_from %.loc6_17 to %.loc6_29.2 [template = constants.%.2]
  181. // CHECK:STDOUT: %.loc6_29.4: ref %tuple.type.2 = struct_access %.loc6_38.2, element1
  182. // CHECK:STDOUT: %.loc6_28.2: init %tuple.type.2 = tuple_init (%.loc6_26) to %.loc6_29.4 [template = constants.%tuple]
  183. // CHECK:STDOUT: %.loc6_29.5: init %tuple.type.2 = converted %.loc6_28.1, %.loc6_28.2 [template = constants.%tuple]
  184. // CHECK:STDOUT: %.loc6_29.6: init %tuple.type.2 = initialize_from %.loc6_29.5 to %.loc6_29.4 [template = constants.%tuple]
  185. // CHECK:STDOUT: %.loc6_29.7: init %.3 = struct_init (%.loc6_29.3, %.loc6_29.6) to %.loc6_38.2 [template = constants.%struct.2]
  186. // CHECK:STDOUT: %.loc6_38.3: init %.3 = converted %.loc6_29.1, %.loc6_29.7 [template = constants.%struct.2]
  187. // CHECK:STDOUT: %.loc6_38.4: ref i32 = struct_access file.%b_ref.var, element1
  188. // CHECK:STDOUT: %.loc6_38.5: init i32 = initialize_from %.loc6_37 to %.loc6_38.4 [template = constants.%.2]
  189. // CHECK:STDOUT: %.loc6_38.6: init %.4 = struct_init (%.loc6_38.3, %.loc6_38.5) to file.%b_ref.var [template = constants.%struct.3]
  190. // CHECK:STDOUT: %.loc6_39: init %.4 = converted %.loc6_38.1, %.loc6_38.6 [template = constants.%struct.3]
  191. // CHECK:STDOUT: assign file.%b_ref.var, %.loc6_39
  192. // CHECK:STDOUT: return
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: specific @C(constants.%S) {
  196. // CHECK:STDOUT: %S.loc8_9.2 => constants.%S
  197. // CHECK:STDOUT: %S.patt.loc8_9.2 => constants.%S
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: specific @C(constants.%struct.4) {
  201. // CHECK:STDOUT: %S.loc8_9.2 => constants.%struct.4
  202. // CHECK:STDOUT: %S.patt.loc8_9.2 => constants.%struct.4
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: --- implicit.impl.carbon
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: constants {
  208. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  209. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  210. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  211. // CHECK:STDOUT: %.1: type = struct_type {.a: i32} [template]
  212. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  213. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (i32) [template]
  214. // CHECK:STDOUT: %.2: type = struct_type {.b: i32, .c: %tuple.type.2} [template]
  215. // CHECK:STDOUT: %.3: type = struct_type {.a: %.2, .d: i32} [template]
  216. // CHECK:STDOUT: %.4: type = ptr_type %.2 [template]
  217. // CHECK:STDOUT: %.5: type = struct_type {.a: %.4, .d: i32} [template]
  218. // CHECK:STDOUT: %.6: type = ptr_type %.5 [template]
  219. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  220. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  221. // CHECK:STDOUT: %.7: type = struct_type {} [template]
  222. // CHECK:STDOUT: %.8: <witness> = complete_type_witness %.7 [template]
  223. // CHECK:STDOUT: %.9: type = struct_type {.a: i32, .b: i32} [template]
  224. // CHECK:STDOUT: %S: %.9 = bind_symbolic_name S, 0 [symbolic]
  225. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic]
  226. // CHECK:STDOUT: %S.patt: %.9 = symbolic_binding_pattern S, 0 [symbolic]
  227. // CHECK:STDOUT: %.10: i32 = int_value 1 [template]
  228. // CHECK:STDOUT: %.11: i32 = int_value 2 [template]
  229. // CHECK:STDOUT: %.12: type = ptr_type %.9 [template]
  230. // CHECK:STDOUT: %struct: %.9 = struct_value (%.10, %.11) [template]
  231. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct) [template]
  232. // CHECK:STDOUT: %.13: type = ptr_type %.7 [template]
  233. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  234. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: imports {
  238. // CHECK:STDOUT: %import_ref.1: ref %.1 = import_ref Implicit//default, inst+17, loaded
  239. // CHECK:STDOUT: %import_ref.2: ref %.3 = import_ref Implicit//default, inst+47, loaded
  240. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+86, loaded [template = constants.%C.1]
  241. // CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+111, loaded [template = constants.%F]
  242. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  243. // CHECK:STDOUT: .Int32 = %import_ref.5
  244. // CHECK:STDOUT: import Core//prelude
  245. // CHECK:STDOUT: import Core//prelude/...
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT: %import_ref.5: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32]
  248. // CHECK:STDOUT: %import_ref.6 = import_ref Implicit//default, inst+91, unloaded
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: file {
  252. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  253. // CHECK:STDOUT: .a_ref = imports.%import_ref.1
  254. // CHECK:STDOUT: .b_ref = imports.%import_ref.2
  255. // CHECK:STDOUT: .C = imports.%import_ref.3
  256. // CHECK:STDOUT: .F = imports.%import_ref.4
  257. // CHECK:STDOUT: .Core = imports.%Core
  258. // CHECK:STDOUT: .a = %a
  259. // CHECK:STDOUT: .b = %b
  260. // CHECK:STDOUT: .c = %c
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT: %Implicit.import = import Implicit
  263. // CHECK:STDOUT: %default.import = import <invalid>
  264. // CHECK:STDOUT: %Core.import = import Core
  265. // CHECK:STDOUT: %int.make_type_32.loc4: init type = call constants.%Int32() [template = i32]
  266. // CHECK:STDOUT: %.loc4_13.1: type = value_of_initializer %int.make_type_32.loc4 [template = i32]
  267. // CHECK:STDOUT: %.loc4_13.2: type = converted %int.make_type_32.loc4, %.loc4_13.1 [template = i32]
  268. // CHECK:STDOUT: %.loc4_16: type = struct_type {.a: i32} [template = constants.%.1]
  269. // CHECK:STDOUT: %a.var: ref %.1 = var a
  270. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  271. // CHECK:STDOUT: %int.make_type_32.loc5_18: init type = call constants.%Int32() [template = i32]
  272. // CHECK:STDOUT: %.loc5_18.1: type = value_of_initializer %int.make_type_32.loc5_18 [template = i32]
  273. // CHECK:STDOUT: %.loc5_18.2: type = converted %int.make_type_32.loc5_18, %.loc5_18.1 [template = i32]
  274. // CHECK:STDOUT: %int.make_type_32.loc5_28: init type = call constants.%Int32() [template = i32]
  275. // CHECK:STDOUT: %.loc5_32.1: %tuple.type.1 = tuple_literal (%int.make_type_32.loc5_28)
  276. // CHECK:STDOUT: %.loc5_32.2: type = value_of_initializer %int.make_type_32.loc5_28 [template = i32]
  277. // CHECK:STDOUT: %.loc5_32.3: type = converted %int.make_type_32.loc5_28, %.loc5_32.2 [template = i32]
  278. // CHECK:STDOUT: %.loc5_32.4: type = converted %.loc5_32.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  279. // CHECK:STDOUT: %.loc5_33: type = struct_type {.b: i32, .c: %tuple.type.2} [template = constants.%.2]
  280. // CHECK:STDOUT: %int.make_type_32.loc5_40: init type = call constants.%Int32() [template = i32]
  281. // CHECK:STDOUT: %.loc5_40.1: type = value_of_initializer %int.make_type_32.loc5_40 [template = i32]
  282. // CHECK:STDOUT: %.loc5_40.2: type = converted %int.make_type_32.loc5_40, %.loc5_40.1 [template = i32]
  283. // CHECK:STDOUT: %.loc5_43: type = struct_type {.a: %.2, .d: i32} [template = constants.%.3]
  284. // CHECK:STDOUT: %b.var: ref %.3 = var b
  285. // CHECK:STDOUT: %b: ref %.3 = bind_name b, %b.var
  286. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1]
  287. // CHECK:STDOUT: %.loc6_16: i32 = int_value 1 [template = constants.%.10]
  288. // CHECK:STDOUT: %.loc6_24: i32 = int_value 2 [template = constants.%.11]
  289. // CHECK:STDOUT: %.loc6_25: %.9 = struct_literal (%.loc6_16, %.loc6_24)
  290. // CHECK:STDOUT: %struct: %.9 = struct_value (%.loc6_16, %.loc6_24) [template = constants.%struct]
  291. // CHECK:STDOUT: %.loc6_9: %.9 = converted %.loc6_25, %struct [template = constants.%struct]
  292. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%struct) [template = constants.%C.3]
  293. // CHECK:STDOUT: %c.var: ref %C.3 = var c
  294. // CHECK:STDOUT: %c: ref %C.3 = bind_name c, %c.var
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: generic class @C(constants.%S: %.9) {
  298. // CHECK:STDOUT: %S: %.9 = bind_symbolic_name S, 0 [symbolic = %S (constants.%S)]
  299. // CHECK:STDOUT: %S.patt: %.9 = symbolic_binding_pattern S, 0 [symbolic = %S.patt (constants.%S.patt)]
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: !definition:
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: class {
  304. // CHECK:STDOUT: !members:
  305. // CHECK:STDOUT: .Self = imports.%import_ref.6
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: fn @F() -> %C.3;
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: fn @__global_init() {
  314. // CHECK:STDOUT: !entry:
  315. // CHECK:STDOUT: %a_ref.ref: ref %.1 = name_ref a_ref, imports.%import_ref.1
  316. // CHECK:STDOUT: %.loc4_20.1: ref i32 = struct_access %a_ref.ref, element0
  317. // CHECK:STDOUT: %.loc4_20.2: i32 = bind_value %.loc4_20.1
  318. // CHECK:STDOUT: %.loc4_20.3: init %.1 = struct_init (%.loc4_20.2) to file.%a.var
  319. // CHECK:STDOUT: %.loc4_25: init %.1 = converted %a_ref.ref, %.loc4_20.3
  320. // CHECK:STDOUT: assign file.%a.var, %.loc4_25
  321. // CHECK:STDOUT: %b_ref.ref: ref %.3 = name_ref b_ref, imports.%import_ref.2
  322. // CHECK:STDOUT: %.loc5_47.1: ref %.2 = struct_access %b_ref.ref, element0
  323. // CHECK:STDOUT: %.loc5_47.2: ref i32 = struct_access %.loc5_47.1, element0
  324. // CHECK:STDOUT: %.loc5_47.3: i32 = bind_value %.loc5_47.2
  325. // CHECK:STDOUT: %.loc5_47.4: ref %.2 = struct_access file.%b.var, element0
  326. // CHECK:STDOUT: %.loc5_47.5: ref i32 = struct_access %.loc5_47.4, element0
  327. // CHECK:STDOUT: %.loc5_47.6: init i32 = initialize_from %.loc5_47.3 to %.loc5_47.5
  328. // CHECK:STDOUT: %.loc5_47.7: ref %tuple.type.2 = struct_access %.loc5_47.1, element1
  329. // CHECK:STDOUT: %.loc5_47.8: ref i32 = tuple_access %.loc5_47.7, element0
  330. // CHECK:STDOUT: %.loc5_47.9: i32 = bind_value %.loc5_47.8
  331. // CHECK:STDOUT: %.loc5_47.10: ref %tuple.type.2 = struct_access %.loc5_47.4, element1
  332. // CHECK:STDOUT: %.loc5_47.11: init %tuple.type.2 = tuple_init (%.loc5_47.9) to %.loc5_47.10
  333. // CHECK:STDOUT: %.loc5_47.12: init %tuple.type.2 = converted %.loc5_47.7, %.loc5_47.11
  334. // CHECK:STDOUT: %.loc5_47.13: init %tuple.type.2 = initialize_from %.loc5_47.12 to %.loc5_47.10
  335. // CHECK:STDOUT: %.loc5_47.14: init %.2 = struct_init (%.loc5_47.6, %.loc5_47.13) to %.loc5_47.4
  336. // CHECK:STDOUT: %.loc5_47.15: init %.2 = converted %.loc5_47.1, %.loc5_47.14
  337. // CHECK:STDOUT: %.loc5_47.16: ref i32 = struct_access %b_ref.ref, element1
  338. // CHECK:STDOUT: %.loc5_47.17: i32 = bind_value %.loc5_47.16
  339. // CHECK:STDOUT: %.loc5_47.18: ref i32 = struct_access file.%b.var, element1
  340. // CHECK:STDOUT: %.loc5_47.19: init i32 = initialize_from %.loc5_47.17 to %.loc5_47.18
  341. // CHECK:STDOUT: %.loc5_47.20: init %.3 = struct_init (%.loc5_47.15, %.loc5_47.19) to file.%b.var
  342. // CHECK:STDOUT: %.loc5_52: init %.3 = converted %b_ref.ref, %.loc5_47.20
  343. // CHECK:STDOUT: assign file.%b.var, %.loc5_52
  344. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F]
  345. // CHECK:STDOUT: %.loc6: ref %C.3 = splice_block file.%c.var {}
  346. // CHECK:STDOUT: %F.call: init %C.3 = call %F.ref() to %.loc6
  347. // CHECK:STDOUT: assign file.%c.var, %F.call
  348. // CHECK:STDOUT: return
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: specific @C(constants.%S) {
  352. // CHECK:STDOUT: %S => constants.%S
  353. // CHECK:STDOUT: %S.patt => constants.%S
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: specific @C(constants.%struct) {
  357. // CHECK:STDOUT: %S => constants.%struct
  358. // CHECK:STDOUT: %S.patt => constants.%struct
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: !definition:
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: --- fail_bad_type.impl.carbon
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: constants {
  366. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  367. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  368. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  369. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  370. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  371. // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
  372. // CHECK:STDOUT: %S: %.3 = bind_symbolic_name S, 0 [symbolic]
  373. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic]
  374. // CHECK:STDOUT: %S.patt: %.3 = symbolic_binding_pattern S, 0 [symbolic]
  375. // CHECK:STDOUT: %.4: i32 = int_value 1 [template]
  376. // CHECK:STDOUT: %.5: i32 = int_value 2 [template]
  377. // CHECK:STDOUT: %.6: type = struct_type {.c: i32, .d: i32} [template]
  378. // CHECK:STDOUT: %.7: type = ptr_type %.3 [template]
  379. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  380. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  381. // CHECK:STDOUT: %struct: %.3 = struct_value (%.4, %.5) [template]
  382. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct) [template]
  383. // CHECK:STDOUT: %.8: type = ptr_type %.1 [template]
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: imports {
  387. // CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
  388. // CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+47, unloaded
  389. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+86, loaded [template = constants.%C.1]
  390. // CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+111, loaded [template = constants.%F]
  391. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  392. // CHECK:STDOUT: import Core//prelude
  393. // CHECK:STDOUT: import Core//prelude/...
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+91, unloaded
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: file {
  399. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  400. // CHECK:STDOUT: .a_ref = imports.%import_ref.1
  401. // CHECK:STDOUT: .b_ref = imports.%import_ref.2
  402. // CHECK:STDOUT: .C = imports.%import_ref.3
  403. // CHECK:STDOUT: .F = imports.%import_ref.4
  404. // CHECK:STDOUT: .Core = imports.%Core
  405. // CHECK:STDOUT: .c_bad = %c_bad
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT: %Implicit.import = import Implicit
  408. // CHECK:STDOUT: %default.import = import <invalid>
  409. // CHECK:STDOUT: %Core.import = import Core
  410. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1]
  411. // CHECK:STDOUT: %.loc11_20: i32 = int_value 1 [template = constants.%.4]
  412. // CHECK:STDOUT: %.loc11_28: i32 = int_value 2 [template = constants.%.5]
  413. // CHECK:STDOUT: %.loc11_29: %.6 = struct_literal (%.loc11_20, %.loc11_28)
  414. // CHECK:STDOUT: %c_bad.var: ref <error> = var c_bad
  415. // CHECK:STDOUT: %c_bad: ref <error> = bind_name c_bad, %c_bad.var
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: generic class @C(constants.%S: %.3) {
  419. // CHECK:STDOUT: %S: %.3 = bind_symbolic_name S, 0 [symbolic = %S (constants.%S)]
  420. // CHECK:STDOUT: %S.patt: %.3 = symbolic_binding_pattern S, 0 [symbolic = %S.patt (constants.%S.patt)]
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: !definition:
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: class {
  425. // CHECK:STDOUT: !members:
  426. // CHECK:STDOUT: .Self = imports.%import_ref.5
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: fn @F() -> %C.3;
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: fn @__global_init() {
  433. // CHECK:STDOUT: !entry:
  434. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F]
  435. // CHECK:STDOUT: %.loc11: ref %C.3 = temporary_storage
  436. // CHECK:STDOUT: %F.call: init %C.3 = call %F.ref() to %.loc11
  437. // CHECK:STDOUT: assign file.%c_bad.var, <error>
  438. // CHECK:STDOUT: return
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: specific @C(constants.%S) {
  442. // CHECK:STDOUT: %S => constants.%S
  443. // CHECK:STDOUT: %S.patt => constants.%S
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: specific @C(constants.%struct) {
  447. // CHECK:STDOUT: %S => constants.%struct
  448. // CHECK:STDOUT: %S.patt => constants.%struct
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: !definition:
  451. // CHECK:STDOUT: }
  452. // CHECK:STDOUT:
  453. // CHECK:STDOUT: --- fail_bad_value.impl.carbon
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: constants {
  456. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  457. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  458. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  459. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  460. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  461. // CHECK:STDOUT: %.3: type = struct_type {.a: i32, .b: i32} [template]
  462. // CHECK:STDOUT: %S: %.3 = bind_symbolic_name S, 0 [symbolic]
  463. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%S) [symbolic]
  464. // CHECK:STDOUT: %S.patt: %.3 = symbolic_binding_pattern S, 0 [symbolic]
  465. // CHECK:STDOUT: %.4: i32 = int_value 3 [template]
  466. // CHECK:STDOUT: %.5: i32 = int_value 4 [template]
  467. // CHECK:STDOUT: %.6: type = ptr_type %.3 [template]
  468. // CHECK:STDOUT: %struct.1: %.3 = struct_value (%.4, %.5) [template]
  469. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%struct.1) [template]
  470. // CHECK:STDOUT: %.7: type = ptr_type %.1 [template]
  471. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  472. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  473. // CHECK:STDOUT: %.8: i32 = int_value 2 [template]
  474. // CHECK:STDOUT: %.9: i32 = int_value 1 [template]
  475. // CHECK:STDOUT: %struct.2: %.3 = struct_value (%.9, %.8) [template]
  476. // CHECK:STDOUT: %C.4: type = class_type @C, @C(%struct.2) [template]
  477. // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template]
  478. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template]
  479. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  480. // CHECK:STDOUT: %ImplicitAs.type.2: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
  481. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic]
  482. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  483. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic]
  484. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  485. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  486. // CHECK:STDOUT: %.10: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic]
  487. // CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.10 [symbolic]
  488. // CHECK:STDOUT: %ImplicitAs.type.3: type = facet_type <@ImplicitAs, @ImplicitAs(%C.3)> [template]
  489. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%C.3) [template]
  490. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  491. // CHECK:STDOUT: %.12: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
  492. // CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.10 [template]
  493. // CHECK:STDOUT: %.14: %.10 = assoc_entity element0, imports.%import_ref.11 [symbolic]
  494. // CHECK:STDOUT: }
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: imports {
  497. // CHECK:STDOUT: %import_ref.1 = import_ref Implicit//default, inst+17, unloaded
  498. // CHECK:STDOUT: %import_ref.2 = import_ref Implicit//default, inst+47, unloaded
  499. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Implicit//default, inst+86, loaded [template = constants.%C.1]
  500. // CHECK:STDOUT: %import_ref.4: %F.type = import_ref Implicit//default, inst+111, loaded [template = constants.%F]
  501. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  502. // CHECK:STDOUT: .ImplicitAs = %import_ref.6
  503. // CHECK:STDOUT: import Core//prelude
  504. // CHECK:STDOUT: import Core//prelude/...
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT: %import_ref.5 = import_ref Implicit//default, inst+91, unloaded
  507. // CHECK:STDOUT: %import_ref.6: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+48, loaded [template = constants.%ImplicitAs]
  508. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/as, inst+54, unloaded
  509. // CHECK:STDOUT: %import_ref.8: @ImplicitAs.%.1 (%.10) = import_ref Core//prelude/operators/as, inst+76, loaded [symbolic = @ImplicitAs.%.2 (constants.%.14)]
  510. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/as, inst+69, unloaded
  511. // CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/as, inst+69, unloaded
  512. // CHECK:STDOUT: %import_ref.11 = import_ref Core//prelude/operators/as, inst+69, unloaded
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: file {
  516. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  517. // CHECK:STDOUT: .a_ref = imports.%import_ref.1
  518. // CHECK:STDOUT: .b_ref = imports.%import_ref.2
  519. // CHECK:STDOUT: .C = imports.%import_ref.3
  520. // CHECK:STDOUT: .F = imports.%import_ref.4
  521. // CHECK:STDOUT: .Core = imports.%Core
  522. // CHECK:STDOUT: .c_bad = %c_bad
  523. // CHECK:STDOUT: }
  524. // CHECK:STDOUT: %Implicit.import = import Implicit
  525. // CHECK:STDOUT: %default.import = import <invalid>
  526. // CHECK:STDOUT: %Core.import = import Core
  527. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C.1]
  528. // CHECK:STDOUT: %.loc9_20: i32 = int_value 3 [template = constants.%.4]
  529. // CHECK:STDOUT: %.loc9_28: i32 = int_value 4 [template = constants.%.5]
  530. // CHECK:STDOUT: %.loc9_29: %.3 = struct_literal (%.loc9_20, %.loc9_28)
  531. // CHECK:STDOUT: %struct: %.3 = struct_value (%.loc9_20, %.loc9_28) [template = constants.%struct.1]
  532. // CHECK:STDOUT: %.loc9_13: %.3 = converted %.loc9_29, %struct [template = constants.%struct.1]
  533. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%struct.1) [template = constants.%C.3]
  534. // CHECK:STDOUT: %c_bad.var: ref %C.3 = var c_bad
  535. // CHECK:STDOUT: %c_bad: ref %C.3 = bind_name c_bad, %c_bad.var
  536. // CHECK:STDOUT: }
  537. // CHECK:STDOUT:
  538. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  539. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  540. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)]
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: !definition:
  543. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  544. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  545. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  546. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  547. // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.10)]
  548. // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.10) = assoc_entity element0, imports.%import_ref.10 [symbolic = %.2 (constants.%.11)]
  549. // CHECK:STDOUT:
  550. // CHECK:STDOUT: interface {
  551. // CHECK:STDOUT: !members:
  552. // CHECK:STDOUT: .Self = imports.%import_ref.7
  553. // CHECK:STDOUT: .Convert = imports.%import_ref.8
  554. // CHECK:STDOUT: witness = (imports.%import_ref.9)
  555. // CHECK:STDOUT: }
  556. // CHECK:STDOUT: }
  557. // CHECK:STDOUT:
  558. // CHECK:STDOUT: generic class @C(constants.%S: %.3) {
  559. // CHECK:STDOUT: %S: %.3 = bind_symbolic_name S, 0 [symbolic = %S (constants.%S)]
  560. // CHECK:STDOUT: %S.patt: %.3 = symbolic_binding_pattern S, 0 [symbolic = %S.patt (constants.%S.patt)]
  561. // CHECK:STDOUT:
  562. // CHECK:STDOUT: !definition:
  563. // CHECK:STDOUT:
  564. // CHECK:STDOUT: class {
  565. // CHECK:STDOUT: !members:
  566. // CHECK:STDOUT: .Self = imports.%import_ref.5
  567. // CHECK:STDOUT: }
  568. // CHECK:STDOUT: }
  569. // CHECK:STDOUT:
  570. // CHECK:STDOUT: fn @F() -> %C.4;
  571. // CHECK:STDOUT:
  572. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) {
  573. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  574. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)]
  575. // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  576. // CHECK:STDOUT:
  577. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
  578. // CHECK:STDOUT: }
  579. // CHECK:STDOUT:
  580. // CHECK:STDOUT: fn @__global_init() {
  581. // CHECK:STDOUT: !entry:
  582. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F]
  583. // CHECK:STDOUT: %.loc9_35: ref %C.4 = temporary_storage
  584. // CHECK:STDOUT: %F.call: init %C.4 = call %F.ref() to %.loc9_35
  585. // CHECK:STDOUT: %.loc9_37: %C.3 = converted %F.call, <error> [template = <error>]
  586. // CHECK:STDOUT: assign file.%c_bad.var, <error>
  587. // CHECK:STDOUT: return
  588. // CHECK:STDOUT: }
  589. // CHECK:STDOUT:
  590. // CHECK:STDOUT: specific @C(constants.%S) {
  591. // CHECK:STDOUT: %S => constants.%S
  592. // CHECK:STDOUT: %S.patt => constants.%S
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT:
  595. // CHECK:STDOUT: specific @C(constants.%struct.1) {
  596. // CHECK:STDOUT: %S => constants.%struct.1
  597. // CHECK:STDOUT: %S.patt => constants.%struct.1
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: !definition:
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT:
  602. // CHECK:STDOUT: specific @C(constants.%struct.2) {
  603. // CHECK:STDOUT: %S => constants.%struct.2
  604. // CHECK:STDOUT: %S.patt => constants.%struct.2
  605. // CHECK:STDOUT:
  606. // CHECK:STDOUT: !definition:
  607. // CHECK:STDOUT: }
  608. // CHECK:STDOUT:
  609. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  610. // CHECK:STDOUT: %Dest => constants.%Dest
  611. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT:
  614. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  615. // CHECK:STDOUT: %Dest => constants.%Dest
  616. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  617. // CHECK:STDOUT: }
  618. // CHECK:STDOUT:
  619. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  620. // CHECK:STDOUT: %Dest => constants.%Dest
  621. // CHECK:STDOUT: %Dest.patt => constants.%Dest
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT:
  624. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
  625. // CHECK:STDOUT: %Dest => constants.%Dest
  626. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2
  627. // CHECK:STDOUT: %Self => constants.%Self.1
  628. // CHECK:STDOUT: }
  629. // CHECK:STDOUT:
  630. // CHECK:STDOUT: specific @ImplicitAs(constants.%C.3) {
  631. // CHECK:STDOUT: %Dest => constants.%C.3
  632. // CHECK:STDOUT: %Dest.patt => constants.%C.3
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: !definition:
  635. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3
  636. // CHECK:STDOUT: %Self => constants.%Self.2
  637. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  638. // CHECK:STDOUT: %Convert => constants.%Convert.2
  639. // CHECK:STDOUT: %.1 => constants.%.12
  640. // CHECK:STDOUT: %.2 => constants.%.13
  641. // CHECK:STDOUT: }
  642. // CHECK:STDOUT: