From 26be5bb8b1e1c05ceab4b7620efa2a058a174886 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 3 Mar 2022 17:01:31 -0800 Subject: stage2: peer resolve *T to [*c]T --- src/Sema.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/Sema.zig b/src/Sema.zig index eb5265d404..ab9d36f3c8 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -18280,6 +18280,17 @@ fn resolvePeerTypes( }, .Pointer => { if (candidate_ty.ptrSize() == .C) { + // *T to [*c]T + if (chosen_ty_tag == .Pointer) { + const chosen_elem_ty = chosen_ty.childType(); + const candidate_elem_ty = candidate_ty.childType(); + if ((try sema.coerceInMemoryAllowed(block, chosen_elem_ty, candidate_elem_ty, false, target, src, src)) == .ok) { + chosen = candidate; + chosen_i = candidate_i + 1; + continue; + } + } + if (chosen_ty_tag == .Int or chosen_ty_tag == .ComptimeInt) { chosen = candidate; chosen_i = candidate_i + 1; @@ -18290,6 +18301,15 @@ fn resolvePeerTypes( } } + // [*c]T and *T + if (chosen_ty_tag == .Pointer and chosen_ty.ptrSize() == .C) { + const chosen_elem_ty = chosen_ty.childType(); + const candidate_elem_ty = candidate_ty.childType(); + if ((try sema.coerceInMemoryAllowed(block, chosen_elem_ty, candidate_elem_ty, false, target, src, src)) == .ok) { + continue; + } + } + // *[N]T to [*]T if (candidate_ty.ptrSize() == .Many and chosen_ty_tag == .Pointer and -- cgit v1.2.3