The following doesn't compile:
var a: [3]f32 = [_]u1{1.5, 10000, 10e100};
with the error,
error: fractional component prevents float value 1.500000 from being casted to type 'u1'
However, the following does compile:
var b: [3]f32 = undefined;
b = [3]u1{1.5, 10000, 10e100};
The second line could be [3] followed by literally any type, and the compiler will ignore the given type and treat the following literal as [3]f32 anyway.
Some more valid examples:
b = [3][1][2][3][4]u1{1.5, 10000, 10e100};
const Coordinate = struct {
x: f32, y: f32
};
...
b = [3][1][2][3][4]Coordinate{1.5, 10000, 10e100};
To clarify, the values are taken in as f32 and when warned with warn("b: {}, {}, {}\n", b[0], b[1], b[2]);, the following output is given: b: 1.5e+00, 1.0e+04, inf
test "" {
var b: [3]f32 = undefined;
b = [3]u1{ 1.5, 10000, 10e100 };
}
now gives
./test2.zig:3:14: error: expected type '[3]u1', found '[3]f32'
b = [3]u1{ 1.5, 10000, 10e100 };
^
Most helpful comment
now gives