zig
zig copied to clipboard
Error message column indicator points to the incorrect part of the line when using @as when @intCast was necessary
Zig Version
0.11.0-dev.1838+3a73216b1
Steps to Reproduce and Observed Behavior
Compile this code (which is incorrectly using @as when it should be @intCast):
pub fn main() !void {
var arr: [3]u16 = undefined;
for (arr, 0..) |_, ix| {
arr[ix] = @as(u16, ix);
}
}
That yields this error:
src\main.zig:4:13: error: expected type 'u16', found 'usize'
arr[ix] = @as(u16, ix);
^~
Expected Behavior
The ^~ should be pointing to the ix.
For reference, without the @as:
pub fn main() !void {
var arr: [3]u16 = undefined;
for (arr, 0..) |_, ix| {
arr[ix] = ix;
}
}
The error indicator points to ix:
src\main.zig:4:19: error: expected type 'u16', found 'usize'
arr[ix] = ix;
^~