| ... | ... | @@ -17814,8 +17814,8 @@ fn resolvePeerTypes( |
| 17814 | 17814 | err_set_ty = try err_set_ty.?.errorSetMerge(sema.arena, candidate_ty); |
| 17815 | 17815 | continue; |
| 17816 | 17816 | }, |
| 17817 | | .ErrorUnion => { |
| 17818 | | if (chosen_ty_tag == .ErrorSet) { |
| 17817 | .ErrorUnion => switch (chosen_ty_tag) { |
| 17818 | .ErrorSet => { |
| 17819 | 17819 | if (err_set_ty.?.isAnyError()) { |
| 17820 | 17820 | chosen = candidate; |
| 17821 | 17821 | chosen_i = candidate_i + 1; |
| ... | ... | @@ -17854,9 +17854,9 @@ fn resolvePeerTypes( |
| 17854 | 17854 | chosen = candidate; |
| 17855 | 17855 | chosen_i = candidate_i + 1; |
| 17856 | 17856 | continue; |
| 17857 | | } |
| 17857 | }, |
| 17858 | 17858 | |
| 17859 | | if (chosen_ty_tag == .ErrorUnion) { |
| 17859 | .ErrorUnion => { |
| 17860 | 17860 | const chosen_payload_ty = chosen_ty.errorUnionPayload(); |
| 17861 | 17861 | const candidate_payload_ty = candidate_ty.errorUnionPayload(); |
| 17862 | 17862 | |
| ... | ... | @@ -17926,30 +17926,57 @@ fn resolvePeerTypes( |
| 17926 | 17926 | err_set_ty = try chosen_set_ty.errorSetMerge(sema.arena, candidate_ty); |
| 17927 | 17927 | continue; |
| 17928 | 17928 | } |
| 17929 | | } |
| 17929 | }, |
| 17930 | 17930 | |
| 17931 | | const payload_ty = candidate_ty.errorUnionPayload(); |
| 17932 | | if (chosen_ty_tag == .Pointer and |
| 17933 | | chosen_ty.ptrSize() == .One and |
| 17934 | | chosen_ty.childType().zigTypeTag() == .Array and |
| 17935 | | payload_ty.isSlice()) |
| 17936 | | { |
| 17937 | | const chosen_child_ty = chosen_ty.childType(); |
| 17938 | | const chosen_elem_ty = chosen_child_ty.elemType2(); |
| 17939 | | const candidate_elem_ty = payload_ty.elemType2(); |
| 17940 | | if ((try sema.coerceInMemoryAllowed(block, candidate_elem_ty, chosen_elem_ty, false, target, src, src)) == .ok) { |
| 17931 | .Pointer => { |
| 17932 | const payload_ty = candidate_ty.errorUnionPayload(); |
| 17933 | if (chosen_ty.ptrSize() == .One and |
| 17934 | chosen_ty.childType().zigTypeTag() == .Array and |
| 17935 | payload_ty.isSlice()) |
| 17936 | { |
| 17937 | const chosen_child_ty = chosen_ty.childType(); |
| 17938 | const chosen_elem_ty = chosen_child_ty.elemType2(); |
| 17939 | const candidate_elem_ty = payload_ty.elemType2(); |
| 17940 | if ((try sema.coerceInMemoryAllowed(block, candidate_elem_ty, chosen_elem_ty, false, target, src, src)) == .ok) { |
| 17941 | chosen = candidate; |
| 17942 | chosen_i = candidate_i + 1; |
| 17943 | |
| 17944 | convert_to_slice = false; // it already is a slice |
| 17945 | |
| 17946 | // If the prev pointer is const then we need to const |
| 17947 | if (chosen_child_ty.isConstPtr()) |
| 17948 | make_the_slice_const = true; |
| 17949 | |
| 17950 | continue; |
| 17951 | } |
| 17952 | } |
| 17953 | }, |
| 17954 | |
| 17955 | else => { |
| 17956 | // Chosen coercing into payload type |
| 17957 | // Then merge error sets (if any) |
| 17958 | const payload_ty = candidate_ty.errorUnionPayload(); |
| 17959 | if ((try sema.coerceInMemoryAllowed(block, payload_ty, chosen_ty, false, target, src, src)) == .ok) { |
| 17941 | 17960 | chosen = candidate; |
| 17942 | 17961 | chosen_i = candidate_i + 1; |
| 17943 | 17962 | |
| 17944 | | convert_to_slice = false; // it already is a slice |
| 17963 | if (err_set_ty) |ty| { |
| 17964 | const cand_set_ty = candidate_ty.errorUnionSet(); |
| 17965 | if (cand_set_ty.castTag(.error_set_inferred)) |inferred| { |
| 17966 | try sema.resolveInferredErrorSet(inferred.data); |
| 17967 | } |
| 17968 | if (cand_set_ty.isAnyError()) { |
| 17969 | err_set_ty = cand_set_ty; |
| 17970 | continue; |
| 17971 | } |
| 17972 | if (ty.isAnyError()) continue; |
| 17945 | 17973 | |
| 17946 | | // If the prev pointer is const then we need to const |
| 17947 | | if (chosen_child_ty.isConstPtr()) |
| 17948 | | make_the_slice_const = true; |
| 17974 | err_set_ty = try err_set_ty.?.errorSetMerge(sema.arena, cand_set_ty); |
| 17975 | } |
| 17949 | 17976 | |
| 17950 | 17977 | continue; |
| 17951 | 17978 | } |
| 17952 | | } |
| 17979 | }, |
| 17953 | 17980 | }, |
| 17954 | 17981 | .Pointer => { |
| 17955 | 17982 | if (candidate_ty.ptrSize() == .C) { |
| ... | ... | @@ -18115,6 +18142,12 @@ fn resolvePeerTypes( |
| 18115 | 18142 | continue; |
| 18116 | 18143 | } |
| 18117 | 18144 | }, |
| 18145 | .ErrorUnion => { |
| 18146 | const payload_ty = chosen_ty.errorUnionPayload(); |
| 18147 | if ((try sema.coerceInMemoryAllowed(block, payload_ty, candidate_ty, false, target, src, src)) == .ok) { |
| 18148 | continue; |
| 18149 | } |
| 18150 | }, |
| 18118 | 18151 | else => {}, |
| 18119 | 18152 | } |
| 18120 | 18153 | |