compiler: Reject invalid nil == nil comparisons.

From-SVN: r194119
This commit is contained in:
Ian Lance Taylor 2012-12-04 06:44:19 +00:00
parent 98fd70c20f
commit 3fa057a437

View File

@ -5610,6 +5610,11 @@ Binary_expression::do_check_types(Gogo*)
|| this->op_ == OPERATOR_GT
|| this->op_ == OPERATOR_GE)
{
if (left_type->is_nil_type() && right_type->is_nil_type())
{
this->report_error(_("invalid comparison of nil with nil"));
return;
}
if (!Type::are_assignable(left_type, right_type, NULL)
&& !Type::are_assignable(right_type, left_type, NULL))
{