Skip to content

Commit

Permalink
fix @setEvalBranchQuota not respected in generic fn calls
Browse files Browse the repository at this point in the history
closes #1257
  • Loading branch information
andrewrk committed Jul 18, 2018
1 parent 6394f7e commit cbfe9a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ir.cpp
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions test/cases/eval.zig
Expand Up @@ -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) {}
}

0 comments on commit cbfe9a4

Please sign in to comment.