| ... | @@ -17597,6 +17597,7 @@ fn zirIsNonNullPtr( | ... | @@ -17597,6 +17597,7 @@ fn zirIsNonNullPtr( |
| 17597 | const nullable_ty = ptr_ty.childType(zcu); | 17597 | const nullable_ty = ptr_ty.childType(zcu); |
| 17598 | | 17598 | |
| 17599 | try sema.checkNullableType(block, src, nullable_ty); | 17599 | try sema.checkNullableType(block, src, nullable_ty); |
| | 17600 | try sema.ensureLayoutResolved(nullable_ty, src, .ptr_access); |
| 17600 | | 17601 | |
| 17601 | if (try sema.resolveIsNullFromType(block, src, nullable_ty)) |is_null| { | 17602 | if (try sema.resolveIsNullFromType(block, src, nullable_ty)) |is_null| { |
| 17602 | return .fromValue(.makeBool(!is_null)); | 17603 | return .fromValue(.makeBool(!is_null)); |
| ... | @@ -31249,6 +31250,11 @@ fn resolveIsNonErrVal( | ... | @@ -31249,6 +31250,11 @@ fn resolveIsNonErrVal( |
| 31249 | return null; | 31250 | return null; |
| 31250 | } | 31251 | } |
| 31251 | | 31252 | |
| | 31253 | /// If `null` is the only possible value of type `ty`, returns `true`. |
| | 31254 | /// If `null` is *not* a possible value of `ty`, returns `false`. |
| | 31255 | /// Otherwise, if a value of type `ty` may or may not be `null`, returns `null`. |
| | 31256 | /// |
| | 31257 | /// Asserts that the layout of `ty` is resolved. |
| 31252 | fn resolveIsNullFromType( | 31258 | fn resolveIsNullFromType( |
| 31253 | sema: *Sema, | 31259 | sema: *Sema, |
| 31254 | block: *Block, | 31260 | block: *Block, |
| ... | @@ -31256,6 +31262,8 @@ fn resolveIsNullFromType( | ... | @@ -31256,6 +31262,8 @@ fn resolveIsNullFromType( |
| 31256 | ty: Type, | 31262 | ty: Type, |
| 31257 | ) CompileError!?bool { | 31263 | ) CompileError!?bool { |
| 31258 | const zcu = sema.pt.zcu; | 31264 | const zcu = sema.pt.zcu; |
| | 31265 | ty.assertHasLayout(zcu); |
| | 31266 | |
| 31259 | return switch (ty.zigTypeTag(zcu)) { | 31267 | return switch (ty.zigTypeTag(zcu)) { |
| 31260 | else => false, | 31268 | else => false, |
| 31261 | .null => true, | 31269 | .null => true, |