diff mbox

Go patch committed: better error setting const to nil

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

Commit Message

Ian Lance Taylor March 26, 2011, 5:45 a.m. UTC
This patch to the Go frontend gives a better error message when setting
a const to nil.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r d04de877d993 go/gogo.cc
--- a/go/gogo.cc	Fri Mar 25 22:31:14 2011 -0700
+++ b/go/gogo.cc	Fri Mar 25 22:41:02 2011 -0700
@@ -1527,7 +1527,9 @@ 
       && !ctype->is_boolean_type()
       && !ctype->is_string_type())
     {
-      if (!ctype->is_error())
+      if (ctype->is_nil_type())
+	error_at(constant->location(), "const initializer cannot be nil");
+      else if (!ctype->is_error())
 	error_at(constant->location(), "invalid constant type");
       constant->set_error();
     }