mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Sema: add a note about @setEvalBranchQuota() when branch quota is exceeded
closes #11996
This commit is contained in:
parent
0c78ece1c9
commit
75c33ba85e
15
src/Sema.zig
15
src/Sema.zig
@ -18427,7 +18427,20 @@ fn safetyPanic(
|
||||
fn emitBackwardBranch(sema: *Sema, block: *Block, src: LazySrcLoc) !void {
|
||||
sema.branch_count += 1;
|
||||
if (sema.branch_count > sema.branch_quota) {
|
||||
return sema.fail(block, src, "evaluation exceeded {d} backwards branches", .{sema.branch_quota});
|
||||
const msg = try sema.errMsg(
|
||||
block,
|
||||
src,
|
||||
"evaluation exceeded {d} backwards branches",
|
||||
.{sema.branch_quota},
|
||||
);
|
||||
try sema.errNote(
|
||||
block,
|
||||
src,
|
||||
msg,
|
||||
"use @setEvalBranchQuota() to raise the branch limit from {d}",
|
||||
.{sema.branch_quota},
|
||||
);
|
||||
return sema.failWithOwnedErrorMsg(block, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5769,8 +5769,10 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, AstNode* source_node) {
|
||||
|
||||
*bbc += 1;
|
||||
if (*bbc > *quota) {
|
||||
ir_add_error_node(ira, source_node,
|
||||
ErrorMsg *msg = ir_add_error_node(ira, source_node,
|
||||
buf_sprintf("evaluation exceeded %" ZIG_PRI_usize " backwards branches", *quota));
|
||||
add_error_note(ira->codegen, msg, source_node,
|
||||
buf_sprintf("use @setEvalBranchQuota to raise branch limit from %" ZIG_PRI_usize, *quota));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -14,6 +14,7 @@ inline fn fibonacci(n: usize) usize {
|
||||
// error
|
||||
//
|
||||
// :11:21: error: evaluation exceeded 1000 backwards branches
|
||||
// :11:21: note: use @setEvalBranchQuota() to raise the branch limit from 1000
|
||||
// :11:40: note: called from here (6 times)
|
||||
// :11:21: note: called from here (495 times)
|
||||
// :5:24: note: called from here
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user