From 7d69e1d84e272251e6aead39c551154797c2b1a4 Mon Sep 17 00:00:00 2001 From: Noam Preil Date: Wed, 7 Oct 2020 02:36:04 -0400 Subject: Rename variables in resolvePeerTypes for clarity --- src/Module.zig | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index b3bdefceec..1abaf2a63a 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2629,52 +2629,52 @@ pub fn resolvePeerTypes(self: *Module, scope: *Scope, instructions: []*Inst) !Ty if (instructions.len == 1) return instructions[0].ty; - var prev_inst = instructions[0]; - for (instructions[1..]) |next_inst| { - if (next_inst.ty.eql(prev_inst.ty)) + var chosen = instructions[0]; + for (instructions[1..]) |candidate| { + if (candidate.ty.eql(chosen.ty)) continue; - if (next_inst.ty.zigTypeTag() == .NoReturn) + if (candidate.ty.zigTypeTag() == .NoReturn) continue; - if (prev_inst.ty.zigTypeTag() == .NoReturn) { - prev_inst = next_inst; + if (chosen.ty.zigTypeTag() == .NoReturn) { + chosen = candidate; continue; } - if (next_inst.ty.zigTypeTag() == .Undefined) + if (candidate.ty.zigTypeTag() == .Undefined) continue; - if (prev_inst.ty.zigTypeTag() == .Undefined) { - prev_inst = next_inst; + if (chosen.ty.zigTypeTag() == .Undefined) { + chosen = candidate; continue; } - if (prev_inst.ty.isInt() and - next_inst.ty.isInt() and - prev_inst.ty.isSignedInt() == next_inst.ty.isSignedInt()) + if (chosen.ty.isInt() and + candidate.ty.isInt() and + chosen.ty.isSignedInt() == candidate.ty.isSignedInt()) { - if (prev_inst.ty.intInfo(self.getTarget()).bits < next_inst.ty.intInfo(self.getTarget()).bits) { - prev_inst = next_inst; + if (chosen.ty.intInfo(self.getTarget()).bits < candidate.ty.intInfo(self.getTarget()).bits) { + chosen = candidate; } continue; } - if (prev_inst.ty.isFloat() and next_inst.ty.isFloat()) { - if (prev_inst.ty.floatBits(self.getTarget()) < next_inst.ty.floatBits(self.getTarget())) { - prev_inst = next_inst; + if (chosen.ty.isFloat() and candidate.ty.isFloat()) { + if (chosen.ty.floatBits(self.getTarget()) < candidate.ty.floatBits(self.getTarget())) { + chosen = candidate; } continue; } - if (prev_inst.ty.zigTypeTag() == .ComptimeInt and next_inst.ty.isInt()) { - prev_inst = next_inst; + if (chosen.ty.zigTypeTag() == .ComptimeInt and candidate.ty.isInt()) { + chosen = candidate; continue; } - if (prev_inst.ty.isInt() and next_inst.ty.zigTypeTag() == .ComptimeInt) { + if (chosen.ty.isInt() and candidate.ty.zigTypeTag() == .ComptimeInt) { continue; } // TODO error notes pointing out each type - return self.fail(scope, next_inst.src, "incompatible types: '{}' and '{}'", .{ prev_inst.ty, next_inst.ty }); + return self.fail(scope, candidate.src, "incompatible types: '{}' and '{}'", .{ chosen.ty, candidate.ty }); } - return prev_inst.ty; + return chosen.ty; } pub fn coerce(self: *Module, scope: *Scope, dest_type: Type, inst: *Inst) !*Inst { -- cgit v1.2.3