aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVÖRÖSKŐI András <voroskoi@gmail.com>2022-07-07 19:05:56 +0200
committerVeikka Tuominen <git@vexu.eu>2022-07-08 02:13:33 +0300
commit75c33ba85e47eec9f7257cfb972a54b22a5283eb (patch)
tree521fbfb604ee9ba9e258cfaa182f755962069099 /src
parent0c78ece1c95164f4a321f5705b20896415336d02 (diff)
downloadzig-75c33ba85e47eec9f7257cfb972a54b22a5283eb.tar.gz
zig-75c33ba85e47eec9f7257cfb972a54b22a5283eb.zip
Sema: add a note about @setEvalBranchQuota() when branch quota is exceeded
closes #11996
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig15
-rw-r--r--src/stage1/ir.cpp4
2 files changed, 17 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 054f645230..0f504c6c1d 100644
--- a/src/Sema.zig
+++ b/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);
}
}
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp
index 52044e9dce..c26a65aac2 100644
--- a/src/stage1/ir.cpp
+++ b/src/stage1/ir.cpp
@@ -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;