diff options
| author | David Rubin <87927264+Rexicon226@users.noreply.github.com> | 2024-01-19 11:25:05 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-19 21:25:05 +0200 |
| commit | 100efcf8d3e7fb7562d51b011dfaf639bf93c9ba (patch) | |
| tree | 08eaaf37a83154cb0624ca82f70784a0f79feeb8 /src | |
| parent | b80cad24840700ead20b59734916bf3d4d4ba87c (diff) | |
| download | zig-100efcf8d3e7fb7562d51b011dfaf639bf93c9ba.tar.gz zig-100efcf8d3e7fb7562d51b011dfaf639bf93c9ba.zip | |
return optional state to `zirPtrCastNoDest`
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index dfb71e08b1..d86a8ef2f0 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -22741,7 +22741,14 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst var ptr_info = operand_ty.ptrInfo(mod); if (flags.const_cast) ptr_info.flags.is_const = false; if (flags.volatile_cast) ptr_info.flags.is_volatile = false; - const dest_ty = try sema.ptrType(ptr_info); + + const dest_ty = blk: { + const dest_ty = try sema.ptrType(ptr_info); + if (operand_ty.zigTypeTag(mod) == .Optional) { + break :blk try mod.optionalType(dest_ty.toIntern()); + } + break :blk dest_ty; + }; if (try sema.resolveValue(operand)) |operand_val| { return Air.internedToRef((try mod.getCoerced(operand_val, dest_ty)).toIntern()); |
