]> Cypherpunks repositories - gostls13.git/commitdiff
bug064
authorRuss Cox <rsc@golang.org>
Thu, 5 Feb 2009 23:22:49 +0000 (15:22 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 5 Feb 2009 23:22:49 +0000 (15:22 -0800)
make f(g()) work when g returns multiple
args with names different than f expects.

func swap(a, b int) (c, d int) {
return b, a
}

swap(swap(1,2))

R=ken
OCL=24474
CL=24476

src/cmd/gc/go.h
src/cmd/gc/subr.c
src/cmd/gc/walk.c
test/fixedbugs/bug064.go [moved from test/bugs/bug064.go with 100% similarity]
test/golden.out

index 1dd041bada9cffa34a105bf3d3c88da680b4a0ce..6545d1e18ca39a253c635debd0036caf34844b6c 100644 (file)
@@ -527,8 +527,6 @@ EXTERN      int32   thunk;
 
 EXTERN int     exporting;
 
-EXTERN int     func;
-
 /*
  *     y.tab.c
  */
@@ -650,6 +648,7 @@ Type*       methtype(Type*);
 int    methconv(Type*);
 Sym*   signame(Type*);
 int    eqtype(Type*, Type*, int);
+int    eqtypenoname(Type*, Type*);
 void   argtype(Node*, Type*);
 int    eqargs(Type*, Type*);
 uint32 typehash(Type*, int);
index 593d07cd38522693277b9c5bee530143ee06c728..2df3fc168f57b3e07886a1868609d1ebb1a2febc 100644 (file)
@@ -1742,6 +1742,25 @@ eqtype(Type *t1, Type *t2, int d)
        return eqtype(t1->type, t2->type, d+1);
 }
 
+int
+eqtypenoname(Type *t1, Type *t2)
+{
+       if(t1 == T || t2 == T || t1->etype != TSTRUCT || t2->etype != TSTRUCT)
+               return eqtype(t1, t2, 0);
+
+
+       t1 = t1->type;
+       t2 = t2->type;
+       for(;;) {
+               if(!eqtype(t1, t2, 1))
+                       return 0;
+               if(t1 == T)
+                       return 1;
+               t1 = t1->down;
+               t2 = t2->down;
+       }
+}
+
 static int
 subtype(Type **stp, Type *t, int d)
 {
index 6e959b8c7a62afee69a6f0ec758ec195ad80bc6a..b680cb07440c0088d41029cfa646eb6cbffe6c8e 100644 (file)
@@ -1905,8 +1905,8 @@ ascompatte(int op, Type **nl, Node **nr, int fp)
        if(l != T && r != N
        && structnext(&peekl) != T
        && listnext(&peekr) == N
-       && eqtype(r->type, *nl, 0))
-               return convas(nod(OAS, nodarg(*nl, fp), r));
+       && eqtypenoname(r->type, *nl))
+               return convas(nod(OAS, nodarg(r->type, fp), r));
 
 loop:
        if(l != T && isddd(l->type)) {
similarity index 100%
rename from test/bugs/bug064.go
rename to test/fixedbugs/bug064.go
index 6713ec2fcfe378f18963add4268a4b3cdc0e59a8..fb9b82709ea1f9d75dcfda70fd675ad02168c01c 100644 (file)
@@ -117,12 +117,6 @@ abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz
 =========== chan/nonblock.go
 PASS
 
-=========== bugs/bug064.go
-bugs/bug064.go:15: illegal types for operand: CALL
-       int
-       struct { u int; v int }
-BUG: compilation should succeed
-
 =========== bugs/bug085.go
 bugs/bug085.go:8: P: undefined
 BUG: fails incorrectly