| author | |
| committer | |
| log | 78a9a465a372d25ef6f9a1f6bb1018160b8c94e1 |
| tree | 3087d77f8411acc3227f3e0b04c1b3be6c8457b6 |
| parent | 6c71e9a54da068202794c309e895b3f9ccfeb161 |
| signature |
closes #15392 files changed, 13 insertions(+), 0 deletions(-)
src/ir.cpp+3| ... | ... | @@ -11571,6 +11571,9 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op |
| 11571 | 11571 | ir_link_new_instruction(is_non_null, &bin_op_instruction->base); |
| 11572 | 11572 | } |
| 11573 | 11573 | return ira->codegen->builtin_types.entry_bool; |
| 11574 | } else if (op1->value.type->id == ZigTypeIdNull || op2->value.type->id == ZigTypeIdNull) { | |
| 11575 | ir_add_error_node(ira, source_node, buf_sprintf("comparison against null can only be done with optionals")); | |
| 11576 | return ira->codegen->builtin_types.entry_invalid; | |
| 11574 | 11577 | } |
| 11575 | 11578 | |
| 11576 | 11579 | if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) { |
test/compile_errors.zig+10| ... | ... | @@ -1,6 +1,16 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.add( | |
| 5 | "comparing a non-optional pointer against null", | |
| 6 | \\export fn entry() void { | |
| 7 | \\ var x: i32 = 1; | |
| 8 | \\ _ = &x == null; | |
| 9 | \\} | |
| 10 | , | |
| 11 | ".tmp_source.zig:3:12: error: comparison against null can only be done with optionals", | |
| 12 | ); | |
| 13 | ||
| 4 | 14 | cases.add( |
| 5 | 15 | "non error sets used in merge error sets operator", |
| 6 | 16 | \\export fn foo() void { |