authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-23 15:32:25-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-23 15:32:25-07:00
logaa46a705ad998636443e744b63471bf0864e90c9
tree633cea6691c79c375a43a0f47fe966fcdf1a6d4a
parentaf73f79490aa9b998bfe1e3a6f9353742289f1bd

astgen: finishThenElseBlock: fix putting store_to_block_ptr in wrong block


1 files changed, 11 insertions(+), 6 deletions(-)

src/astgen.zig+11-6
...@@ -1732,9 +1732,10 @@ fn orelseCatchExpr(...@@ -1732,9 +1732,10 @@ fn orelseCatchExpr(
17321732
1733 return finishThenElseBlock(1733 return finishThenElseBlock(
1734 mod,1734 mod,
1735 &block_scope,1735 scope,
1736 rl,1736 rl,
1737 node,1737 node,
1738 &block_scope,
1738 &then_scope,1739 &then_scope,
1739 &else_scope,1740 &else_scope,
1740 condbr,1741 condbr,
...@@ -1750,9 +1751,10 @@ fn orelseCatchExpr(...@@ -1750,9 +1751,10 @@ fn orelseCatchExpr(
17501751
1751fn finishThenElseBlock(1752fn finishThenElseBlock(
1752 mod: *Module,1753 mod: *Module,
1753 block_scope: *Scope.GenZir,1754 parent_scope: *Scope,
1754 rl: ResultLoc,1755 rl: ResultLoc,
1755 node: ast.Node.Index,1756 node: ast.Node.Index,
1757 block_scope: *Scope.GenZir,
1756 then_scope: *Scope.GenZir,1758 then_scope: *Scope.GenZir,
1757 else_scope: *Scope.GenZir,1759 else_scope: *Scope.GenZir,
1758 condbr: zir.Inst.Index,1760 condbr: zir.Inst.Index,
...@@ -1830,7 +1832,7 @@ fn finishThenElseBlock(...@@ -1830,7 +1832,7 @@ fn finishThenElseBlock(
1830 const block_ref = wzc.ref_start_index + main_block;1832 const block_ref = wzc.ref_start_index + main_block;
1831 switch (rl) {1833 switch (rl) {
1832 .ref => return block_ref,1834 .ref => return block_ref,
1833 else => return rvalue(mod, &block_scope.base, rl, block_ref, node),1835 else => return rvalue(mod, parent_scope, rl, block_ref, node),
1834 }1836 }
1835 },1837 },
1836 }1838 }
...@@ -2066,9 +2068,10 @@ fn ifExpr(...@@ -2066,9 +2068,10 @@ fn ifExpr(
20662068
2067 return finishThenElseBlock(2069 return finishThenElseBlock(
2068 mod,2070 mod,
2069 &block_scope,2071 scope,
2070 rl,2072 rl,
2071 node,2073 node,
2074 &block_scope,
2072 &then_scope,2075 &then_scope,
2073 &else_scope,2076 &else_scope,
2074 condbr,2077 condbr,
...@@ -2277,9 +2280,10 @@ fn whileExpr(...@@ -2277,9 +2280,10 @@ fn whileExpr(
2277 }2280 }
2278 return finishThenElseBlock(2281 return finishThenElseBlock(
2279 mod,2282 mod,
2280 &loop_scope,2283 scope,
2281 rl,2284 rl,
2282 node,2285 node,
2286 &loop_scope,
2283 &then_scope,2287 &then_scope,
2284 &else_scope,2288 &else_scope,
2285 condbr,2289 condbr,
...@@ -2476,9 +2480,10 @@ fn forExpr(...@@ -2476,9 +2480,10 @@ fn forExpr(
2476 }2480 }
2477 return finishThenElseBlock(2481 return finishThenElseBlock(
2478 mod,2482 mod,
2479 &loop_scope,2483 scope,
2480 rl,2484 rl,
2481 node,2485 node,
2486 &loop_scope,
2482 &then_scope,2487 &then_scope,
2483 &else_scope,2488 &else_scope,
2484 condbr,2489 condbr,