@setEvalBranchQuota

@setEvalBranchQuota

@setEvalBranchQuota(new_quota: usize)

Changes the maximum number of backwards branches that compile-time code execution can use before giving up and making a compile error.

If the new_quota is smaller than the default quota (1000) or a previously explicitly set quota, it is ignored.

Example:

test.zig

test "foo" {
    comptime {
        var i = 0;
        while (i < 1001) : (i += 1) {}
    }
}
``` ```
$ zig test test.zig
/home/andy/dev/zig/docgen_tmp/test.zig:4:9: error: evaluation exceeded 1000 backwards branches
        while (i < 1001) : (i += 1) {}
        ^

Now we use @setEvalBranchQuota:

test.zig

test "foo" {
    comptime {
        @setEvalBranchQuota(1001);
        var i = 0;
        while (i < 1001) : (i += 1) {}
    }
}
``` ```
$ zig test test.zig
1/1 test "foo"...OK
All tests passed.

See also:

  • comptime