| author | |
| committer | |
| log | 775e055b59366f60badfb77a420219691846314b |
| tree | f9a32fdd42363ecc14e787242efbf5e996262727 |
| parent | 94039d66ed4fecb7defc5deeeedd7afa3b773f0c |
Closes #126242 files changed, 32 insertions(+), 0 deletions(-)
src/Sema.zig+2| ... | @@ -6713,6 +6713,8 @@ fn instantiateGenericCall( | ... | @@ -6713,6 +6713,8 @@ fn instantiateGenericCall( |
| 6713 | .comptime_args_fn_inst = module_fn.zir_body_inst, | 6713 | .comptime_args_fn_inst = module_fn.zir_body_inst, |
| 6714 | .preallocated_new_func = new_module_func, | 6714 | .preallocated_new_func = new_module_func, |
| 6715 | .is_generic_instantiation = true, | 6715 | .is_generic_instantiation = true, |
| 6716 | .branch_quota = sema.branch_quota, | ||
| 6717 | .branch_count = sema.branch_count, | ||
| 6716 | }; | 6718 | }; |
| 6717 | defer child_sema.deinit(); | 6719 | defer child_sema.deinit(); |
| 6718 | 6720 |
test/cases/compile_errors/generic_funciton_instantiation_inherits_parent_branch_quota.zig created+30| ... | @@ -0,0 +1,30 @@ | ||
| 1 | pub export fn entry1() void { | ||
| 2 | @setEvalBranchQuota(1001); | ||
| 3 | // Return type evaluation should inherit both the | ||
| 4 | // parent's branch quota and count meaning | ||
| 5 | // at least 2002 backwards branches are required. | ||
| 6 | comptime var i = 0; | ||
| 7 | inline while (i < 1000) : (i += 1) {} | ||
| 8 | _ = simple(10); | ||
| 9 | } | ||
| 10 | pub export fn entry2() void { | ||
| 11 | @setEvalBranchQuota(2001); | ||
| 12 | comptime var i = 0; | ||
| 13 | inline while (i < 1000) : (i += 1) {} | ||
| 14 | _ = simple(10); | ||
| 15 | } | ||
| 16 | fn simple(comptime n: usize) Type(n) { | ||
| 17 | return n; | ||
| 18 | } | ||
| 19 | fn Type(comptime n: usize) type { | ||
| 20 | if (n <= 1) return usize; | ||
| 21 | return Type(n - 1); | ||
| 22 | } | ||
| 23 | |||
| 24 | // error | ||
| 25 | // backend=stage2 | ||
| 26 | // target=native | ||
| 27 | // | ||
| 28 | // :21:16: error: evaluation exceeded 1001 backwards branches | ||
| 29 | // :21:16: note: use @setEvalBranchQuota() to raise the branch limit from 1001 | ||
| 30 | // :16:34: note: called from here | ||