aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-02-08 14:59:33 -0500
committerAndrew Kelley <andrew@ziglang.org>2020-02-08 14:59:33 -0500
commit80ba21b83cd13849c1d1d9cdebfa070b03f334d3 (patch)
treec4138d82ba6485317fb025886c33bc7cb5bc5605 /src/ir.cpp
parent884804dbc3a066fde06da769994554efe09febd6 (diff)
downloadzig-80ba21b83cd13849c1d1d9cdebfa070b03f334d3.tar.gz
zig-80ba21b83cd13849c1d1d9cdebfa070b03f334d3.zip
properly spill optional payload capture value
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index ef3426d111..dc24fcef0c 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -8874,7 +8874,9 @@ static IrInstSrc *ir_gen_if_optional_expr(IrBuilderSrc *irb, Scope *scope, AstNo
AstNode *else_node = node->data.test_expr.else_node;
bool var_is_ptr = node->data.test_expr.var_is_ptr;
- IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr);
+ ScopeExpr *spill_scope = create_expr_scope(irb->codegen, expr_node, scope);
+
+ IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, expr_node, &spill_scope->base, LValPtr, nullptr);
if (maybe_val_ptr == irb->codegen->invalid_inst_src)
return maybe_val_ptr;
@@ -8899,7 +8901,7 @@ static IrInstSrc *ir_gen_if_optional_expr(IrBuilderSrc *irb, Scope *scope, AstNo
ir_set_cursor_at_end_and_append_block(irb, then_block);
- Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime);
+ Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, &spill_scope->base, is_comptime);
Scope *var_scope;
if (var_symbol) {
bool is_shadowable = false;