This patch to the Go frontend correctly parses select { case <-c <- v: } Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 51340e536e48 go/parse.cc --- a/go/parse.cc Fri Mar 25 13:39:15 2011 -0700 +++ b/go/parse.cc Fri Mar 25 18:57:25 2011 -0700 @@ -4375,17 +4375,25 @@ // send or receive expression. If SAW_COMMA is true, then *VAL is // set and we just read a comma. - if (!saw_comma && this->peek_token()->is_op(OPERATOR_CHANOP)) + Expression* e; + if (saw_comma || !this->peek_token()->is_op(OPERATOR_CHANOP)) + e = this->expression(PRECEDENCE_NORMAL, true, true, NULL); + else { // case <-c: *is_send = false; this->advance_token(); *channel = this->expression(PRECEDENCE_NORMAL, false, true, NULL); - return true; + + // The next token should be ':'. If it is '<-', then we have + // case <-c <- v: + // which is to say, send on a channel received from a channel. + if (!this->peek_token()->is_op(OPERATOR_CHANOP)) + return true; + + e = Expression::make_receive(*channel, (*channel)->location()); } - Expression* e = this->expression(PRECEDENCE_NORMAL, true, true, NULL); - if (this->peek_token()->is_op(OPERATOR_EQ)) { if (!this->advance_token()->is_op(OPERATOR_CHANOP))