Patchwork Go patch committed: Don't crash on erroneous var init from receive

login
register
mail settings
Submitter Ian Taylor
Date Dec. 22, 2010, 4:38 p.m.
Message ID <mcr62ulhifo.fsf@google.com>
Download mbox | patch
Permalink /patch/76433/
State New
Headers show

Comments

Ian Taylor - Dec. 22, 2010, 4:38 p.m.
This patch to the Go frontend avoids a compiler crash when a variable is
initialized from a channel receive but the receive turns out to be
erroneous.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r da6d9ff631bd go/gogo.cc
--- a/go/gogo.cc	Wed Dec 22 08:27:02 2010 -0800
+++ b/go/gogo.cc	Wed Dec 22 08:35:00 2010 -0800
@@ -3165,7 +3165,7 @@ 
     {
       Expression* channel = expr->receive_expression()->channel();
       Type* channel_type = channel->type();
-      if (channel_type->is_error_type())
+      if (channel_type->channel_type() == NULL)
 	return Type::make_error_type();
       return channel_type->channel_type()->element_type();
     }