if(cr == 1) {
// a,b,... = fn()
walktype(r, Erv);
- convlit(r, types[TFUNC]);
+ if(r->type == T || r->type->etype != TSTRUCT)
+ break;
l = ascompatet(n->op, &n->left, &r->type, 0);
if(l != N)
indir(n, list(r, reorder2(l)));
loop:
if(l == N || r == N) {
+ // cannot happen: caller checked that lists had same length
if(l != r)
yyerror("error in shape across %O", op);
return rev(nn);
loop:
if(l == N || r == T) {
if(l != N || r != T)
- yyerror("error in shape across %O", op);
+ yyerror("assignment count mismatch: %d = %d",
+ listcount(*nl), structcount(*nr));
+
return rev(nn);
}
return nn;
}
+/*
+ * helpers for shape errors
+ */
+static void
+dumptypes(Type **nl, char *what)
+{
+ int first;
+ Type *l;
+ Iter savel;
+
+ l = structfirst(&savel, nl);
+ print("\t");
+ first = 1;
+ for(l = structfirst(&savel, nl); l != T; l = structnext(&savel)) {
+ if(first)
+ first = 0;
+ else
+ print(", ");
+ print("%T", l);
+ }
+ if(first)
+ print("[no arguments %s]", what);
+ print("\n");
+}
+
+static void
+dumpnodetypes(Node **nr, char *what)
+{
+ int first;
+ Node *r;
+ Iter saver;
+
+ print("\t");
+ first = 1;
+ for(r = listfirst(&saver, nr); r != N; r = listnext(&saver)) {
+ if(first)
+ first = 0;
+ else
+ print(", ");
+ print("%T", r->type);
+ }
+ if(first)
+ print("[no arguments %s]", what);
+ print("\n");
+}
+
/*
* check assign expression list to
* a type list. called in
&& structnext(&peekl) != T
&& listnext(&peekr) == N
&& eqtypenoname(r->type, *nl)) {
- // clumsy check for differently aligned structs.
+ // TODO(rsc): clumsy check for differently aligned structs.
// need to handle eventually, but this keeps us
// from inserting bugs
if(r->type->width != (*nl)->width) {
}
if(l == T || r == N) {
- if(l != T || r != N)
- yyerror("error in shape across %O", op);
+ if(l != T || r != N) {
+ if(l != T)
+ yyerror("not enough arguments to %O", op);
+ else
+ yyerror("too many arguments to %O", op);
+ dumptypes(nl, "expected");
+ dumpnodetypes(nr, "given");
+ }
return rev(nn);
}
convlit(r, l->type);
=========== fixedbugs/bug049.go
fixedbugs/bug049.go:6: cannot convert nil constant to string
+fixedbugs/bug049.go:6: illegal types for operand: EQ
+ string
+ nil
=========== fixedbugs/bug050.go
fixedbugs/bug050.go:3: package statement must be first
fixedbugs/bug062.go:6: cannot convert nil constant to string
fixedbugs/bug062.go:6: illegal types for operand: AS
string
+ nil
=========== fixedbugs/bug067.go
ok
fixedbugs/bug131.go:7: cannot convert uint64 constant to int64
fixedbugs/bug131.go:7: illegal types for operand: AS
int64
+ uint64
=========== fixedbugs/bug133.go
fixedbugs/bug133.dir/bug2.go:11: undefined DOT i on bug0.T