aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShawn Landden <shawn@git.icu>2019-03-28 08:47:47 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-03-28 15:54:44 -0400
commit66f13ba80787b652ee4f26669f4f2af99e1f1ea0 (patch)
tree8733b7d4ac0a4dc4dc04081b3f26c3b9c141beed /src
parent85d188537538cdb7929ac05d7960d6b724676d7f (diff)
downloadzig-66f13ba80787b652ee4f26669f4f2af99e1f1ea0.tar.gz
zig-66f13ba80787b652ee4f26669f4f2af99e1f1ea0.zip
stage1: better error message when comparing against null
Closes: #2104
Diffstat (limited to 'src')
-rw-r--r--src/ir.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 3851103c1e..0833bb580c 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -12210,7 +12210,8 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *
return is_non_null;
}
} 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"));
+ ir_add_error_node(ira, source_node, buf_sprintf("only optionals (not '%s') can compare to null",
+ buf_ptr(&(op1->value.type->id == ZigTypeIdNull ? op2->value.type->name : op1->value.type->name))));
return ira->codegen->invalid_instruction;
}