From c213d72ec6a64e973017bf326e0f241a3eef8adb Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 5 Mar 2020 20:58:59 +0000 Subject: [PATCH] Fix #580 defer bug --- src/ir.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 1258f0308..da0075ec8 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3103,10 +3103,6 @@ irValue *ir_find_or_generate_context_ptr(irProcedure *proc) { return proc->context_stack[proc->context_stack.count-1].value; } - // irBlock *tmp_block = proc->curr_block; - // proc->curr_block = proc->blocks[0]; - // defer (proc->curr_block = tmp_block); - irValue *c = ir_add_local_generated(proc, t_context, true); ir_push_context_onto_stack(proc, c); ir_emit_store(proc, c, ir_emit_load(proc, proc->module->global_default_context)); @@ -3300,9 +3296,11 @@ void ir_emit_defer_stmts(irProcedure *proc, irDeferExitKind kind, irBlock *block isize i = count; while (i --> 0) { irDefer d = proc->defer_stmts[i]; - if (proc->context_stack.count >= d.context_stack_count) { - proc->context_stack.count = d.context_stack_count; - } + + // TODO(bill, 2020-03-05): Why was this added? + // if (proc->context_stack.count >= d.context_stack_count) { + // proc->context_stack.count = d.context_stack_count; + // } if (kind == irDeferExit_Default) { if (proc->scope_index == d.scope_index &&