when a runtime integer type, with a comptime known value is used in a context where the comptime known value is usable, it behaves like its a comptime_int even though its not supposed to be?
this:
pub fn main() !void {
const i: u128 = 5;
const a = [_]u8{ 1, 2, 3, 4, 5, 6, 6 };
std.debug.print("{}", .{a[i]});
}
compiles and runs
but this:
pub fn main() !void {
const i: u128 = 5;
std.debug.print("{}", .{foo(i)});
}
fn foo(i: u128) u8 {
const a = [_]u8{ 1, 2, 3, 4, 5, 6, 6 };
return a[i];
}
gets a compile error.
I tested with a couple of integer types, including signed ones, the behaviour is consistent.
Shouldnât zig honour type soundness even if it knows in this case it would work with the given value?