setlineno(n);
switch(n->op) {
default:
- yyerror("select case must be receive, send or assign recv");;
+ yyerror("select case must be receive, send or assign recv");
break;
case OAS:
// convert x = <-c into OSELRECV(x, c)
+ // assignment might have introduced a
+ // conversion. throw it away.
+ // it will come back when the select code
+ // gets generated, because it always assigns
+ // through a temporary.
+ if((n->right->op == OCONVNOP || n->right->op == OCONVIFACE) && n->right->implicit)
+ n->right = n->right->left;
if(n->right->op != ORECV) {
yyerror("select assignment must have receive on right hand side");
break;
if(n->isddd != 0)
fmtprint(fp, " isddd(%d)", n->isddd);
+ if(n->implicit != 0)
+ fmtprint(fp, " implicit(%d)", n->implicit);
+
return 0;
}
r = nod(op, n, N);
r->type = t;
r->typecheck = 1;
+ r->implicit = 1;
return r;
}
--- /dev/null
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// issue 1172
+
+package main
+
+func main() {
+ var i interface{}
+ c := make(chan int, 1)
+ c <- 1
+ select {
+ case i = <-c: // error on this line
+ }
+ if i != 1 {
+ println("bad i", i)
+ panic("BUG")
+ }
+}