I’m trying to understand whether passing null as a value to an optional argument of a function is considered comptime by the compiler, and if it can optimize away paths that follow in case of null. Here’s a trivial example:
https://godbolt.org/z/51zqf6Tso
I barely know assembly but I noticed that the loop in the example disappeared.
fn incUntil100(num: usize, until: ?usize) usize {
var n = num;
while (if (until) |u| num != u else true) {
n += 1;
if (n == 100) return n;
break;
}
return n;
}
export fn testWithNull(num: usize) usize {
return incUntil100(num, null);
}
export fn testWithoutNull(num: usize) usize {
return incUntil...