Why does this program fail to compile? Zig version 0.6.0.
const std = @import("std");
fn get_value () f32 {
return 1.0;
}
test "testcase" {
const value: f32 = 1. + get_value() ;
_ = std.math.clamp(value, 0.0, 255.0);
}
Gives compile error:
$ zig test src/clamp.zig
Semantic Analysis [790/1017] ./src/clamp.zig:9:24: error: unable to evaluate constant expression
_ = std.math.clamp(value, 0.0, 255.0);
^
./src/clamp.zig:9:23: note: referenced here
_ = std.math.clamp(value, 0.0, 255.0);
^