| ... | ... | @@ -17597,6 +17597,7 @@ fn zirIsNonNullPtr( |
| 17597 | 17597 | const nullable_ty = ptr_ty.childType(zcu); |
| 17598 | 17598 | |
| 17599 | 17599 | try sema.checkNullableType(block, src, nullable_ty); |
| 17600 | try sema.ensureLayoutResolved(nullable_ty, src, .ptr_access); |
| 17600 | 17601 | |
| 17601 | 17602 | if (try sema.resolveIsNullFromType(block, src, nullable_ty)) |is_null| { |
| 17602 | 17603 | return .fromValue(.makeBool(!is_null)); |
| ... | ... | @@ -31249,6 +31250,11 @@ fn resolveIsNonErrVal( |
| 31249 | 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 | 31258 | fn resolveIsNullFromType( |
| 31253 | 31259 | sema: *Sema, |
| 31254 | 31260 | block: *Block, |
| ... | ... | @@ -31256,6 +31262,8 @@ fn resolveIsNullFromType( |
| 31256 | 31262 | ty: Type, |
| 31257 | 31263 | ) CompileError!?bool { |
| 31258 | 31264 | const zcu = sema.pt.zcu; |
| 31265 | ty.assertHasLayout(zcu); |
| 31266 | |
| 31259 | 31267 | return switch (ty.zigTypeTag(zcu)) { |
| 31260 | 31268 | else => false, |
| 31261 | 31269 | .null => true, |