zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3b2c4211027c235e3bc38043be99fc5be5e870e1 (tree)
parent e04547642ac2d0c1cba010b6101bb30c210735cb
Author: Veikka Tuominen <git@vexu.eu>
Date:   Tue, 17 Jan 2023 19:31:00 +0200

Sema: fix bad boolean logic for cast to null panic

Closes #14349

Diffstat:
Msrc/Sema.zig | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -27330,7 +27330,7 @@ fn coerceCompatiblePtrs( return sema.addConstant(dest_ty, val); } try sema.requireRuntimeBlock(block, inst_src, null); - const inst_allows_zero = (inst_ty.zigTypeTag() == .Pointer and inst_ty.ptrAllowsZero()) or true; + const inst_allows_zero = inst_ty.zigTypeTag() != .Pointer or inst_ty.ptrAllowsZero(); if (block.wantSafety() and inst_allows_zero and !dest_ty.ptrAllowsZero() and try sema.typeHasRuntimeBits(dest_ty.elemType2())) {