diff mbox

Go patch committed: Reject nil == nil

Message ID mcrlides4e0.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Dec. 4, 2012, 6:44 a.m. UTC
This patch to the Go frontend rejects invalid comparisons in Go of nil
with nil.  These comparisons have no type and no particular meaning, and
they are not permitted.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 4d8871577da5 go/expressions.cc
--- a/go/expressions.cc	Mon Dec 03 22:22:34 2012 -0800
+++ b/go/expressions.cc	Mon Dec 03 22:38:58 2012 -0800
@@ -5610,6 +5610,11 @@ 
       || 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))
 	{