fixing upcasting signed to unsigned

This commit is contained in:
Jakub Doka 2024-10-25 15:45:00 +02:00
parent e62aab9b4b
commit b1da36ecde
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
4 changed files with 7 additions and 0 deletions

View file

@ -842,6 +842,11 @@ integer_range := fn(min: uint, max: uint): uint {
}
```
#### signed_to_unsigned_upcast
```hb
main := fn(): uint return @as(i32, 1)
```
#### writing_into_string
```hb
outl := fn(): void {

View file

@ -434,6 +434,7 @@ mod ty {
_ if oa.is_pointer() && ob.is_pointer() => return None,
_ if a.is_signed() && b.is_signed() || a.is_unsigned() && b.is_unsigned() => ob,
_ if a.is_unsigned() && b.is_signed() && a.repr() - U8 < b.repr() - I8 => ob,
_ if a.is_unsigned() && b.is_signed() && a.repr() - U8 > b.repr() - I8 => oa,
_ if oa.is_integer() && ob.is_pointer() && kind == TyCheck::BinOp => ob,
_ => return None,
})

View file

@ -4435,6 +4435,7 @@ mod tests {
small_struct_assignment;
intcast_store;
string_flip;
signed_to_unsigned_upcast;
wide_ret;
comptime_min_reg_leak;
different_types;