]> Cypherpunks repositories - gostls13.git/commitdiff
multiple return in := bug
authorRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 23:59:10 +0000 (16:59 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 27 Jul 2009 23:59:10 +0000 (16:59 -0700)
R=ken
OCL=32253
CL=32253

src/cmd/gc/subr.c
src/cmd/gc/walk.c
test/fixedbugs/bug175.go [new file with mode: 0644]
test/golden.out

index fbfded77cf0ae6fcca7ea1dfb5839c1983f933f5..14a5fa7b5c9f8fd0031a63719af42a6a97383b5e 100644 (file)
@@ -1112,6 +1112,15 @@ Tpretty(Fmt *fp, Type *t)
                return fmtprint(fp, " }");
 
        case TSTRUCT:
+               if(t->funarg) {
+                       fmtprint(fp, "(");
+                       for(t1=t->type; t1!=T; t1=t1->down) {
+                               fmtprint(fp, "%T", t1);
+                               if(t1->down)
+                                       fmtprint(fp, ", ");
+                       }
+                       return fmtprint(fp, ")");
+               }
                fmtprint(fp, "struct {");
                for(t1=t->type; t1!=T; t1=t1->down) {
                        fmtprint(fp, " %T", t1);
index 2402ef3b629f63b920e1a4e2132bf89c23faedd9..31b52434a3e7ee3cfb54ce7fc7fc673b4f0364af 100644 (file)
@@ -3673,6 +3673,10 @@ old2new(Node *n, Type *t, NodeList **init)
                yyerror("left side of := must be a name");
                return n;
        }
+       if(t != T && t->funarg) {
+               yyerror("use of multi func value as single value in :=");
+               return n;
+       }
        l = newname(n->sym);
        dodclvar(l, t, init);
        return l;
diff --git a/test/fixedbugs/bug175.go b/test/fixedbugs/bug175.go
new file mode 100644 (file)
index 0000000..a8f6e3c
--- /dev/null
@@ -0,0 +1,14 @@
+// errchk $G $D/$F.go
+
+// Copyright 2009 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.
+
+package main
+
+func f() (int, bool) { return 0, true }
+
+func main() {
+       x, y := f(), 2; // ERROR "multi"
+}
+
index 5c50da5a753f6308b9862cc23c6c9158aa7cd694..605a9b31acd41de752541792fd802809388ba135 100644 (file)
@@ -235,3 +235,9 @@ fixedbugs/bug131.go:7: illegal types for operand: AS
 fixedbugs/bug133.dir/bug2.go:11: undefined: bug0.T field i
 fixedbugs/bug133.dir/bug2.go:11: illegal types for operand: RETURN
        int
+
+=========== fixedbugs/bug175.go
+fixedbugs/bug175.go:8: use of multi func value as single value in :=
+fixedbugs/bug175.go:8: undefined: x
+fixedbugs/bug175.go:8: illegal types for operand: AS
+       (int, bool)