I have this code
const std = @import("std");
const numbers = [_]u8{ 1, 2, 3, 4};
fn sum_list(comptime list: []const u8) u32 {
var sum: u32 = 0;
for (list) |num| {
sum += num;
}
return sum;
}
pub fn main() anyerror!void {
const sum = sum_list(&numbers);
std.debug.print("summed = {d}\n", .{sum});
}
``` and I want it to figure out that sum is 10 at comptime
but for some reason it's still calling a function in the binary
example.main:
push rbp
mov rbp, rsp
sub rsp, 16
call example.sum_list__anon_3411
mov dword ptr [rbp - 8], eax
lea rdi, [rbp - 8]
call debug.print__anon_3413
xor eax, eax
add rsp, 16
pop rbp
ret
can see this at <https://godbolt.org/z/WTY1Tz96b>