aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-10-27 00:48:56 +0300
committerVeikka Tuominen <git@vexu.eu>2022-10-27 01:31:18 +0300
commitb937a045607deae158ccb6a00f5defaf36510e61 (patch)
tree962f15f44d455e77dd8a3369bd4125b740679853 /src
parentf3a3fb3d880528e8b6404648c605ed092ef1412c (diff)
downloadzig-b937a045607deae158ccb6a00f5defaf36510e61.tar.gz
zig-b937a045607deae158ccb6a00f5defaf36510e61.zip
Sema: check `coerceInMemoryAllowed` earlier in `resolvePeerTypes`
Closes #13310
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index d1a558d15b..b41dd21b81 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -28340,8 +28340,16 @@ fn resolvePeerTypes(
const candidate_ty_tag = try candidate_ty.zigTypeTagOrPoison();
const chosen_ty_tag = try chosen_ty.zigTypeTagOrPoison();
- if (candidate_ty.eql(chosen_ty, sema.mod))
+ // If the candidate can coerce into our chosen type, we're done.
+ // If the chosen type can coerce into the candidate, use that.
+ if ((try sema.coerceInMemoryAllowed(block, chosen_ty, candidate_ty, false, target, src, src)) == .ok) {
+ continue;
+ }
+ if ((try sema.coerceInMemoryAllowed(block, candidate_ty, chosen_ty, false, target, src, src)) == .ok) {
+ chosen = candidate;
+ chosen_i = candidate_i + 1;
continue;
+ }
switch (candidate_ty_tag) {
.NoReturn, .Undefined => continue,
@@ -28741,17 +28749,6 @@ fn resolvePeerTypes(
else => {},
}
- // If the candidate can coerce into our chosen type, we're done.
- // If the chosen type can coerce into the candidate, use that.
- if ((try sema.coerceInMemoryAllowed(block, chosen_ty, candidate_ty, false, target, src, src)) == .ok) {
- continue;
- }
- if ((try sema.coerceInMemoryAllowed(block, candidate_ty, chosen_ty, false, target, src, src)) == .ok) {
- chosen = candidate;
- chosen_i = candidate_i + 1;
- continue;
- }
-
// At this point, we hit a compile error. We need to recover
// the source locations.
const chosen_src = candidate_srcs.resolve(