mirror of
https://github.com/ziglang/zig.git
synced 2025-12-20 21:23:06 +00:00
fix peer result location with typed parent, ...
...runtime condition, comptime prongs. closes #3244
This commit is contained in:
parent
c6e77f248d
commit
914ad1ec2e
@ -15198,7 +15198,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe
|
|||||||
}
|
}
|
||||||
peer_parent->skipped = true;
|
peer_parent->skipped = true;
|
||||||
return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,
|
return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent,
|
||||||
value_type, value, force_runtime, true, true);
|
value_type, value, force_runtime || !is_comptime, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer_parent->resolved_type == nullptr) {
|
if (peer_parent->resolved_type == nullptr) {
|
||||||
|
|||||||
@ -721,3 +721,23 @@ test "global variable assignment with optional unwrapping with var initialized t
|
|||||||
};
|
};
|
||||||
expect(global_foo.* == 1234);
|
expect(global_foo.* == 1234);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "peer result location with typed parent, runtime condition, comptime prongs" {
|
||||||
|
const S = struct {
|
||||||
|
fn doTheTest(arg: i32) i32 {
|
||||||
|
const st = Structy{
|
||||||
|
.bleh = if (arg == 1) 1 else 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (st.bleh == 1)
|
||||||
|
return 1234;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Structy = struct {
|
||||||
|
bleh: i32,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
expect(S.doTheTest(0) == 1234);
|
||||||
|
expect(S.doTheTest(1) == 1234);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user