diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-02-28 09:41:03 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-02-28 20:42:13 -0700 |
| commit | 0ce2d46ff9b520ebd09f499cd2caf6e5667f5fa7 (patch) | |
| tree | 78859051047e074eb6be8c6674f8ee70a930c942 /src/Sema.zig | |
| parent | ea00e500457231083263302cc6972998a1a92910 (diff) | |
| download | zig-0ce2d46ff9b520ebd09f499cd2caf6e5667f5fa7.tar.gz zig-0ce2d46ff9b520ebd09f499cd2caf6e5667f5fa7.zip | |
stage2: error union/set peer resolution switch to "else" form of for loop
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index e69d0829f1..b395f85d00 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -17738,23 +17738,17 @@ fn resolvePeerTypes( // If chosen is superset of candidate, keep it. // If candidate is superset of chosen, switch it. // If neither is a superset, merge errors. - var prev_is_superset = true; for (candidate_ty.errorSetNames()) |name| { if (!err_set_ty.?.errorSetHasField(name)) { - prev_is_superset = false; break; } - } - if (prev_is_superset) continue; // use previous + } else continue; - var cand_is_superset = true; for (err_set_ty.?.errorSetNames()) |name| { if (!candidate_ty.errorSetHasField(name)) { - cand_is_superset = false; break; } - } - if (cand_is_superset) { + } else { // Swap to candidate err_set_ty = candidate_ty; chosen = candidate; @@ -17801,14 +17795,11 @@ fn resolvePeerTypes( } // If previous is superset, keep the previous - var prev_is_superset = true; for (candidate_ty.errorSetNames()) |name| { if (!err_set_ty.?.errorSetHasField(name)) { - prev_is_superset = false; break; } - } - if (prev_is_superset) continue; // use previous + } else continue; // Merge err_set_ty = try err_set_ty.?.errorSetMerge(sema.arena, candidate_ty); @@ -17834,14 +17825,11 @@ fn resolvePeerTypes( } // If candidate is a superset of the error type, then use it. - var cand_is_superset = true; for (err_set_ty.?.errorSetNames()) |name| { if (!eu_set_ty.errorSetHasField(name)) { - cand_is_superset = false; break; } - } - if (cand_is_superset) { + } else { // Swap to candidate err_set_ty = eu_set_ty; chosen = candidate; @@ -17901,23 +17889,17 @@ fn resolvePeerTypes( if (err_set_ty == null) err_set_ty = chosen_set_ty; // If the previous error set type is a superset, we're done. - var prev_is_superset = true; for (candidate_set_ty.errorSetNames()) |name| { if (!chosen_set_ty.errorSetHasField(name)) { - prev_is_superset = false; break; } - } - if (prev_is_superset) continue; // use previous + } else continue; - var cand_is_superset = true; for (chosen_set_ty.errorSetNames()) |name| { if (!candidate_set_ty.errorSetHasField(name)) { - cand_is_superset = false; break; } - } - if (cand_is_superset) { + } else { err_set_ty = candidate_ty; continue; } |
