array.carbon 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  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/deduce/array.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/deduce/array.carbon
  10. // --- type_only.carbon
  11. library "[[@TEST_NAME]]";
  12. class C {}
  13. fn F[T:! type](a: [T; 3]) -> T { return a[0]; }
  14. fn G() -> C {
  15. var a: [C; 3] = ({}, {}, {});
  16. return F(a);
  17. }
  18. // --- bound_only.carbon
  19. library "[[@TEST_NAME]]";
  20. class C {}
  21. fn F[N:! Core.IntLiteral()](a: [C; N]) -> i32 { return N; }
  22. fn G() -> i32 {
  23. var a: [C; 3] = ({}, {}, {});
  24. return F(a);
  25. }
  26. // --- type_and_bound.carbon
  27. library "[[@TEST_NAME]]";
  28. class C {}
  29. fn F[T:! type, N:! Core.IntLiteral()](a: [T; N]) {}
  30. fn G() {
  31. var a: [C; 3] = ({}, {}, {});
  32. F(a);
  33. }
  34. // --- fail_bound_mismatch.carbon
  35. library "[[@TEST_NAME]]";
  36. class C {}
  37. fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
  38. fn G() -> C {
  39. // TODO: We succeed at deducing T here but fail to convert. Is this the right behavior?
  40. var a: [C; 3] = ({}, {}, {});
  41. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+10]]:12: error: cannot implicitly convert from `[C; 3]` to `[C; 2]` [ImplicitAsConversionFailure]
  42. // CHECK:STDERR: return F(a);
  43. // CHECK:STDERR: ^
  44. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE+7]]:12: note: type `[C; 3]` does not implement interface `Core.ImplicitAs([C; 2])` [MissingImplInMemberAccessNote]
  45. // CHECK:STDERR: return F(a);
  46. // CHECK:STDERR: ^
  47. // CHECK:STDERR: fail_bound_mismatch.carbon:[[@LINE-11]]:16: note: initializing function parameter [InCallToFunctionParam]
  48. // CHECK:STDERR: fn F[T:! type](a: [T; 2]) -> T { return a[0]; }
  49. // CHECK:STDERR: ^~~~~~~~~
  50. // CHECK:STDERR:
  51. return F(a);
  52. }
  53. // --- fail_type_mismatch.carbon
  54. library "[[@TEST_NAME]]";
  55. class C {}
  56. class D {}
  57. fn F[N:! Core.IntLiteral()](a: [C; N]) -> i32 { return N; }
  58. fn G() -> i32 {
  59. // TODO: We succeed at deducing N here but fail to convert. Is this the right behavior?
  60. var a: [D; 3] = ({}, {}, {});
  61. // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+10]]:12: error: cannot implicitly convert from `[D; 3]` to `[C; 3]` [ImplicitAsConversionFailure]
  62. // CHECK:STDERR: return F(a);
  63. // CHECK:STDERR: ^
  64. // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+7]]:12: note: type `[D; 3]` does not implement interface `Core.ImplicitAs([C; 3])` [MissingImplInMemberAccessNote]
  65. // CHECK:STDERR: return F(a);
  66. // CHECK:STDERR: ^
  67. // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE-11]]:29: note: initializing function parameter [InCallToFunctionParam]
  68. // CHECK:STDERR: fn F[N:! Core.IntLiteral()](a: [C; N]) -> i32 { return N; }
  69. // CHECK:STDERR: ^~~~~~~~~
  70. // CHECK:STDERR:
  71. return F(a);
  72. }
  73. // --- fail_bound_type_mismatch.carbon
  74. library "[[@TEST_NAME]]";
  75. class C {}
  76. fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  77. fn G() -> i32 {
  78. var a: [C; 3] = ({}, {}, {});
  79. // TODO: This fails because the array bound in `F` is effectively
  80. // `N.(ImplicitAs(IntLiteral).Convert)()`
  81. // which we can't deduce through. We should decide if we want to support
  82. // deductions of that form. If not, it'd be nice to diagnose this situation
  83. // better.
  84. // CHECK:STDERR: fail_bound_type_mismatch.carbon:[[@LINE+7]]:10: error: cannot deduce value for generic parameter `N` [DeductionIncomplete]
  85. // CHECK:STDERR: return F(a);
  86. // CHECK:STDERR: ^~~~
  87. // CHECK:STDERR: fail_bound_type_mismatch.carbon:[[@LINE-12]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
  88. // CHECK:STDERR: fn F[N:! i32](a: [C; N]) -> i32 { return N; }
  89. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. // CHECK:STDERR:
  91. return F(a);
  92. }
  93. // CHECK:STDOUT: --- type_only.carbon
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: constants {
  96. // CHECK:STDOUT: %C: type = class_type @C [template]
  97. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  98. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  99. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  100. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  101. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  102. // CHECK:STDOUT: %array_type.743: type = array_type %int_3, %T [symbolic]
  103. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  104. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  105. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  106. // CHECK:STDOUT: %require_complete.06f: <witness> = require_complete_type %array_type.743 [symbolic]
  107. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template]
  108. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  109. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  110. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  111. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  112. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  113. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  114. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  115. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  116. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  117. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.5c6, %Convert.956 [template]
  118. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  119. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template]
  120. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  121. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  122. // CHECK:STDOUT: %array_type.002: type = array_type %int_3, %C [template]
  123. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  124. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  125. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  126. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  127. // CHECK:STDOUT: %array: %array_type.002 = tuple_value (%C.val, %C.val, %C.val) [template]
  128. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%C) [template]
  129. // CHECK:STDOUT: %complete_type.dd1: <witness> = complete_type_witness %array_type.002 [template]
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: imports {
  133. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  134. // CHECK:STDOUT: .Int = %Core.Int
  135. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  136. // CHECK:STDOUT: import Core//prelude
  137. // CHECK:STDOUT: import Core//prelude/...
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: file {
  142. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  143. // CHECK:STDOUT: .Core = imports.%Core
  144. // CHECK:STDOUT: .C = %C.decl
  145. // CHECK:STDOUT: .F = %F.decl
  146. // CHECK:STDOUT: .G = %G.decl
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: %Core.import = import Core
  149. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  150. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  151. // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  152. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param<none> [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  153. // CHECK:STDOUT: %a.patt: @F.%array_type.loc6_24.2 (%array_type.743) = binding_pattern a
  154. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_24.2 (%array_type.743) = value_param_pattern %a.patt, runtime_param0
  155. // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern
  156. // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  157. // CHECK:STDOUT: } {
  158. // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  159. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  160. // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
  161. // CHECK:STDOUT: %a.param: @F.%array_type.loc6_24.2 (%array_type.743) = value_param runtime_param0
  162. // CHECK:STDOUT: %.loc6_24: type = splice_block %array_type.loc6_24.1 [symbolic = %array_type.loc6_24.2 (constants.%array_type.743)] {
  163. // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  164. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  165. // CHECK:STDOUT: %array_type.loc6_24.1: type = array_type %int_3, %T [symbolic = %array_type.loc6_24.2 (constants.%array_type.743)]
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT: %a: @F.%array_type.loc6_24.2 (%array_type.743) = bind_name a, %a.param
  168. // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1
  169. // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  172. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  173. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  174. // CHECK:STDOUT: } {
  175. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
  176. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  177. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: class @C {
  182. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  183. // CHECK:STDOUT: complete_type_witness = %complete_type
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: !members:
  186. // CHECK:STDOUT: .Self = constants.%C
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
  190. // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
  191. // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  192. // CHECK:STDOUT: %array_type.loc6_24.2: type = array_type constants.%int_3, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_24.2 (constants.%array_type.743)]
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: !definition:
  195. // CHECK:STDOUT: %require_complete.loc6_27: <witness> = require_complete_type @F.%T.loc6_6.2 (%T) [symbolic = %require_complete.loc6_27 (constants.%require_complete.4ae)]
  196. // CHECK:STDOUT: %require_complete.loc6_17: <witness> = require_complete_type @F.%array_type.loc6_24.2 (%array_type.743) [symbolic = %require_complete.loc6_17 (constants.%require_complete.06f)]
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_24.2 (%array_type.743)) -> @F.%T.loc6_6.2 (%T) {
  199. // CHECK:STDOUT: !entry:
  200. // CHECK:STDOUT: %a.ref: @F.%array_type.loc6_24.2 (%array_type.743) = name_ref a, %a
  201. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  202. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  203. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  204. // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  205. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  206. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  207. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0) [template = constants.%int_0.6a9]
  208. // CHECK:STDOUT: %.loc6_43.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9]
  209. // CHECK:STDOUT: %.loc6_43.2: %i32 = converted %int_0, %.loc6_43.1 [template = constants.%int_0.6a9]
  210. // CHECK:STDOUT: %.loc6_44.1: ref @F.%array_type.loc6_24.2 (%array_type.743) = value_as_ref %a.ref
  211. // CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43.2
  212. // CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2
  213. // CHECK:STDOUT: return %.loc6_44.3
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: fn @G() -> %return.param_patt: %C {
  218. // CHECK:STDOUT: !entry:
  219. // CHECK:STDOUT: name_binding_decl {
  220. // CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a
  221. // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT: %a.var: ref %array_type.002 = var a
  224. // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal ()
  225. // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal ()
  226. // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal ()
  227. // CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1)
  228. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  229. // CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0
  230. // CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [template = constants.%C.val]
  231. // CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [template = constants.%C.val]
  232. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  233. // CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1
  234. // CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [template = constants.%C.val]
  235. // CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%C.val]
  236. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  237. // CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2
  238. // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val]
  239. // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val]
  240. // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array]
  241. // CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array]
  242. // CHECK:STDOUT: assign %a.var, %.loc9_3.2
  243. // CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] {
  244. // CHECK:STDOUT: %C.ref.loc9: type = name_ref C, file.%C.decl [template = constants.%C]
  245. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  246. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002]
  247. // CHECK:STDOUT: }
  248. // CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var
  249. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  250. // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a
  251. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [template = constants.%F.specific_fn]
  252. // CHECK:STDOUT: %.loc8: ref %C = splice_block %return {}
  253. // CHECK:STDOUT: %.loc10: %array_type.002 = bind_value %a.ref
  254. // CHECK:STDOUT: %F.call: init %C = call %F.specific_fn(%.loc10) to %.loc8
  255. // CHECK:STDOUT: return %F.call to %return
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: specific @F(constants.%T) {
  259. // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
  260. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T
  261. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.743
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: specific @F(constants.%C) {
  265. // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
  266. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C
  267. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.002
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: !definition:
  270. // CHECK:STDOUT: %require_complete.loc6_27 => constants.%complete_type.357
  271. // CHECK:STDOUT: %require_complete.loc6_17 => constants.%complete_type.dd1
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: --- bound_only.carbon
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: constants {
  277. // CHECK:STDOUT: %C: type = class_type @C [template]
  278. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  279. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  280. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [template]
  281. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [template]
  282. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic]
  283. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic]
  284. // CHECK:STDOUT: %array_type.6a2: type = array_type %N, %C [symbolic]
  285. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  286. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  287. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  288. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  289. // CHECK:STDOUT: %require_complete.d82: <witness> = require_complete_type %array_type.6a2 [symbolic]
  290. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  291. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  292. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  293. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  294. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  295. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  296. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  297. // CHECK:STDOUT: %Convert.bound.41f: <bound method> = bound_method %N, %Convert.956 [symbolic]
  298. // CHECK:STDOUT: %Convert.specific_fn.122: <specific function> = specific_function %Convert.bound.41f, @Convert.2(%int_32) [symbolic]
  299. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn.122(%N) [symbolic]
  300. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  301. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  302. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  303. // CHECK:STDOUT: %array_type.002: type = array_type %int_3.1ba, %C [template]
  304. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  305. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  306. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  307. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  308. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  309. // CHECK:STDOUT: %array: %array_type.002 = tuple_value (%C.val, %C.val, %C.val) [template]
  310. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%int_3.1ba) [template]
  311. // CHECK:STDOUT: %complete_type.dd1: <witness> = complete_type_witness %array_type.002 [template]
  312. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [template]
  313. // CHECK:STDOUT: %Convert.specific_fn.b42: <specific function> = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template]
  314. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template]
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: imports {
  318. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  319. // CHECK:STDOUT: .IntLiteral = %Core.IntLiteral
  320. // CHECK:STDOUT: .Int = %Core.Int
  321. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  322. // CHECK:STDOUT: import Core//prelude
  323. // CHECK:STDOUT: import Core//prelude/...
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT: %Core.IntLiteral: %IntLiteral.type = import_ref Core//prelude/types/int_literal, IntLiteral, loaded [template = constants.%IntLiteral]
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: file {
  329. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  330. // CHECK:STDOUT: .Core = imports.%Core
  331. // CHECK:STDOUT: .C = %C.decl
  332. // CHECK:STDOUT: .F = %F.decl
  333. // CHECK:STDOUT: .G = %G.decl
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT: %Core.import = import Core
  336. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  337. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  338. // CHECK:STDOUT: %N.patt.loc6_6.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt)]
  339. // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc6_6.1, runtime_param<none> [symbolic = %N.patt.loc6_6.2 (constants.%N.patt)]
  340. // CHECK:STDOUT: %a.patt: @F.%array_type.loc6_37.2 (%array_type.6a2) = binding_pattern a
  341. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_37.2 (%array_type.6a2) = value_param_pattern %a.patt, runtime_param0
  342. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  343. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  344. // CHECK:STDOUT: } {
  345. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  346. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  347. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param<none>
  348. // CHECK:STDOUT: %.loc6_26.1: type = splice_block %.loc6_26.3 [template = Core.IntLiteral] {
  349. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  350. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [template = constants.%IntLiteral]
  351. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  352. // CHECK:STDOUT: %.loc6_26.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  353. // CHECK:STDOUT: %.loc6_26.3: type = converted %int_literal.make_type, %.loc6_26.2 [template = Core.IntLiteral]
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT: %N.loc6_6.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc6_6.2 (constants.%N)]
  356. // CHECK:STDOUT: %a.param: @F.%array_type.loc6_37.2 (%array_type.6a2) = value_param runtime_param0
  357. // CHECK:STDOUT: %.loc6_37: type = splice_block %array_type.loc6_37.1 [symbolic = %array_type.loc6_37.2 (constants.%array_type.6a2)] {
  358. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  359. // CHECK:STDOUT: %N.ref.loc6_36: Core.IntLiteral = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N)]
  360. // CHECK:STDOUT: %array_type.loc6_37.1: type = array_type %N.ref.loc6_36, %C [symbolic = %array_type.loc6_37.2 (constants.%array_type.6a2)]
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT: %a: @F.%array_type.loc6_37.2 (%array_type.6a2) = bind_name a, %a.param
  363. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  364. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  367. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  368. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  369. // CHECK:STDOUT: } {
  370. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  371. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  372. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  373. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: class @C {
  378. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  379. // CHECK:STDOUT: complete_type_witness = %complete_type
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: !members:
  382. // CHECK:STDOUT: .Self = constants.%C
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT:
  385. // CHECK:STDOUT: generic fn @F(%N.loc6_6.1: Core.IntLiteral) {
  386. // CHECK:STDOUT: %N.loc6_6.2: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N.loc6_6.2 (constants.%N)]
  387. // CHECK:STDOUT: %N.patt.loc6_6.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt)]
  388. // CHECK:STDOUT: %array_type.loc6_37.2: type = array_type %N.loc6_6.2, %C [symbolic = %array_type.loc6_37.2 (constants.%array_type.6a2)]
  389. // CHECK:STDOUT:
  390. // CHECK:STDOUT: !definition:
  391. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%array_type.loc6_37.2 (%array_type.6a2) [symbolic = %require_complete (constants.%require_complete.d82)]
  392. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.loc6_6.2, constants.%Convert.956 [symbolic = %Convert.bound (constants.%Convert.bound.41f)]
  393. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)]
  394. // CHECK:STDOUT: %int.convert_checked.loc6_57.2: init %i32 = call %Convert.specific_fn(%N.loc6_6.2) [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)]
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc6_37.2 (%array_type.6a2)) -> %i32 {
  397. // CHECK:STDOUT: !entry:
  398. // CHECK:STDOUT: %N.ref.loc6_56: Core.IntLiteral = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N)]
  399. // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  400. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %N.ref.loc6_56, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound.41f)]
  401. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)]
  402. // CHECK:STDOUT: %int.convert_checked.loc6_57.1: init %i32 = call %specific_fn(%N.ref.loc6_56) [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)]
  403. // CHECK:STDOUT: %.loc6_57.1: %i32 = value_of_initializer %int.convert_checked.loc6_57.1 [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)]
  404. // CHECK:STDOUT: %.loc6_57.2: %i32 = converted %N.ref.loc6_56, %.loc6_57.1 [symbolic = %int.convert_checked.loc6_57.2 (constants.%int.convert_checked)]
  405. // CHECK:STDOUT: return %.loc6_57.2
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: fn @G() -> %i32 {
  410. // CHECK:STDOUT: !entry:
  411. // CHECK:STDOUT: name_binding_decl {
  412. // CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a
  413. // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT: %a.var: ref %array_type.002 = var a
  416. // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal ()
  417. // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal ()
  418. // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal ()
  419. // CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1)
  420. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  421. // CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0
  422. // CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [template = constants.%C.val]
  423. // CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [template = constants.%C.val]
  424. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  425. // CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1
  426. // CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [template = constants.%C.val]
  427. // CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%C.val]
  428. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  429. // CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2
  430. // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val]
  431. // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val]
  432. // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array]
  433. // CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array]
  434. // CHECK:STDOUT: assign %a.var, %.loc9_3.2
  435. // CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] {
  436. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  437. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  438. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002]
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var
  441. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  442. // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a
  443. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%int_3.1ba) [template = constants.%F.specific_fn]
  444. // CHECK:STDOUT: %.loc10_12: %array_type.002 = bind_value %a.ref
  445. // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(%.loc10_12)
  446. // CHECK:STDOUT: %.loc10_14.1: %i32 = value_of_initializer %F.call
  447. // CHECK:STDOUT: %.loc10_14.2: %i32 = converted %F.call, %.loc10_14.1
  448. // CHECK:STDOUT: return %.loc10_14.2
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: specific @F(constants.%N) {
  452. // CHECK:STDOUT: %N.loc6_6.2 => constants.%N
  453. // CHECK:STDOUT: %N.patt.loc6_6.2 => constants.%N
  454. // CHECK:STDOUT: %array_type.loc6_37.2 => constants.%array_type.6a2
  455. // CHECK:STDOUT: }
  456. // CHECK:STDOUT:
  457. // CHECK:STDOUT: specific @F(constants.%int_3.1ba) {
  458. // CHECK:STDOUT: %N.loc6_6.2 => constants.%int_3.1ba
  459. // CHECK:STDOUT: %N.patt.loc6_6.2 => constants.%int_3.1ba
  460. // CHECK:STDOUT: %array_type.loc6_37.2 => constants.%array_type.002
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: !definition:
  463. // CHECK:STDOUT: %require_complete => constants.%complete_type.dd1
  464. // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound.b30
  465. // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn.b42
  466. // CHECK:STDOUT: %int.convert_checked.loc6_57.2 => constants.%int_3.822
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: --- type_and_bound.carbon
  470. // CHECK:STDOUT:
  471. // CHECK:STDOUT: constants {
  472. // CHECK:STDOUT: %C: type = class_type @C [template]
  473. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  474. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  475. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  476. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  477. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [template]
  478. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  479. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [template]
  480. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 1 [symbolic]
  481. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 1 [symbolic]
  482. // CHECK:STDOUT: %array_type.bb5: type = array_type %N, %T [symbolic]
  483. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  484. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  485. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %array_type.bb5 [symbolic]
  486. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  487. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  488. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  489. // CHECK:STDOUT: %array_type.002: type = array_type %int_3, %C [template]
  490. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  491. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  492. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  493. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  494. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  495. // CHECK:STDOUT: %array: %array_type.002 = tuple_value (%C.val, %C.val, %C.val) [template]
  496. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%C, %int_3) [template]
  497. // CHECK:STDOUT: %complete_type.dd1: <witness> = complete_type_witness %array_type.002 [template]
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: imports {
  501. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  502. // CHECK:STDOUT: .IntLiteral = %Core.IntLiteral
  503. // CHECK:STDOUT: import Core//prelude
  504. // CHECK:STDOUT: import Core//prelude/...
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT: %Core.IntLiteral: %IntLiteral.type = import_ref Core//prelude/types/int_literal, IntLiteral, loaded [template = constants.%IntLiteral]
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: file {
  510. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  511. // CHECK:STDOUT: .Core = imports.%Core
  512. // CHECK:STDOUT: .C = %C.decl
  513. // CHECK:STDOUT: .F = %F.decl
  514. // CHECK:STDOUT: .G = %G.decl
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT: %Core.import = import Core
  517. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  518. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  519. // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  520. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param<none> [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  521. // CHECK:STDOUT: %N.patt.loc6_16.1: Core.IntLiteral = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc6_16.2 (constants.%N.patt)]
  522. // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc6_16.1, runtime_param<none> [symbolic = %N.patt.loc6_16.2 (constants.%N.patt)]
  523. // CHECK:STDOUT: %a.patt: @F.%array_type.loc6_47.2 (%array_type.bb5) = binding_pattern a
  524. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_47.2 (%array_type.bb5) = value_param_pattern %a.patt, runtime_param0
  525. // CHECK:STDOUT: } {
  526. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  527. // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
  528. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param<none>
  529. // CHECK:STDOUT: %.loc6_36.1: type = splice_block %.loc6_36.3 [template = Core.IntLiteral] {
  530. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  531. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [template = constants.%IntLiteral]
  532. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  533. // CHECK:STDOUT: %.loc6_36.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  534. // CHECK:STDOUT: %.loc6_36.3: type = converted %int_literal.make_type, %.loc6_36.2 [template = Core.IntLiteral]
  535. // CHECK:STDOUT: }
  536. // CHECK:STDOUT: %N.loc6_16.1: Core.IntLiteral = bind_symbolic_name N, 1, %N.param [symbolic = %N.loc6_16.2 (constants.%N)]
  537. // CHECK:STDOUT: %a.param: @F.%array_type.loc6_47.2 (%array_type.bb5) = value_param runtime_param0
  538. // CHECK:STDOUT: %.loc6_47: type = splice_block %array_type.loc6_47.1 [symbolic = %array_type.loc6_47.2 (constants.%array_type.bb5)] {
  539. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  540. // CHECK:STDOUT: %N.ref: Core.IntLiteral = name_ref N, %N.loc6_16.1 [symbolic = %N.loc6_16.2 (constants.%N)]
  541. // CHECK:STDOUT: %array_type.loc6_47.1: type = array_type %N.ref, %T [symbolic = %array_type.loc6_47.2 (constants.%array_type.bb5)]
  542. // CHECK:STDOUT: }
  543. // CHECK:STDOUT: %a: @F.%array_type.loc6_47.2 (%array_type.bb5) = bind_name a, %a.param
  544. // CHECK:STDOUT: }
  545. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {}
  546. // CHECK:STDOUT: }
  547. // CHECK:STDOUT:
  548. // CHECK:STDOUT: class @C {
  549. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  550. // CHECK:STDOUT: complete_type_witness = %complete_type
  551. // CHECK:STDOUT:
  552. // CHECK:STDOUT: !members:
  553. // CHECK:STDOUT: .Self = constants.%C
  554. // CHECK:STDOUT: }
  555. // CHECK:STDOUT:
  556. // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type, %N.loc6_16.1: Core.IntLiteral) {
  557. // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
  558. // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  559. // CHECK:STDOUT: %N.loc6_16.2: Core.IntLiteral = bind_symbolic_name N, 1 [symbolic = %N.loc6_16.2 (constants.%N)]
  560. // CHECK:STDOUT: %N.patt.loc6_16.2: Core.IntLiteral = symbolic_binding_pattern N, 1 [symbolic = %N.patt.loc6_16.2 (constants.%N.patt)]
  561. // CHECK:STDOUT: %array_type.loc6_47.2: type = array_type %N.loc6_16.2, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_47.2 (constants.%array_type.bb5)]
  562. // CHECK:STDOUT:
  563. // CHECK:STDOUT: !definition:
  564. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%array_type.loc6_47.2 (%array_type.bb5) [symbolic = %require_complete (constants.%require_complete)]
  565. // CHECK:STDOUT:
  566. // CHECK:STDOUT: fn[%T.param_patt: type, %N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc6_47.2 (%array_type.bb5)) {
  567. // CHECK:STDOUT: !entry:
  568. // CHECK:STDOUT: return
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT: }
  571. // CHECK:STDOUT:
  572. // CHECK:STDOUT: fn @G() {
  573. // CHECK:STDOUT: !entry:
  574. // CHECK:STDOUT: name_binding_decl {
  575. // CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a
  576. // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt
  577. // CHECK:STDOUT: }
  578. // CHECK:STDOUT: %a.var: ref %array_type.002 = var a
  579. // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal ()
  580. // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal ()
  581. // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal ()
  582. // CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1)
  583. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  584. // CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0
  585. // CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [template = constants.%C.val]
  586. // CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [template = constants.%C.val]
  587. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  588. // CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1
  589. // CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [template = constants.%C.val]
  590. // CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%C.val]
  591. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  592. // CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2
  593. // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val]
  594. // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val]
  595. // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array]
  596. // CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array]
  597. // CHECK:STDOUT: assign %a.var, %.loc9_3.2
  598. // CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] {
  599. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  600. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  601. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002]
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var
  604. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  605. // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a
  606. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C, constants.%int_3) [template = constants.%F.specific_fn]
  607. // CHECK:STDOUT: %.loc10: %array_type.002 = bind_value %a.ref
  608. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn(%.loc10)
  609. // CHECK:STDOUT: return
  610. // CHECK:STDOUT: }
  611. // CHECK:STDOUT:
  612. // CHECK:STDOUT: specific @F(constants.%T, constants.%N) {
  613. // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
  614. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T
  615. // CHECK:STDOUT: %N.loc6_16.2 => constants.%N
  616. // CHECK:STDOUT: %N.patt.loc6_16.2 => constants.%N
  617. // CHECK:STDOUT: %array_type.loc6_47.2 => constants.%array_type.bb5
  618. // CHECK:STDOUT: }
  619. // CHECK:STDOUT:
  620. // CHECK:STDOUT: specific @F(constants.%C, constants.%int_3) {
  621. // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
  622. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C
  623. // CHECK:STDOUT: %N.loc6_16.2 => constants.%int_3
  624. // CHECK:STDOUT: %N.patt.loc6_16.2 => constants.%int_3
  625. // CHECK:STDOUT: %array_type.loc6_47.2 => constants.%array_type.002
  626. // CHECK:STDOUT:
  627. // CHECK:STDOUT: !definition:
  628. // CHECK:STDOUT: %require_complete => constants.%complete_type.dd1
  629. // CHECK:STDOUT: }
  630. // CHECK:STDOUT:
  631. // CHECK:STDOUT: --- fail_bound_mismatch.carbon
  632. // CHECK:STDOUT:
  633. // CHECK:STDOUT: constants {
  634. // CHECK:STDOUT: %C: type = class_type @C [template]
  635. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  636. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  637. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  638. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  639. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  640. // CHECK:STDOUT: %array_type.9d4: type = array_type %int_2, %T [symbolic]
  641. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  642. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  643. // CHECK:STDOUT: %require_complete.4ae: <witness> = require_complete_type %T [symbolic]
  644. // CHECK:STDOUT: %require_complete.d11: <witness> = require_complete_type %array_type.9d4 [symbolic]
  645. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [template]
  646. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  647. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  648. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  649. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  650. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  651. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  652. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  653. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  654. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  655. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.5c6, %Convert.956 [template]
  656. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  657. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [template]
  658. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  659. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  660. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  661. // CHECK:STDOUT: %array_type.002: type = array_type %int_3, %C [template]
  662. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  663. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  664. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  665. // CHECK:STDOUT: %array: %array_type.002 = tuple_value (%C.val, %C.val, %C.val) [template]
  666. // CHECK:STDOUT: %array_type.15a: type = array_type %int_2, %C [template]
  667. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%C) [template]
  668. // CHECK:STDOUT: %complete_type.8eb: <witness> = complete_type_witness %array_type.15a [template]
  669. // CHECK:STDOUT: }
  670. // CHECK:STDOUT:
  671. // CHECK:STDOUT: imports {
  672. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  673. // CHECK:STDOUT: .Int = %Core.Int
  674. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  675. // CHECK:STDOUT: import Core//prelude
  676. // CHECK:STDOUT: import Core//prelude/...
  677. // CHECK:STDOUT: }
  678. // CHECK:STDOUT: }
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: file {
  681. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  682. // CHECK:STDOUT: .Core = imports.%Core
  683. // CHECK:STDOUT: .C = %C.decl
  684. // CHECK:STDOUT: .F = %F.decl
  685. // CHECK:STDOUT: .G = %G.decl
  686. // CHECK:STDOUT: }
  687. // CHECK:STDOUT: %Core.import = import Core
  688. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  689. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  690. // CHECK:STDOUT: %T.patt.loc6_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  691. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_6.1, runtime_param<none> [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  692. // CHECK:STDOUT: %a.patt: @F.%array_type.loc6_24.2 (%array_type.9d4) = binding_pattern a
  693. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_24.2 (%array_type.9d4) = value_param_pattern %a.patt, runtime_param0
  694. // CHECK:STDOUT: %return.patt: @F.%T.loc6_6.2 (%T) = return_slot_pattern
  695. // CHECK:STDOUT: %return.param_patt: @F.%T.loc6_6.2 (%T) = out_param_pattern %return.patt, runtime_param1
  696. // CHECK:STDOUT: } {
  697. // CHECK:STDOUT: %T.ref.loc6_30: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  698. // CHECK:STDOUT: %T.param: type = value_param runtime_param<none>
  699. // CHECK:STDOUT: %T.loc6_6.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_6.2 (constants.%T)]
  700. // CHECK:STDOUT: %a.param: @F.%array_type.loc6_24.2 (%array_type.9d4) = value_param runtime_param0
  701. // CHECK:STDOUT: %.loc6_24: type = splice_block %array_type.loc6_24.1 [symbolic = %array_type.loc6_24.2 (constants.%array_type.9d4)] {
  702. // CHECK:STDOUT: %T.ref.loc6_20: type = name_ref T, %T.loc6_6.1 [symbolic = %T.loc6_6.2 (constants.%T)]
  703. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  704. // CHECK:STDOUT: %array_type.loc6_24.1: type = array_type %int_2, %T [symbolic = %array_type.loc6_24.2 (constants.%array_type.9d4)]
  705. // CHECK:STDOUT: }
  706. // CHECK:STDOUT: %a: @F.%array_type.loc6_24.2 (%array_type.9d4) = bind_name a, %a.param
  707. // CHECK:STDOUT: %return.param: ref @F.%T.loc6_6.2 (%T) = out_param runtime_param1
  708. // CHECK:STDOUT: %return: ref @F.%T.loc6_6.2 (%T) = return_slot %return.param
  709. // CHECK:STDOUT: }
  710. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  711. // CHECK:STDOUT: %return.patt: %C = return_slot_pattern
  712. // CHECK:STDOUT: %return.param_patt: %C = out_param_pattern %return.patt, runtime_param0
  713. // CHECK:STDOUT: } {
  714. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, file.%C.decl [template = constants.%C]
  715. // CHECK:STDOUT: %return.param: ref %C = out_param runtime_param0
  716. // CHECK:STDOUT: %return: ref %C = return_slot %return.param
  717. // CHECK:STDOUT: }
  718. // CHECK:STDOUT: }
  719. // CHECK:STDOUT:
  720. // CHECK:STDOUT: class @C {
  721. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  722. // CHECK:STDOUT: complete_type_witness = %complete_type
  723. // CHECK:STDOUT:
  724. // CHECK:STDOUT: !members:
  725. // CHECK:STDOUT: .Self = constants.%C
  726. // CHECK:STDOUT: }
  727. // CHECK:STDOUT:
  728. // CHECK:STDOUT: generic fn @F(%T.loc6_6.1: type) {
  729. // CHECK:STDOUT: %T.loc6_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_6.2 (constants.%T)]
  730. // CHECK:STDOUT: %T.patt.loc6_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_6.2 (constants.%T.patt)]
  731. // CHECK:STDOUT: %array_type.loc6_24.2: type = array_type constants.%int_2, @F.%T.loc6_6.2 (%T) [symbolic = %array_type.loc6_24.2 (constants.%array_type.9d4)]
  732. // CHECK:STDOUT:
  733. // CHECK:STDOUT: !definition:
  734. // CHECK:STDOUT: %require_complete.loc6_27: <witness> = require_complete_type @F.%T.loc6_6.2 (%T) [symbolic = %require_complete.loc6_27 (constants.%require_complete.4ae)]
  735. // CHECK:STDOUT: %require_complete.loc6_17: <witness> = require_complete_type @F.%array_type.loc6_24.2 (%array_type.9d4) [symbolic = %require_complete.loc6_17 (constants.%require_complete.d11)]
  736. // CHECK:STDOUT:
  737. // CHECK:STDOUT: fn[%T.param_patt: type](%a.param_patt: @F.%array_type.loc6_24.2 (%array_type.9d4)) -> @F.%T.loc6_6.2 (%T) {
  738. // CHECK:STDOUT: !entry:
  739. // CHECK:STDOUT: %a.ref: @F.%array_type.loc6_24.2 (%array_type.9d4) = name_ref a, %a
  740. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  741. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  742. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  743. // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  744. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_0, %impl.elem0 [template = constants.%Convert.bound]
  745. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  746. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0) [template = constants.%int_0.6a9]
  747. // CHECK:STDOUT: %.loc6_43.1: %i32 = value_of_initializer %int.convert_checked [template = constants.%int_0.6a9]
  748. // CHECK:STDOUT: %.loc6_43.2: %i32 = converted %int_0, %.loc6_43.1 [template = constants.%int_0.6a9]
  749. // CHECK:STDOUT: %.loc6_44.1: ref @F.%array_type.loc6_24.2 (%array_type.9d4) = value_as_ref %a.ref
  750. // CHECK:STDOUT: %.loc6_44.2: ref @F.%T.loc6_6.2 (%T) = array_index %.loc6_44.1, %.loc6_43.2
  751. // CHECK:STDOUT: %.loc6_44.3: @F.%T.loc6_6.2 (%T) = bind_value %.loc6_44.2
  752. // CHECK:STDOUT: return %.loc6_44.3
  753. // CHECK:STDOUT: }
  754. // CHECK:STDOUT: }
  755. // CHECK:STDOUT:
  756. // CHECK:STDOUT: fn @G() -> %return.param_patt: %C {
  757. // CHECK:STDOUT: !entry:
  758. // CHECK:STDOUT: name_binding_decl {
  759. // CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a
  760. // CHECK:STDOUT: %.loc10_3.1: %array_type.002 = var_pattern %a.patt
  761. // CHECK:STDOUT: }
  762. // CHECK:STDOUT: %a.var: ref %array_type.002 = var a
  763. // CHECK:STDOUT: %.loc10_21.1: %empty_struct_type = struct_literal ()
  764. // CHECK:STDOUT: %.loc10_25.1: %empty_struct_type = struct_literal ()
  765. // CHECK:STDOUT: %.loc10_29.1: %empty_struct_type = struct_literal ()
  766. // CHECK:STDOUT: %.loc10_30.1: %tuple.type = tuple_literal (%.loc10_21.1, %.loc10_25.1, %.loc10_29.1)
  767. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0.5c6]
  768. // CHECK:STDOUT: %.loc10_30.2: ref %C = array_index %a.var, %int_0
  769. // CHECK:STDOUT: %.loc10_21.2: init %C = class_init (), %.loc10_30.2 [template = constants.%C.val]
  770. // CHECK:STDOUT: %.loc10_30.3: init %C = converted %.loc10_21.1, %.loc10_21.2 [template = constants.%C.val]
  771. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  772. // CHECK:STDOUT: %.loc10_30.4: ref %C = array_index %a.var, %int_1
  773. // CHECK:STDOUT: %.loc10_25.2: init %C = class_init (), %.loc10_30.4 [template = constants.%C.val]
  774. // CHECK:STDOUT: %.loc10_30.5: init %C = converted %.loc10_25.1, %.loc10_25.2 [template = constants.%C.val]
  775. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  776. // CHECK:STDOUT: %.loc10_30.6: ref %C = array_index %a.var, %int_2
  777. // CHECK:STDOUT: %.loc10_29.2: init %C = class_init (), %.loc10_30.6 [template = constants.%C.val]
  778. // CHECK:STDOUT: %.loc10_30.7: init %C = converted %.loc10_29.1, %.loc10_29.2 [template = constants.%C.val]
  779. // CHECK:STDOUT: %.loc10_30.8: init %array_type.002 = array_init (%.loc10_30.3, %.loc10_30.5, %.loc10_30.7) to %a.var [template = constants.%array]
  780. // CHECK:STDOUT: %.loc10_3.2: init %array_type.002 = converted %.loc10_30.1, %.loc10_30.8 [template = constants.%array]
  781. // CHECK:STDOUT: assign %a.var, %.loc10_3.2
  782. // CHECK:STDOUT: %.loc10_15: type = splice_block %array_type [template = constants.%array_type.002] {
  783. // CHECK:STDOUT: %C.ref.loc10: type = name_ref C, file.%C.decl [template = constants.%C]
  784. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  785. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002]
  786. // CHECK:STDOUT: }
  787. // CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var
  788. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  789. // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a
  790. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%C) [template = constants.%F.specific_fn]
  791. // CHECK:STDOUT: %.loc8: ref %C = splice_block %return {}
  792. // CHECK:STDOUT: %.loc21: %array_type.15a = converted %a.ref, <error> [template = <error>]
  793. // CHECK:STDOUT: %F.call: init %C = call %F.specific_fn(<error>) to %.loc8
  794. // CHECK:STDOUT: return %F.call to %return
  795. // CHECK:STDOUT: }
  796. // CHECK:STDOUT:
  797. // CHECK:STDOUT: specific @F(constants.%T) {
  798. // CHECK:STDOUT: %T.loc6_6.2 => constants.%T
  799. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%T
  800. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.9d4
  801. // CHECK:STDOUT: }
  802. // CHECK:STDOUT:
  803. // CHECK:STDOUT: specific @F(constants.%C) {
  804. // CHECK:STDOUT: %T.loc6_6.2 => constants.%C
  805. // CHECK:STDOUT: %T.patt.loc6_6.2 => constants.%C
  806. // CHECK:STDOUT: %array_type.loc6_24.2 => constants.%array_type.15a
  807. // CHECK:STDOUT:
  808. // CHECK:STDOUT: !definition:
  809. // CHECK:STDOUT: %require_complete.loc6_27 => constants.%complete_type.357
  810. // CHECK:STDOUT: %require_complete.loc6_17 => constants.%complete_type.8eb
  811. // CHECK:STDOUT: }
  812. // CHECK:STDOUT:
  813. // CHECK:STDOUT: --- fail_type_mismatch.carbon
  814. // CHECK:STDOUT:
  815. // CHECK:STDOUT: constants {
  816. // CHECK:STDOUT: %C: type = class_type @C [template]
  817. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  818. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  819. // CHECK:STDOUT: %D: type = class_type @D [template]
  820. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [template]
  821. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [template]
  822. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic]
  823. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic]
  824. // CHECK:STDOUT: %array_type.6a2: type = array_type %N, %C [symbolic]
  825. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  826. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  827. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  828. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  829. // CHECK:STDOUT: %require_complete.d82: <witness> = require_complete_type %array_type.6a2 [symbolic]
  830. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  831. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  832. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  833. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  834. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  835. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  836. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  837. // CHECK:STDOUT: %Convert.bound.41f: <bound method> = bound_method %N, %Convert.956 [symbolic]
  838. // CHECK:STDOUT: %Convert.specific_fn.122: <specific function> = specific_function %Convert.bound.41f, @Convert.2(%int_32) [symbolic]
  839. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn.122(%N) [symbolic]
  840. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  841. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  842. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  843. // CHECK:STDOUT: %array_type.fe4: type = array_type %int_3.1ba, %D [template]
  844. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  845. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  846. // CHECK:STDOUT: %D.val: %D = struct_value () [template]
  847. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  848. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  849. // CHECK:STDOUT: %array: %array_type.fe4 = tuple_value (%D.val, %D.val, %D.val) [template]
  850. // CHECK:STDOUT: %array_type.002: type = array_type %int_3.1ba, %C [template]
  851. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%int_3.1ba) [template]
  852. // CHECK:STDOUT: %complete_type.dd1: <witness> = complete_type_witness %array_type.002 [template]
  853. // CHECK:STDOUT: %Convert.bound.b30: <bound method> = bound_method %int_3.1ba, %Convert.956 [template]
  854. // CHECK:STDOUT: %Convert.specific_fn.b42: <specific function> = specific_function %Convert.bound.b30, @Convert.2(%int_32) [template]
  855. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [template]
  856. // CHECK:STDOUT: }
  857. // CHECK:STDOUT:
  858. // CHECK:STDOUT: imports {
  859. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  860. // CHECK:STDOUT: .IntLiteral = %Core.IntLiteral
  861. // CHECK:STDOUT: .Int = %Core.Int
  862. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  863. // CHECK:STDOUT: import Core//prelude
  864. // CHECK:STDOUT: import Core//prelude/...
  865. // CHECK:STDOUT: }
  866. // CHECK:STDOUT: %Core.IntLiteral: %IntLiteral.type = import_ref Core//prelude/types/int_literal, IntLiteral, loaded [template = constants.%IntLiteral]
  867. // CHECK:STDOUT: }
  868. // CHECK:STDOUT:
  869. // CHECK:STDOUT: file {
  870. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  871. // CHECK:STDOUT: .Core = imports.%Core
  872. // CHECK:STDOUT: .C = %C.decl
  873. // CHECK:STDOUT: .D = %D.decl
  874. // CHECK:STDOUT: .F = %F.decl
  875. // CHECK:STDOUT: .G = %G.decl
  876. // CHECK:STDOUT: }
  877. // CHECK:STDOUT: %Core.import = import Core
  878. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  879. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {} {}
  880. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  881. // CHECK:STDOUT: %N.patt.loc7_6.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc7_6.2 (constants.%N.patt)]
  882. // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc7_6.1, runtime_param<none> [symbolic = %N.patt.loc7_6.2 (constants.%N.patt)]
  883. // CHECK:STDOUT: %a.patt: @F.%array_type.loc7_37.2 (%array_type.6a2) = binding_pattern a
  884. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc7_37.2 (%array_type.6a2) = value_param_pattern %a.patt, runtime_param0
  885. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  886. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  887. // CHECK:STDOUT: } {
  888. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  889. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  890. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param<none>
  891. // CHECK:STDOUT: %.loc7_26.1: type = splice_block %.loc7_26.3 [template = Core.IntLiteral] {
  892. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  893. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [template = constants.%IntLiteral]
  894. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  895. // CHECK:STDOUT: %.loc7_26.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  896. // CHECK:STDOUT: %.loc7_26.3: type = converted %int_literal.make_type, %.loc7_26.2 [template = Core.IntLiteral]
  897. // CHECK:STDOUT: }
  898. // CHECK:STDOUT: %N.loc7_6.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc7_6.2 (constants.%N)]
  899. // CHECK:STDOUT: %a.param: @F.%array_type.loc7_37.2 (%array_type.6a2) = value_param runtime_param0
  900. // CHECK:STDOUT: %.loc7_37: type = splice_block %array_type.loc7_37.1 [symbolic = %array_type.loc7_37.2 (constants.%array_type.6a2)] {
  901. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  902. // CHECK:STDOUT: %N.ref.loc7_36: Core.IntLiteral = name_ref N, %N.loc7_6.1 [symbolic = %N.loc7_6.2 (constants.%N)]
  903. // CHECK:STDOUT: %array_type.loc7_37.1: type = array_type %N.ref.loc7_36, %C [symbolic = %array_type.loc7_37.2 (constants.%array_type.6a2)]
  904. // CHECK:STDOUT: }
  905. // CHECK:STDOUT: %a: @F.%array_type.loc7_37.2 (%array_type.6a2) = bind_name a, %a.param
  906. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  907. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  908. // CHECK:STDOUT: }
  909. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  910. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  911. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  912. // CHECK:STDOUT: } {
  913. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  914. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  915. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  916. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  917. // CHECK:STDOUT: }
  918. // CHECK:STDOUT: }
  919. // CHECK:STDOUT:
  920. // CHECK:STDOUT: class @C {
  921. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  922. // CHECK:STDOUT: complete_type_witness = %complete_type
  923. // CHECK:STDOUT:
  924. // CHECK:STDOUT: !members:
  925. // CHECK:STDOUT: .Self = constants.%C
  926. // CHECK:STDOUT: }
  927. // CHECK:STDOUT:
  928. // CHECK:STDOUT: class @D {
  929. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  930. // CHECK:STDOUT: complete_type_witness = %complete_type
  931. // CHECK:STDOUT:
  932. // CHECK:STDOUT: !members:
  933. // CHECK:STDOUT: .Self = constants.%D
  934. // CHECK:STDOUT: }
  935. // CHECK:STDOUT:
  936. // CHECK:STDOUT: generic fn @F(%N.loc7_6.1: Core.IntLiteral) {
  937. // CHECK:STDOUT: %N.loc7_6.2: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N.loc7_6.2 (constants.%N)]
  938. // CHECK:STDOUT: %N.patt.loc7_6.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc7_6.2 (constants.%N.patt)]
  939. // CHECK:STDOUT: %array_type.loc7_37.2: type = array_type %N.loc7_6.2, %C [symbolic = %array_type.loc7_37.2 (constants.%array_type.6a2)]
  940. // CHECK:STDOUT:
  941. // CHECK:STDOUT: !definition:
  942. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%array_type.loc7_37.2 (%array_type.6a2) [symbolic = %require_complete (constants.%require_complete.d82)]
  943. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.loc7_6.2, constants.%Convert.956 [symbolic = %Convert.bound (constants.%Convert.bound.41f)]
  944. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)]
  945. // CHECK:STDOUT: %int.convert_checked.loc7_57.2: init %i32 = call %Convert.specific_fn(%N.loc7_6.2) [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)]
  946. // CHECK:STDOUT:
  947. // CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%a.param_patt: @F.%array_type.loc7_37.2 (%array_type.6a2)) -> %i32 {
  948. // CHECK:STDOUT: !entry:
  949. // CHECK:STDOUT: %N.ref.loc7_56: Core.IntLiteral = name_ref N, %N.loc7_6.1 [symbolic = %N.loc7_6.2 (constants.%N)]
  950. // CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  951. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %N.ref.loc7_56, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound.41f)]
  952. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method, @Convert.2(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn.122)]
  953. // CHECK:STDOUT: %int.convert_checked.loc7_57.1: init %i32 = call %specific_fn(%N.ref.loc7_56) [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)]
  954. // CHECK:STDOUT: %.loc7_57.1: %i32 = value_of_initializer %int.convert_checked.loc7_57.1 [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)]
  955. // CHECK:STDOUT: %.loc7_57.2: %i32 = converted %N.ref.loc7_56, %.loc7_57.1 [symbolic = %int.convert_checked.loc7_57.2 (constants.%int.convert_checked)]
  956. // CHECK:STDOUT: return %.loc7_57.2
  957. // CHECK:STDOUT: }
  958. // CHECK:STDOUT: }
  959. // CHECK:STDOUT:
  960. // CHECK:STDOUT: fn @G() -> %i32 {
  961. // CHECK:STDOUT: !entry:
  962. // CHECK:STDOUT: name_binding_decl {
  963. // CHECK:STDOUT: %a.patt: %array_type.fe4 = binding_pattern a
  964. // CHECK:STDOUT: %.loc11_3.1: %array_type.fe4 = var_pattern %a.patt
  965. // CHECK:STDOUT: }
  966. // CHECK:STDOUT: %a.var: ref %array_type.fe4 = var a
  967. // CHECK:STDOUT: %.loc11_21.1: %empty_struct_type = struct_literal ()
  968. // CHECK:STDOUT: %.loc11_25.1: %empty_struct_type = struct_literal ()
  969. // CHECK:STDOUT: %.loc11_29.1: %empty_struct_type = struct_literal ()
  970. // CHECK:STDOUT: %.loc11_30.1: %tuple.type = tuple_literal (%.loc11_21.1, %.loc11_25.1, %.loc11_29.1)
  971. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  972. // CHECK:STDOUT: %.loc11_30.2: ref %D = array_index %a.var, %int_0
  973. // CHECK:STDOUT: %.loc11_21.2: init %D = class_init (), %.loc11_30.2 [template = constants.%D.val]
  974. // CHECK:STDOUT: %.loc11_30.3: init %D = converted %.loc11_21.1, %.loc11_21.2 [template = constants.%D.val]
  975. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  976. // CHECK:STDOUT: %.loc11_30.4: ref %D = array_index %a.var, %int_1
  977. // CHECK:STDOUT: %.loc11_25.2: init %D = class_init (), %.loc11_30.4 [template = constants.%D.val]
  978. // CHECK:STDOUT: %.loc11_30.5: init %D = converted %.loc11_25.1, %.loc11_25.2 [template = constants.%D.val]
  979. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  980. // CHECK:STDOUT: %.loc11_30.6: ref %D = array_index %a.var, %int_2
  981. // CHECK:STDOUT: %.loc11_29.2: init %D = class_init (), %.loc11_30.6 [template = constants.%D.val]
  982. // CHECK:STDOUT: %.loc11_30.7: init %D = converted %.loc11_29.1, %.loc11_29.2 [template = constants.%D.val]
  983. // CHECK:STDOUT: %.loc11_30.8: init %array_type.fe4 = array_init (%.loc11_30.3, %.loc11_30.5, %.loc11_30.7) to %a.var [template = constants.%array]
  984. // CHECK:STDOUT: %.loc11_3.2: init %array_type.fe4 = converted %.loc11_30.1, %.loc11_30.8 [template = constants.%array]
  985. // CHECK:STDOUT: assign %a.var, %.loc11_3.2
  986. // CHECK:STDOUT: %.loc11_15: type = splice_block %array_type [template = constants.%array_type.fe4] {
  987. // CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [template = constants.%D]
  988. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  989. // CHECK:STDOUT: %array_type: type = array_type %int_3, %D [template = constants.%array_type.fe4]
  990. // CHECK:STDOUT: }
  991. // CHECK:STDOUT: %a: ref %array_type.fe4 = bind_name a, %a.var
  992. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  993. // CHECK:STDOUT: %a.ref: ref %array_type.fe4 = name_ref a, %a
  994. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%int_3.1ba) [template = constants.%F.specific_fn]
  995. // CHECK:STDOUT: %.loc22_12: %array_type.002 = converted %a.ref, <error> [template = <error>]
  996. // CHECK:STDOUT: %F.call: init %i32 = call %F.specific_fn(<error>)
  997. // CHECK:STDOUT: %.loc22_14.1: %i32 = value_of_initializer %F.call
  998. // CHECK:STDOUT: %.loc22_14.2: %i32 = converted %F.call, %.loc22_14.1
  999. // CHECK:STDOUT: return %.loc22_14.2
  1000. // CHECK:STDOUT: }
  1001. // CHECK:STDOUT:
  1002. // CHECK:STDOUT: specific @F(constants.%N) {
  1003. // CHECK:STDOUT: %N.loc7_6.2 => constants.%N
  1004. // CHECK:STDOUT: %N.patt.loc7_6.2 => constants.%N
  1005. // CHECK:STDOUT: %array_type.loc7_37.2 => constants.%array_type.6a2
  1006. // CHECK:STDOUT: }
  1007. // CHECK:STDOUT:
  1008. // CHECK:STDOUT: specific @F(constants.%int_3.1ba) {
  1009. // CHECK:STDOUT: %N.loc7_6.2 => constants.%int_3.1ba
  1010. // CHECK:STDOUT: %N.patt.loc7_6.2 => constants.%int_3.1ba
  1011. // CHECK:STDOUT: %array_type.loc7_37.2 => constants.%array_type.002
  1012. // CHECK:STDOUT:
  1013. // CHECK:STDOUT: !definition:
  1014. // CHECK:STDOUT: %require_complete => constants.%complete_type.dd1
  1015. // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound.b30
  1016. // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn.b42
  1017. // CHECK:STDOUT: %int.convert_checked.loc7_57.2 => constants.%int_3.822
  1018. // CHECK:STDOUT: }
  1019. // CHECK:STDOUT:
  1020. // CHECK:STDOUT: --- fail_bound_type_mismatch.carbon
  1021. // CHECK:STDOUT:
  1022. // CHECK:STDOUT: constants {
  1023. // CHECK:STDOUT: %C: type = class_type @C [template]
  1024. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  1025. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [template]
  1026. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  1027. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  1028. // CHECK:STDOUT: %N.51e: %i32 = bind_symbolic_name N, 0 [symbolic]
  1029. // CHECK:STDOUT: %N.patt.8e2: %i32 = symbolic_binding_pattern N, 0 [symbolic]
  1030. // CHECK:STDOUT: %ImplicitAs.type.2fd: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [template]
  1031. // CHECK:STDOUT: %Convert.type.71e: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
  1032. // CHECK:STDOUT: %impl_witness.023: <witness> = impl_witness (imports.%Core.import_ref.85c), @impl.2(%int_32) [template]
  1033. // CHECK:STDOUT: %Convert.type.4ad: type = fn_type @Convert.3, @impl.2(%int_32) [template]
  1034. // CHECK:STDOUT: %Convert.960: %Convert.type.4ad = struct_value () [template]
  1035. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.2fd = facet_value %i32, %impl_witness.023 [template]
  1036. // CHECK:STDOUT: %.10e: type = fn_type_with_self_type %Convert.type.71e, %ImplicitAs.facet [template]
  1037. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.51e, %Convert.960 [symbolic]
  1038. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.3(%int_32) [symbolic]
  1039. // CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %Convert.specific_fn(%N.51e) [symbolic]
  1040. // CHECK:STDOUT: %array_type.c13: type = array_type %int.convert_checked, %C [symbolic]
  1041. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  1042. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  1043. // CHECK:STDOUT: %require_complete.303: <witness> = require_complete_type %array_type.c13 [symbolic]
  1044. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  1045. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  1046. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template]
  1047. // CHECK:STDOUT: %array_type.002: type = array_type %int_3, %C [template]
  1048. // CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_struct_type, %empty_struct_type, %empty_struct_type) [template]
  1049. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  1050. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  1051. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  1052. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template]
  1053. // CHECK:STDOUT: %array: %array_type.002 = tuple_value (%C.val, %C.val, %C.val) [template]
  1054. // CHECK:STDOUT: }
  1055. // CHECK:STDOUT:
  1056. // CHECK:STDOUT: imports {
  1057. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1058. // CHECK:STDOUT: .Int = %Core.Int
  1059. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1060. // CHECK:STDOUT: import Core//prelude
  1061. // CHECK:STDOUT: import Core//prelude/...
  1062. // CHECK:STDOUT: }
  1063. // CHECK:STDOUT: }
  1064. // CHECK:STDOUT:
  1065. // CHECK:STDOUT: file {
  1066. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1067. // CHECK:STDOUT: .Core = imports.%Core
  1068. // CHECK:STDOUT: .C = %C.decl
  1069. // CHECK:STDOUT: .F = %F.decl
  1070. // CHECK:STDOUT: .G = %G.decl
  1071. // CHECK:STDOUT: }
  1072. // CHECK:STDOUT: %Core.import = import Core
  1073. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  1074. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  1075. // CHECK:STDOUT: %N.patt.loc6_6.1: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt.8e2)]
  1076. // CHECK:STDOUT: %N.param_patt: %i32 = value_param_pattern %N.patt.loc6_6.1, runtime_param<none> [symbolic = %N.patt.loc6_6.2 (constants.%N.patt.8e2)]
  1077. // CHECK:STDOUT: %a.patt: @F.%array_type.loc6_23.2 (%array_type.c13) = binding_pattern a
  1078. // CHECK:STDOUT: %a.param_patt: @F.%array_type.loc6_23.2 (%array_type.c13) = value_param_pattern %a.patt, runtime_param0
  1079. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  1080. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  1081. // CHECK:STDOUT: } {
  1082. // CHECK:STDOUT: %int_32.loc6_29: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1083. // CHECK:STDOUT: %i32.loc6_29: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1084. // CHECK:STDOUT: %N.param: %i32 = value_param runtime_param<none>
  1085. // CHECK:STDOUT: %.loc6_10: type = splice_block %i32.loc6_10 [template = constants.%i32] {
  1086. // CHECK:STDOUT: %int_32.loc6_10: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1087. // CHECK:STDOUT: %i32.loc6_10: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1088. // CHECK:STDOUT: }
  1089. // CHECK:STDOUT: %N.loc6_6.1: %i32 = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc6_6.2 (constants.%N.51e)]
  1090. // CHECK:STDOUT: %a.param: @F.%array_type.loc6_23.2 (%array_type.c13) = value_param runtime_param0
  1091. // CHECK:STDOUT: %.loc6_23: type = splice_block %array_type.loc6_23.1 [symbolic = %array_type.loc6_23.2 (constants.%array_type.c13)] {
  1092. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  1093. // CHECK:STDOUT: %N.ref.loc6_22: %i32 = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N.51e)]
  1094. // CHECK:STDOUT: %impl.elem0: %.10e = impl_witness_access constants.%impl_witness.023, element0 [template = constants.%Convert.960]
  1095. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %N.ref.loc6_22, %impl.elem0 [symbolic = %Convert.bound (constants.%Convert.bound)]
  1096. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)]
  1097. // CHECK:STDOUT: %int.convert_checked.loc6_22.1: init Core.IntLiteral = call %specific_fn(%N.ref.loc6_22) [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)]
  1098. // CHECK:STDOUT: %.loc6_22.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc6_22.1 [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)]
  1099. // CHECK:STDOUT: %.loc6_22.2: Core.IntLiteral = converted %N.ref.loc6_22, %.loc6_22.1 [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)]
  1100. // CHECK:STDOUT: %array_type.loc6_23.1: type = array_type %.loc6_22.2, %C [symbolic = %array_type.loc6_23.2 (constants.%array_type.c13)]
  1101. // CHECK:STDOUT: }
  1102. // CHECK:STDOUT: %a: @F.%array_type.loc6_23.2 (%array_type.c13) = bind_name a, %a.param
  1103. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  1104. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  1105. // CHECK:STDOUT: }
  1106. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  1107. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  1108. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param0
  1109. // CHECK:STDOUT: } {
  1110. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  1111. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  1112. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param0
  1113. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  1114. // CHECK:STDOUT: }
  1115. // CHECK:STDOUT: }
  1116. // CHECK:STDOUT:
  1117. // CHECK:STDOUT: class @C {
  1118. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.357]
  1119. // CHECK:STDOUT: complete_type_witness = %complete_type
  1120. // CHECK:STDOUT:
  1121. // CHECK:STDOUT: !members:
  1122. // CHECK:STDOUT: .Self = constants.%C
  1123. // CHECK:STDOUT: }
  1124. // CHECK:STDOUT:
  1125. // CHECK:STDOUT: generic fn @F(%N.loc6_6.1: %i32) {
  1126. // CHECK:STDOUT: %N.loc6_6.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc6_6.2 (constants.%N.51e)]
  1127. // CHECK:STDOUT: %N.patt.loc6_6.2: %i32 = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc6_6.2 (constants.%N.patt.8e2)]
  1128. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %N.loc6_6.2, constants.%Convert.960 [symbolic = %Convert.bound (constants.%Convert.bound)]
  1129. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.3(constants.%int_32) [symbolic = %Convert.specific_fn (constants.%Convert.specific_fn)]
  1130. // CHECK:STDOUT: %int.convert_checked.loc6_22.2: init Core.IntLiteral = call %Convert.specific_fn(%N.loc6_6.2) [symbolic = %int.convert_checked.loc6_22.2 (constants.%int.convert_checked)]
  1131. // CHECK:STDOUT: %array_type.loc6_23.2: type = array_type %int.convert_checked.loc6_22.2, %C [symbolic = %array_type.loc6_23.2 (constants.%array_type.c13)]
  1132. // CHECK:STDOUT:
  1133. // CHECK:STDOUT: !definition:
  1134. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @F.%array_type.loc6_23.2 (%array_type.c13) [symbolic = %require_complete (constants.%require_complete.303)]
  1135. // CHECK:STDOUT:
  1136. // CHECK:STDOUT: fn[%N.param_patt: %i32](%a.param_patt: @F.%array_type.loc6_23.2 (%array_type.c13)) -> %i32 {
  1137. // CHECK:STDOUT: !entry:
  1138. // CHECK:STDOUT: %N.ref.loc6_42: %i32 = name_ref N, %N.loc6_6.1 [symbolic = %N.loc6_6.2 (constants.%N.51e)]
  1139. // CHECK:STDOUT: return %N.ref.loc6_42
  1140. // CHECK:STDOUT: }
  1141. // CHECK:STDOUT: }
  1142. // CHECK:STDOUT:
  1143. // CHECK:STDOUT: fn @G() -> %i32 {
  1144. // CHECK:STDOUT: !entry:
  1145. // CHECK:STDOUT: name_binding_decl {
  1146. // CHECK:STDOUT: %a.patt: %array_type.002 = binding_pattern a
  1147. // CHECK:STDOUT: %.loc9_3.1: %array_type.002 = var_pattern %a.patt
  1148. // CHECK:STDOUT: }
  1149. // CHECK:STDOUT: %a.var: ref %array_type.002 = var a
  1150. // CHECK:STDOUT: %.loc9_21.1: %empty_struct_type = struct_literal ()
  1151. // CHECK:STDOUT: %.loc9_25.1: %empty_struct_type = struct_literal ()
  1152. // CHECK:STDOUT: %.loc9_29.1: %empty_struct_type = struct_literal ()
  1153. // CHECK:STDOUT: %.loc9_30.1: %tuple.type = tuple_literal (%.loc9_21.1, %.loc9_25.1, %.loc9_29.1)
  1154. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  1155. // CHECK:STDOUT: %.loc9_30.2: ref %C = array_index %a.var, %int_0
  1156. // CHECK:STDOUT: %.loc9_21.2: init %C = class_init (), %.loc9_30.2 [template = constants.%C.val]
  1157. // CHECK:STDOUT: %.loc9_30.3: init %C = converted %.loc9_21.1, %.loc9_21.2 [template = constants.%C.val]
  1158. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  1159. // CHECK:STDOUT: %.loc9_30.4: ref %C = array_index %a.var, %int_1
  1160. // CHECK:STDOUT: %.loc9_25.2: init %C = class_init (), %.loc9_30.4 [template = constants.%C.val]
  1161. // CHECK:STDOUT: %.loc9_30.5: init %C = converted %.loc9_25.1, %.loc9_25.2 [template = constants.%C.val]
  1162. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
  1163. // CHECK:STDOUT: %.loc9_30.6: ref %C = array_index %a.var, %int_2
  1164. // CHECK:STDOUT: %.loc9_29.2: init %C = class_init (), %.loc9_30.6 [template = constants.%C.val]
  1165. // CHECK:STDOUT: %.loc9_30.7: init %C = converted %.loc9_29.1, %.loc9_29.2 [template = constants.%C.val]
  1166. // CHECK:STDOUT: %.loc9_30.8: init %array_type.002 = array_init (%.loc9_30.3, %.loc9_30.5, %.loc9_30.7) to %a.var [template = constants.%array]
  1167. // CHECK:STDOUT: %.loc9_3.2: init %array_type.002 = converted %.loc9_30.1, %.loc9_30.8 [template = constants.%array]
  1168. // CHECK:STDOUT: assign %a.var, %.loc9_3.2
  1169. // CHECK:STDOUT: %.loc9_15: type = splice_block %array_type [template = constants.%array_type.002] {
  1170. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  1171. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
  1172. // CHECK:STDOUT: %array_type: type = array_type %int_3, %C [template = constants.%array_type.002]
  1173. // CHECK:STDOUT: }
  1174. // CHECK:STDOUT: %a: ref %array_type.002 = bind_name a, %a.var
  1175. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  1176. // CHECK:STDOUT: %a.ref: ref %array_type.002 = name_ref a, %a
  1177. // CHECK:STDOUT: return <error>
  1178. // CHECK:STDOUT: }
  1179. // CHECK:STDOUT:
  1180. // CHECK:STDOUT: specific @F(constants.%N.51e) {
  1181. // CHECK:STDOUT: %N.loc6_6.2 => constants.%N.51e
  1182. // CHECK:STDOUT: %N.patt.loc6_6.2 => constants.%N.51e
  1183. // CHECK:STDOUT: %Convert.bound => constants.%Convert.bound
  1184. // CHECK:STDOUT: %Convert.specific_fn => constants.%Convert.specific_fn
  1185. // CHECK:STDOUT: %int.convert_checked.loc6_22.2 => constants.%int.convert_checked
  1186. // CHECK:STDOUT: %array_type.loc6_23.2 => constants.%array_type.c13
  1187. // CHECK:STDOUT: }
  1188. // CHECK:STDOUT: