diff options
| author | gingerBill <bill@gingerbill.org> | 2019-01-13 20:51:26 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-01-13 20:51:26 +0000 |
| commit | 19e37c852e7b060d4248d657e41cf5c1e41d26a7 (patch) | |
| tree | 64a18bad6a3b34e858bee6e2cdcf3170cd5fb679 /src/ir.cpp | |
| parent | 8fc24fd6f2c13c8fb591dfb35a47053ad5d5e694 (diff) | |
Change `deferred_*` scoping behaviour for `if`
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index c6c50182b..627985857 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -8239,7 +8239,8 @@ void ir_build_stmt_internal(irProcedure *proc, Ast *node) { case_ast_node(is, IfStmt, node); ir_emit_comment(proc, str_lit("IfStmt")); - ir_open_scope(proc); // Open scope here + ir_open_scope(proc); // Scope #1 + defer (ir_close_scope(proc, irDeferExit_Default, nullptr)); if (is->init != nullptr) { // TODO(bill): Should this have a separate block to begin with? @@ -8265,7 +8266,6 @@ void ir_build_stmt_internal(irProcedure *proc, Ast *node) { } ir_build_stmt(proc, is->body); - ir_close_scope(proc, irDeferExit_Default, nullptr); ir_emit_jump(proc, done); @@ -8906,6 +8906,8 @@ void ir_end_procedure_body(irProcedure *proc) { ir_emit_unreachable(proc); } + GB_ASSERT(proc->scope_index == 0); + proc->curr_block = proc->decl_block; ir_emit_jump(proc, proc->entry_block); proc->curr_block = nullptr; |