From cbfe9a407776d3b56a4da2a3bc3108a2f31b9212 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 17 Jul 2018 23:37:17 -0400 Subject: [PATCH] fix @setEvalBranchQuota not respected in generic fn calls closes #1257 --- src/ir.cpp | 1 + test/cases/eval.zig | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/ir.cpp b/src/ir.cpp index a12bd054a7..96ade9d392 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -13092,6 +13092,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal impl_fn->ir_executable.parent_exec = ira->new_irb.exec; impl_fn->analyzed_executable.source_node = call_instruction->base.source_node; impl_fn->analyzed_executable.parent_exec = ira->new_irb.exec; + impl_fn->analyzed_executable.backward_branch_quota = ira->new_irb.exec->backward_branch_quota; impl_fn->analyzed_executable.is_generic_instantiation = true; ira->codegen->fn_defs.append(impl_fn); diff --git a/test/cases/eval.zig b/test/cases/eval.zig index 83d2e80176..9da475994d 100644 --- a/test/cases/eval.zig +++ b/test/cases/eval.zig @@ -642,3 +642,13 @@ test "@tagName of @typeId" { const str = @tagName(@typeId(u8)); assert(std.mem.eql(u8, str, "Int")); } + +test "setting backward branch quota just before a generic fn call" { + @setEvalBranchQuota(1001); + loopNTimes(1001); +} + +fn loopNTimes(comptime n: usize) void { + comptime var i = 0; + inline while (i < n) : (i += 1) {} +}