1
0
mirror of https://github.com/golang/go synced 2024-11-25 13:57:57 -07:00
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
This commit is contained in:
Russ Cox 2009-02-05 15:22:49 -08:00
parent 7a3877aa0c
commit b0009bef20
5 changed files with 22 additions and 10 deletions

View 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);

View 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)
{

View 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)) {

View 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