Zig Version
0.10.0-dev.4198+5e0d8a435
Steps to Reproduce
Run zig test on the following code (heavily reduced to minimize surface area):
const std = @import("std");
const swap = std.mem.swap;
pub fn stablePartition(comptime T: type, slice: []T, predicate: fn(T) bool) i8 {
if (slice.len == 0)
return 0;
_ = stablePartition(T, slice[1..], predicate);
return 1;
}
test "stablePartition" {
var items = [_]i8{0,1,2,3,4,5,6};
_=stablePartition(i8, &items, isOdd);
}
fn isOdd(val: i8) bool {
return val & 1 == 1;
}
By default this produces the following error:
min.zig:7:24: error: evaluation exceeded 1000 backwards branches
_ = stablePartition(T, slice[1..], predicate);
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
min.zig:7:24: note: use @setEvalBranchQuota() to raise the branch limit from 1000
min.zig:7:24: note: called from here (999 times)
min.zig:14:22: note: called from here
_=stablePartition(i8, &items, isOdd);
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
Using @setEvalBranchQuota(5000) as suggested causes the compiler to crash on my machine. Note that this is during compilation, not runtime.
Expected Behavior
Running zig test -fstage1 min.zig compiles and runs successfully with all tests passing.
Actual Behavior
Backwards branches error or segfault if the branch quota is increased. There appears to be some kind of infinite recursion, perhaps in type inference/resolution.
Zig Version
0.10.0-dev.4198+5e0d8a435
Steps to Reproduce
Run
zig teston the following code (heavily reduced to minimize surface area):By default this produces the following error:
Using
@setEvalBranchQuota(5000)as suggested causes the compiler to crash on my machine. Note that this is during compilation, not runtime.Expected Behavior
Running
zig test -fstage1 min.zigcompiles and runs successfully with all tests passing.Actual Behavior
Backwards branches error or segfault if the branch quota is increased. There appears to be some kind of infinite recursion, perhaps in type inference/resolution.