Type *l, *ll;
Node *r, *a;
NodeList *nn, *lr0, *alist;
- Iter savel, peekl;
+ Iter savel;
lr0 = lr;
l = structfirst(&savel, nl);
if(lr)
r = lr->n;
nn = nil;
-
- // 1 to many
- peekl = savel;
- if(l != T && r != N && structnext(&peekl) != T && lr->next == nil
- && r->type->etype == TSTRUCT && r->type->funarg) {
+
+ // f(g()) where g has multiple return values
+ if(r != N && lr->next == nil && r->type->etype == TSTRUCT && r->type->funarg) {
// optimization - can do block copy
if(eqtypenoname(r->type, *nl)) {
a = nodarg(*nl, fp);
nn = list1(convas(nod(OAS, a, r), init));
goto ret;
}
+
// conversions involved.
// copy into temporaries.
alist = nil;
if(l == T || r == N) {
if(l != T || r != N) {
if(l != T)
- yyerror("xxx not enough arguments to %O", op);
+ yyerror("not enough arguments to %O", op);
else
- yyerror("xxx too many arguments to %O", op);
+ yyerror("too many arguments to %O", op);
dumptypes(nl, "expected");
dumpnodetypes(lr0, "given");
}
--- /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.
+
+// http://code.google.com/p/go/issues/detail?id=662
+
+package main
+
+import "fmt"
+
+func f() (int, int) { return 1, 2 }
+
+func main() {
+ s := fmt.Sprint(f())
+ if s != "1 2" { // with bug, was "{1 2}"
+ println("BUG")
+ }
+}