| ... | ... | @@ -3518,9 +3518,26 @@ fn makeIntType(self: *Module, scope: *Scope, signed: bool, bits: u16) !Type { |
| 3518 | 3518 | fn resolvePeerTypes(self: *Module, scope: *Scope, instructions: []*Inst) !Type { |
| 3519 | 3519 | if (instructions.len == 0) |
| 3520 | 3520 | return Type.initTag(.noreturn); |
| 3521 | |
| 3521 | 3522 | if (instructions.len == 1) |
| 3522 | 3523 | return instructions[0].ty; |
| 3523 | | return self.fail(scope, instructions[0].src, "TODO peer type resolution", .{}); |
| 3524 | |
| 3525 | var prev_inst = instructions[0]; |
| 3526 | for (instructions[1..]) |next_inst| { |
| 3527 | if (next_inst.ty.eql(prev_inst.ty)) |
| 3528 | continue; |
| 3529 | if (next_inst.ty.zigTypeTag() == .NoReturn) |
| 3530 | continue; |
| 3531 | if (prev_inst.ty.zigTypeTag() == .NoReturn) { |
| 3532 | prev_inst = next_inst; |
| 3533 | continue; |
| 3534 | } |
| 3535 | |
| 3536 | // TODO error notes pointing out each type |
| 3537 | return self.fail(scope, next_inst.src, "incompatible types: '{}' and '{}'", .{ prev_inst.ty, next_inst.ty }); |
| 3538 | } |
| 3539 | |
| 3540 | return prev_inst.ty; |
| 3524 | 3541 | } |
| 3525 | 3542 | |
| 3526 | 3543 | fn coerce(self: *Module, scope: *Scope, dest_type: Type, inst: *Inst) !*Inst { |