This patch to the Go frontend gives better error messages for the common error of omitting a channel element type. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 5e8176633433 go/parse.cc --- a/go/parse.cc Mon Mar 28 14:34:54 2011 -0700 +++ b/go/parse.cc Mon Mar 28 14:46:43 2011 -0700 @@ -656,6 +656,23 @@ this->advance_token(); } } + + // Better error messages for the common error of omitting the + // channel element type. + if (!this->type_may_start_here()) + { + token = this->peek_token(); + if (token->is_op(OPERATOR_RCURLY)) + error_at(this->location(), "unexpected %<}%> in channel type"); + else if (token->is_op(OPERATOR_RPAREN)) + error_at(this->location(), "unexpected %<)%> in channel type"); + else if (token->is_op(OPERATOR_COMMA)) + error_at(this->location(), "unexpected comma in channel type"); + else + error_at(this->location(), "expected channel element type"); + return Type::make_error_type(); + } + Type* element_type = this->type(); return Type::make_channel_type(send, receive, element_type); }