fix: inline to propagate comptime-ness to call site

See conversation at: https://ziggit.dev/t/why-is-the-comptime-keyword-needed-in-this-inline-for-loop-condition/14090
This commit is contained in:
Robby Zambito 2026-01-27 16:42:58 -05:00 committed by Alex Rønne Petersen
parent 2d88a5a103
commit d2db1d45f1
2 changed files with 3 additions and 2 deletions

View file

@ -42,6 +42,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
/// The result array is in the same order as the input.
pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumField) []const E {
comptime {
@setEvalBranchQuota(@typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion);
var result: [fields.len]E = undefined;
for (&result, fields) |*r, f| {
r.* = @enumFromInt(f.value);
@ -53,7 +54,7 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi
/// Returns the set of all named values in the given enum, in
/// declaration order.
pub fn values(comptime E: type) []const E {
pub inline fn values(comptime E: type) []const E {
return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields);
}

View file

@ -177113,7 +177113,7 @@ fn airBr(self: *CodeGen, inst: Air.Inst.Index) !void {
}
fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
@setEvalBranchQuota(1_100);
@setEvalBranchQuota(1_100 + @typeInfo(Mir.Inst.Fixes).@"enum".fields.len);
const pt = self.pt;
const zcu = pt.zcu;
const unwrapped_asm = self.air.unwrapAsm(inst);