diff mbox

Go patch committed: Better error message

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

Commit Message

Ian Lance Taylor Sept. 21, 2012, 9:08 p.m. UTC
This patch to the Go compiler gives a better error message if a method
that requires a pointer receiver is invoked with a non-pointer value.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline and 4.7 branch.

Ian
diff mbox

Patch

diff -r cb56a10e8798 go/types.cc
--- a/go/types.cc	Fri Sep 21 10:44:22 2012 -0700
+++ b/go/types.cc	Fri Sep 21 14:00:15 2012 -0700
@@ -6845,7 +6845,8 @@ 
 	      std::string n = Gogo::message_name(p->name());
 	      size_t len = 100 + n.length();
 	      char* buf = new char[len];
-	      snprintf(buf, len, _("method %s%s%s requires a pointer"),
+	      snprintf(buf, len,
+		       _("method %s%s%s requires a pointer receiver"),
 		       open_quote, n.c_str(), close_quote);
 	      reason->assign(buf);
 	      delete[] buf;
@@ -9034,7 +9035,7 @@ 
 		 Gogo::message_name(name).c_str(), ambig1.c_str(),
 		 ambig2.c_str());
       else if (found_pointer_method)
-	error_at(location, "method requires a pointer");
+	error_at(location, "method requires a pointer receiver");
       else if (nt == NULL && st == NULL && it == NULL)
 	error_at(location,
 		 ("reference to field %qs in object which "