1
0
mirror of https://github.com/golang/go synced 2024-11-22 01:44:40 -07:00

func f() (int, int);

x := f();

used to give
	fatal error: dowidth fn struct struct { int; int }

now gives
	assignment count mismatch: 1 = 2

R=ken
OCL=27198
CL=27201
This commit is contained in:
Russ Cox 2009-04-07 22:20:37 -07:00
parent 7cbec417b1
commit 3067781ab9
2 changed files with 39 additions and 25 deletions

View File

@ -3067,6 +3067,41 @@ colas(Node *nl, Node *nr)
n = N;
cr = listcount(nr);
cl = listcount(nl);
/* check calls early, to give better message for a := f() */
if(cr == 1) {
switch(nr->op) {
case OCALLMETH:
case OCALLINTER:
case OCALL:
walktype(nr->left, Erv);
convlit(nr->left, types[TFUNC]);
t = nr->left->type;
if(t == T)
return; // error already printed
if(t->etype == tptr)
t = t->type;
if(t == T || t->etype != TFUNC) {
yyerror("cannot call %T", t);
return;
}
if(t->outtuple != cl) {
cr = t->outtuple;
goto badt;
}
// finish call - first half above
l = listfirst(&savel, &nl);
t = structfirst(&saver, getoutarg(t));
while(l != N) {
a = old2new(l, t->type);
n = list(n, a);
l = listnext(&savel);
t = structnext(&saver);
}
n = rev(n);
return n;
}
}
if(cl != cr) {
if(cr == 1)
goto multi;
@ -3099,29 +3134,6 @@ multi:
default:
goto badt;
case OCALLMETH:
case OCALLINTER:
case OCALL:
walktype(nr->left, Erv);
convlit(nr->left, types[TFUNC]);
t = nr->left->type;
if(t != T && t->etype == tptr)
t = t->type;
if(t == T || t->etype != TFUNC)
goto badt;
if(t->outtuple != cl)
goto badt;
l = listfirst(&savel, &nl);
t = structfirst(&saver, getoutarg(t));
while(l != N) {
a = old2new(l, t->type);
n = list(n, a);
l = listnext(&savel);
t = structnext(&saver);
}
break;
case OINDEX:
// check if rhs is a map index.
// if so, types are valuetype,bool

View File

@ -145,8 +145,6 @@ fixedbugs/bug035.go:7: variable f redeclared in this block
=========== fixedbugs/bug037.go
fixedbugs/bug037.go:6: vlong: undefined
fixedbugs/bug037.go:6: illegal types for operand: AS
undefined
=========== fixedbugs/bug039.go
fixedbugs/bug039.go:6: variable x redeclared in this block
@ -219,7 +217,11 @@ fixedbugs/bug091.go:15: illegal types for operand: AS
M
=========== fixedbugs/bug103.go
fixedbugs/bug103.go:8: assignment count mismatch: 1 = 0
fixedbugs/bug103.go:8: x: undefined
fixedbugs/bug103.go:8: function requires a return type
fixedbugs/bug103.go:8: illegal types for operand: AS
int
=========== fixedbugs/bug113.go
main.I is int, not int32