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; diff --git a/test/cases/recursive_inline_function.1.zig b/test/cases/recursive_inline_function.1.zig index 8ed9bde8e8..0b7dd56d38 100644 --- a/test/cases/recursive_inline_function.1.zig +++ b/test/cases/recursive_inline_function.1.zig @@ -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