zig/test/cases/compile_errors/truncate_sign_mismatch.zig
mlugg f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00

26 lines
598 B
Zig

export fn entry1() i8 {
var x: u32 = 10;
return @truncate(x);
}
export fn entry2() u8 {
var x: i32 = -10;
return @truncate(x);
}
export fn entry3() i8 {
comptime var x: u32 = 10;
return @truncate(x);
}
export fn entry4() u8 {
comptime var x: i32 = -10;
return @truncate(x);
}
// error
// backend=stage2
// target=native
//
// :3:22: error: expected signed integer type, found 'u32'
// :7:22: error: expected unsigned integer type, found 'i32'
// :11:22: error: expected signed integer type, found 'u32'
// :15:22: error: expected unsigned integer type, found 'i32'