Commit cbfe9a4077

Andrew Kelley <superjoe30@gmail.com>
2018-07-18 05:37:17
fix @setEvalBranchQuota not respected in generic fn calls
closes #1257
1 parent 6394f7e
Changed files (2)
src
test
cases
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);
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) {}
+}