diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-05 14:55:36 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-06 15:39:06 +0300 |
| commit | cc89908e826882065eeaa23bb8827fb7d7cd6219 (patch) | |
| tree | db08db6e065b427aaaa5e22069ea2fc8a545d425 /src | |
| parent | 0b1dd845d9ac15ade5748dcb6ffa6b868fdfe0c0 (diff) | |
| download | zig-cc89908e826882065eeaa23bb8827fb7d7cd6219.tar.gz zig-cc89908e826882065eeaa23bb8827fb7d7cd6219.zip | |
Sema: do not emit `is(_non)_null` for invalid types
Closes #13024
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 3ccad330ee..7b9f7da769 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -26897,10 +26897,14 @@ fn analyzeIsNull( } } + const inverted_non_null_res = if (invert_logic) Air.Inst.Ref.bool_true else Air.Inst.Ref.bool_false; const operand_ty = sema.typeOf(operand); var buf: Type.Payload.ElemType = undefined; if (operand_ty.zigTypeTag() == .Optional and operand_ty.optionalChild(&buf).zigTypeTag() == .NoReturn) { - return Air.Inst.Ref.bool_true; + return inverted_non_null_res; + } + if (operand_ty.zigTypeTag() != .Optional and !operand_ty.isPtrLikeOptional()) { + return inverted_non_null_res; } try sema.requireRuntimeBlock(block, src, null); const air_tag: Air.Inst.Tag = if (invert_logic) .is_non_null else .is_null; |
