mirror of
https://github.com/golang/go
synced 2024-11-22 04:24:39 -07:00
gc: fix use of typekind array in error messages
Fixes #1697. R=ken2 CC=golang-dev https://golang.org/cl/4395045
This commit is contained in:
parent
dd93df35b9
commit
bd77eedacf
@ -56,7 +56,7 @@ typechecklist(NodeList *l, int top)
|
|||||||
typecheck(&l->n, top);
|
typecheck(&l->n, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* typekind[] = {
|
static char* _typekind[] = {
|
||||||
[TINT] = "int",
|
[TINT] = "int",
|
||||||
[TUINT] = "uint",
|
[TUINT] = "uint",
|
||||||
[TINT8] = "int8",
|
[TINT8] = "int8",
|
||||||
@ -82,8 +82,22 @@ static char* typekind[] = {
|
|||||||
[TMAP] = "map",
|
[TMAP] = "map",
|
||||||
[TARRAY] = "array",
|
[TARRAY] = "array",
|
||||||
[TFUNC] = "func",
|
[TFUNC] = "func",
|
||||||
|
[TNIL] = "nil",
|
||||||
|
[TIDEAL] = "ideal number",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char*
|
||||||
|
typekind(int et)
|
||||||
|
{
|
||||||
|
static char buf[50];
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
if(0 <= et && et < nelem(_typekind) && (s=_typekind[et]) != nil)
|
||||||
|
return s;
|
||||||
|
snprint(buf, sizeof buf, "etype=%d", et);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* type check node *np.
|
* type check node *np.
|
||||||
* replaces *np with a new pointer in some cases.
|
* replaces *np with a new pointer in some cases.
|
||||||
@ -406,7 +420,7 @@ reswitch:
|
|||||||
}
|
}
|
||||||
if(!okfor[op][et]) {
|
if(!okfor[op][et]) {
|
||||||
notokfor:
|
notokfor:
|
||||||
yyerror("invalid operation: %#N (operator %#O not defined on %s)", n, op, typekind[et]);
|
yyerror("invalid operation: %#N (operator %#O not defined on %s)", n, op, typekind(et));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
// okfor allows any array == array;
|
// okfor allows any array == array;
|
||||||
|
Loading…
Reference in New Issue
Block a user