stage2: apply type coercion in if expressions
When setting the break value in an if expression we must explicitly check if a result location type coercion that needs to happen. This was already done for switch expression, so let's just imitate that check and fix for if expressions. To make this possible, we now also propagate `rl_ty_inst` to sub scopes.
This commit is contained in:
committed by
Andrew Kelley
parent
adc9a282d8
commit
fd1284ebd0
@@ -693,3 +693,9 @@ test "variable name containing underscores does not shadow int primitive" {
|
||||
_ = u6__4;
|
||||
_ = i2_04_8;
|
||||
}
|
||||
|
||||
test "if expression type coercion" {
|
||||
var cond: bool = true;
|
||||
const x: u16 = if (cond) 1 else 0;
|
||||
try expect(@as(u16, x) == 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user