diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-05 15:31:34 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-06 20:09:45 +0300 |
| commit | 775e055b59366f60badfb77a420219691846314b (patch) | |
| tree | f9a32fdd42363ecc14e787242efbf5e996262727 /test/cases/compile_errors | |
| parent | 94039d66ed4fecb7defc5deeeedd7afa3b773f0c (diff) | |
| download | zig-775e055b59366f60badfb77a420219691846314b.tar.gz zig-775e055b59366f60badfb77a420219691846314b.zip | |
Sema: generic function instantiation inherits parent's branch quota
Closes #12624
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/generic_funciton_instantiation_inherits_parent_branch_quota.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/cases/compile_errors/generic_funciton_instantiation_inherits_parent_branch_quota.zig b/test/cases/compile_errors/generic_funciton_instantiation_inherits_parent_branch_quota.zig new file mode 100644 index 0000000000..1d45ce86db --- /dev/null +++ b/test/cases/compile_errors/generic_funciton_instantiation_inherits_parent_branch_quota.zig @@ -0,0 +1,30 @@ +pub export fn entry1() void { + @setEvalBranchQuota(1001); + // Return type evaluation should inherit both the + // parent's branch quota and count meaning + // at least 2002 backwards branches are required. + comptime var i = 0; + inline while (i < 1000) : (i += 1) {} + _ = simple(10); +} +pub export fn entry2() void { + @setEvalBranchQuota(2001); + comptime var i = 0; + inline while (i < 1000) : (i += 1) {} + _ = simple(10); +} +fn simple(comptime n: usize) Type(n) { + return n; +} +fn Type(comptime n: usize) type { + if (n <= 1) return usize; + return Type(n - 1); +} + +// error +// backend=stage2 +// target=native +// +// :21:16: error: evaluation exceeded 1001 backwards branches +// :21:16: note: use @setEvalBranchQuota() to raise the branch limit from 1001 +// :16:34: note: called from here |
