| author | |
| committer | |
| log | 75c33ba85e47eec9f7257cfb972a54b22a5283eb |
| tree | 521fbfb604ee9ba9e258cfaa182f755962069099 |
| parent | 0c78ece1c95164f4a321f5705b20896415336d02 |
closes #119963 files changed, 18 insertions(+), 2 deletions(-)
src/Sema.zig+14-1| ... | ... | @@ -18427,7 +18427,20 @@ fn safetyPanic( |
| 18427 | 18427 | fn emitBackwardBranch(sema: *Sema, block: *Block, src: LazySrcLoc) !void { |
| 18428 | 18428 | sema.branch_count += 1; |
| 18429 | 18429 | if (sema.branch_count > sema.branch_quota) { |
| 18430 | return sema.fail(block, src, "evaluation exceeded {d} backwards branches", .{sema.branch_quota}); | |
| 18430 | const msg = try sema.errMsg( | |
| 18431 | block, | |
| 18432 | src, | |
| 18433 | "evaluation exceeded {d} backwards branches", | |
| 18434 | .{sema.branch_quota}, | |
| 18435 | ); | |
| 18436 | try sema.errNote( | |
| 18437 | block, | |
| 18438 | src, | |
| 18439 | msg, | |
| 18440 | "use @setEvalBranchQuota() to raise the branch limit from {d}", | |
| 18441 | .{sema.branch_quota}, | |
| 18442 | ); | |
| 18443 | return sema.failWithOwnedErrorMsg(block, msg); | |
| 18431 | 18444 | } |
| 18432 | 18445 | } |
| 18433 | 18446 |
src/stage1/ir.cpp+3-1| ... | ... | @@ -5769,8 +5769,10 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, AstNode* source_node) { |
| 5769 | 5769 | |
| 5770 | 5770 | *bbc += 1; |
| 5771 | 5771 | if (*bbc > *quota) { |
| 5772 | ir_add_error_node(ira, source_node, | |
| 5772 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | |
| 5773 | 5773 | buf_sprintf("evaluation exceeded %" ZIG_PRI_usize " backwards branches", *quota)); |
| 5774 | add_error_note(ira->codegen, msg, source_node, | |
| 5775 | buf_sprintf("use @setEvalBranchQuota to raise branch limit from %" ZIG_PRI_usize, *quota)); | |
| 5774 | 5776 | return false; |
| 5775 | 5777 | } |
| 5776 | 5778 | return true; |
test/cases/recursive_inline_function.1.zig+1| ... | ... | @@ -14,6 +14,7 @@ inline fn fibonacci(n: usize) usize { |
| 14 | 14 | // error |
| 15 | 15 | // |
| 16 | 16 | // :11:21: error: evaluation exceeded 1000 backwards branches |
| 17 | // :11:21: note: use @setEvalBranchQuota() to raise the branch limit from 1000 | |
| 17 | 18 | // :11:40: note: called from here (6 times) |
| 18 | 19 | // :11:21: note: called from here (495 times) |
| 19 | 20 | // :5:24: note: called from here |