Commit 3067781a authored by Russ Cox's avatar Russ Cox

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
parent 7cbec417
...@@ -3067,6 +3067,41 @@ colas(Node *nl, Node *nr) ...@@ -3067,6 +3067,41 @@ colas(Node *nl, Node *nr)
n = N; n = N;
cr = listcount(nr); cr = listcount(nr);
cl = listcount(nl); 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(cl != cr) {
if(cr == 1) if(cr == 1)
goto multi; goto multi;
...@@ -3099,29 +3134,6 @@ multi: ...@@ -3099,29 +3134,6 @@ multi:
default: default:
goto badt; 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: case OINDEX:
// check if rhs is a map index. // check if rhs is a map index.
// if so, types are valuetype,bool // if so, types are valuetype,bool
......
...@@ -145,8 +145,6 @@ fixedbugs/bug035.go:7: variable f redeclared in this block ...@@ -145,8 +145,6 @@ fixedbugs/bug035.go:7: variable f redeclared in this block
=========== fixedbugs/bug037.go =========== fixedbugs/bug037.go
fixedbugs/bug037.go:6: vlong: undefined fixedbugs/bug037.go:6: vlong: undefined
fixedbugs/bug037.go:6: illegal types for operand: AS
undefined
=========== fixedbugs/bug039.go =========== fixedbugs/bug039.go
fixedbugs/bug039.go:6: variable x redeclared in this block fixedbugs/bug039.go:6: variable x redeclared in this block
...@@ -219,7 +217,11 @@ fixedbugs/bug091.go:15: illegal types for operand: AS ...@@ -219,7 +217,11 @@ fixedbugs/bug091.go:15: illegal types for operand: AS
M M
=========== fixedbugs/bug103.go =========== 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: function requires a return type
fixedbugs/bug103.go:8: illegal types for operand: AS
int
=========== fixedbugs/bug113.go =========== fixedbugs/bug113.go
main.I is int, not int32 main.I is int, not int32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment