1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:04:39 -07:00

allow name-type or pointer-to-named-type as method name (bug046)

R=r
DELTA=17  (11 added, 3 deleted, 3 changed)
OCL=14048
CL=14048
This commit is contained in:
Ken Thompson 2008-08-10 15:09:09 -07:00
parent b89c538473
commit 258c817a1b

View File

@ -216,18 +216,26 @@ methcmp(Type *t1, Type *t2)
Node*
methodname(Node *n, Type *t)
{
Sym *s;
s = S;
if(t->sym != S)
s = t->sym;
if(isptr[t->etype])
t = t->type;
if(t->etype != TSTRUCT)
goto bad;
if(t->sym == S)
goto bad;
if(t->sym != S)
s = t->sym;
snprint(namebuf, sizeof(namebuf), "%s_%s", t->sym->name, n->sym->name);
// if(t->etype != TSTRUCT)
// goto bad;
if(s == S)
goto bad;
snprint(namebuf, sizeof(namebuf), "%s_%s", s->name, n->sym->name);
return newname(lookup(namebuf));
bad:
yyerror("illegal <this> pointer");
yyerror("illegal <this> pointer: %T", t);
return n;
}