Contrived example:
// ...
const i: i32 = 1;
const t: f32 = @floatFromInt(i) * std.math.pi;
// ...
Result:
./example.zig:5:20: error: @floatFromInt must have a known result type
const t: f32 = @floatFromInt(i) * std.math.pi;
^~~~~~~~~~~~~~~~
./example.zig:5:20: note: use @as to provide explicit result type
I run into situations like this all the time. The conversion should be obvious if you look at the type of the destination variable. And indeed, the type parameter was removed from these functions since it was supposed to figure out the destination type on it’s own. So why do I have to write @as(f32, …) everywhere?
I tested this in Compiler Explorer, both for 0.15.2 and trunk, and get the same error for both. Is this on the roadmap for improvement?