diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 18:58:50 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 18:58:50 -0400 |
| commit | 78a9a465a372d25ef6f9a1f6bb1018160b8c94e1 (patch) | |
| tree | 3087d77f8411acc3227f3e0b04c1b3be6c8457b6 /src/ir.cpp | |
| parent | 6c71e9a54da068202794c309e895b3f9ccfeb161 (diff) | |
| download | zig-78a9a465a372d25ef6f9a1f6bb1018160b8c94e1.tar.gz zig-78a9a465a372d25ef6f9a1f6bb1018160b8c94e1.zip | |
add compile error for non-optional types compared against null
closes #1539
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index e2bcbcffee..d073f3296c 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11571,6 +11571,9 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op ir_link_new_instruction(is_non_null, &bin_op_instruction->base); } return ira->codegen->builtin_types.entry_bool; + } else if (op1->value.type->id == ZigTypeIdNull || op2->value.type->id == ZigTypeIdNull) { + ir_add_error_node(ira, source_node, buf_sprintf("comparison against null can only be done with optionals")); + return ira->codegen->builtin_types.entry_invalid; } if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) { |
