authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-17 22:30:49-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-17 22:30:49-04:00
log914ad1ec2eff4ea9061804ad0da9cde7dd6543b6
tree387ccac6981a2c0ab0ce4698ed3363cc4f49c082
parentc6e77f248d3771070162d80341f9aeef89a49924
signaturelock-open Commit is signed but in an unrecognized format.

fix peer result location with typed parent, ...

...runtime condition, comptime prongs. closes #3244

2 files changed, 21 insertions(+), 1 deletions(-)

src/ir.cpp+1-1
...@@ -15198,7 +15198,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe...@@ -15198,7 +15198,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
15198 }15198 }
15199 peer_parent->skipped = true;15199 peer_parent->skipped = true;
15200 return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,15200 return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,
15201 value_type, value, force_runtime, true, true);15201 value_type, value, force_runtime || !is_comptime, true, true);
15202 }15202 }
1520315203
15204 if (peer_parent->resolved_type == nullptr) {15204 if (peer_parent->resolved_type == nullptr) {
test/stage1/behavior/misc.zig+20
...@@ -721,3 +721,23 @@ test "global variable assignment with optional unwrapping with var initialized t...@@ -721,3 +721,23 @@ test "global variable assignment with optional unwrapping with var initialized t
721 };721 };
722 expect(global_foo.* == 1234);722 expect(global_foo.* == 1234);
723}723}
724
725test "peer result location with typed parent, runtime condition, comptime prongs" {
726 const S = struct {
727 fn doTheTest(arg: i32) i32 {
728 const st = Structy{
729 .bleh = if (arg == 1) 1 else 1,
730 };
731
732 if (st.bleh == 1)
733 return 1234;
734 return 0;
735 }
736
737 const Structy = struct {
738 bleh: i32,
739 };
740 };
741 expect(S.doTheTest(0) == 1234);
742 expect(S.doTheTest(1) == 1234);
743}