authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-22 14:12:59+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-22 17:03:42+03:00
log47de73980e9dbbf85fee754b579273a9b7b57c53
tree51ca1803556da6703b102de5b06c1e7eee9dbbd2
parent8e75ba653b03477229cf72211e8a8bfe7b071254

Sema: use `resolveMaybeUndefValIntable` in `zirIntToPtr`


1 files changed, 8 insertions(+), 4 deletions(-)

src/Sema.zig+8-4
......@@ -1663,11 +1663,15 @@ fn resolveMaybeUndefValIntable(
16631663 inst: Air.Inst.Ref,
16641664) CompileError!?Value {
16651665 const val = (try sema.resolveMaybeUndefValAllowVariables(block, src, inst)) orelse return null;
1666 switch (val.tag()) {
1667 .variable, .decl_ref, .decl_ref_mut => return null,
1666 var check = val;
1667 while (true) switch (check.tag()) {
1668 .variable, .decl_ref, .decl_ref_mut, .comptime_field_ptr => return null,
1669 .field_ptr => check = check.castTag(.field_ptr).?.data.container_ptr,
1670 .elem_ptr => check = check.castTag(.elem_ptr).?.data.array_ptr,
1671 .eu_payload_ptr, .opt_payload_ptr => check = check.cast(Value.Payload.PayloadPtr).?.data.container_ptr,
16681672 .generic_poison => return error.GenericPoison,
16691673 else => return val,
1670 }
1674 };
16711675}
16721676
16731677/// Returns all Value tags including `variable` and `undef`.
......@@ -7893,7 +7897,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
78937897 if (!ptr_ty.isPtrAtRuntime()) {
78947898 return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(sema.mod)});
78957899 }
7896 if (try sema.resolveMaybeUndefVal(block, ptr_src, ptr)) |ptr_val| {
7900 if (try sema.resolveMaybeUndefValIntable(block, ptr_src, ptr)) |ptr_val| {
78977901 return sema.addConstant(Type.usize, ptr_val);
78987902 }
78997903 try sema.requireRuntimeBlock(block, ptr_src, ptr_src);