mirror of
https://github.com/golang/go
synced 2024-11-19 18:14:40 -07:00
gc: print detail for typechecking loop error
R=ken2 CC=golang-dev https://golang.org/cl/5654060
This commit is contained in:
parent
2f3d695a61
commit
2aafad25b4
@ -111,16 +111,15 @@ typekind(Type *t)
|
|||||||
* replaces *np with a new pointer in some cases.
|
* replaces *np with a new pointer in some cases.
|
||||||
* returns the final value of *np as a convenience.
|
* returns the final value of *np as a convenience.
|
||||||
*/
|
*/
|
||||||
|
static void typecheck1(Node **, int);
|
||||||
Node*
|
Node*
|
||||||
typecheck(Node **np, int top)
|
typecheck(Node **np, int top)
|
||||||
{
|
{
|
||||||
int et, aop, op, ptr;
|
Node *n;
|
||||||
Node *n, *l, *r;
|
int lno;
|
||||||
NodeList *args;
|
Fmt fmt;
|
||||||
int lno, ok, ntop;
|
NodeList *l;
|
||||||
Type *t, *tp, *ft, *missing, *have, *badtype;
|
static NodeList *tcstack, *tcfree;
|
||||||
Val v;
|
|
||||||
char *why;
|
|
||||||
|
|
||||||
// cannot type check until all the source has been parsed
|
// cannot type check until all the source has been parsed
|
||||||
if(!typecheckok)
|
if(!typecheckok)
|
||||||
@ -157,11 +156,52 @@ typecheck(Node **np, int top)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(n->typecheck == 2) {
|
if(n->typecheck == 2) {
|
||||||
yyerror("typechecking loop involving %N", n);
|
if(nsavederrors+nerrors == 0) {
|
||||||
|
fmtstrinit(&fmt);
|
||||||
|
for(l=tcstack; l; l=l->next)
|
||||||
|
fmtprint(&fmt, "\n\t%L %N", l->n->lineno, l->n);
|
||||||
|
yyerror("typechecking loop involving %N%s", n, fmtstrflush(&fmt));
|
||||||
|
}
|
||||||
lineno = lno;
|
lineno = lno;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
n->typecheck = 2;
|
n->typecheck = 2;
|
||||||
|
|
||||||
|
if(tcfree != nil) {
|
||||||
|
l = tcfree;
|
||||||
|
tcfree = l->next;
|
||||||
|
} else
|
||||||
|
l = mal(sizeof *l);
|
||||||
|
l->next = tcstack;
|
||||||
|
l->n = n;
|
||||||
|
tcstack = l;
|
||||||
|
|
||||||
|
typecheck1(&n, top);
|
||||||
|
*np = n;
|
||||||
|
n->typecheck = 1;
|
||||||
|
|
||||||
|
if(tcstack != l)
|
||||||
|
fatal("typecheck stack out of sync");
|
||||||
|
tcstack = l->next;
|
||||||
|
l->next = tcfree;
|
||||||
|
tcfree = l;
|
||||||
|
|
||||||
|
lineno = lno;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
typecheck1(Node **np, int top)
|
||||||
|
{
|
||||||
|
int et, aop, op, ptr;
|
||||||
|
Node *n, *l, *r;
|
||||||
|
NodeList *args;
|
||||||
|
int ok, ntop;
|
||||||
|
Type *t, *tp, *ft, *missing, *have, *badtype;
|
||||||
|
Val v;
|
||||||
|
char *why;
|
||||||
|
|
||||||
|
n = *np;
|
||||||
|
|
||||||
if(n->sym) {
|
if(n->sym) {
|
||||||
if(n->op == ONAME && n->etype != 0 && !(top & Ecall)) {
|
if(n->op == ONAME && n->etype != 0 && !(top & Ecall)) {
|
||||||
@ -1484,10 +1524,7 @@ error:
|
|||||||
n->type = T;
|
n->type = T;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
lineno = lno;
|
|
||||||
n->typecheck = 1;
|
|
||||||
*np = n;
|
*np = n;
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user