Commit 61590c4c authored by Russ Cox's avatar Russ Cox

disallow P.t for lowercase t and not our package P.

implement hiding lowercase methods m in
signatures by adding in a hash of the package name
to the type hash code.

remove remaining checks for internally-generated _ names:
they are all gone.

R=ken
OCL=23236
CL=23238
parent c3fa54c4
...@@ -57,9 +57,8 @@ if(throwreturn == N) { ...@@ -57,9 +57,8 @@ if(throwreturn == N) {
// add clearing of the output parameters // add clearing of the output parameters
t = structfirst(&save, getoutarg(curfn->type)); t = structfirst(&save, getoutarg(curfn->type));
while(t != T) { while(t != T) {
if(t->nname != N && t->nname->sym->name[0] != '_') { if(t->nname != N)
curfn->nbody = list(nod(OAS, t->nname, N), curfn->nbody); curfn->nbody = list(nod(OAS, t->nname, N), curfn->nbody);
}
t = structnext(&save); t = structnext(&save);
} }
} }
......
...@@ -658,6 +658,8 @@ dumpsigt(Type *progt, Type *ifacet, Type *rcvrt, Type *methodt, Sym *s) ...@@ -658,6 +658,8 @@ dumpsigt(Type *progt, Type *ifacet, Type *rcvrt, Type *methodt, Sym *s)
a->name = method->name; a->name = method->name;
a->hash = PRIME8*stringhash(a->name) + PRIME9*typehash(f->type, 0); a->hash = PRIME8*stringhash(a->name) + PRIME9*typehash(f->type, 0);
if(!exportname(a->name))
a->hash += PRIME10*stringhash(package);
a->perm = o; a->perm = o;
a->sym = methodsym(method, rcvrt); a->sym = methodsym(method, rcvrt);
...@@ -767,7 +769,6 @@ dumpsigi(Type *t, Sym *s) ...@@ -767,7 +769,6 @@ dumpsigi(Type *t, Sym *s)
int o; int o;
Sig *a, *b; Sig *a, *b;
Prog *p; Prog *p;
char *sp;
char buf[NSYMB]; char buf[NSYMB];
at.sym = s; at.sym = s;
...@@ -784,19 +785,15 @@ dumpsigi(Type *t, Sym *s) ...@@ -784,19 +785,15 @@ dumpsigi(Type *t, Sym *s)
s1 = f->sym; s1 = f->sym;
if(s1 == nil) if(s1 == nil)
continue; continue;
if(s1->name[0] == '_')
continue;
b = mal(sizeof(*b)); b = mal(sizeof(*b));
b->link = a; b->link = a;
a = b; a = b;
a->name = s1->name; a->name = s1->name;
sp = strchr(s1->name, '_');
if(sp != nil)
a->name = sp+1;
a->hash = PRIME8*stringhash(a->name) + PRIME9*typehash(f->type, 0); a->hash = PRIME8*stringhash(a->name) + PRIME9*typehash(f->type, 0);
if(!exportname(a->name))
a->hash += PRIME10*stringhash(package);
a->perm = o; a->perm = o;
a->sym = methodsym(f->sym, t); a->sym = methodsym(f->sym, t);
a->offset = 0; a->offset = 0;
......
...@@ -433,7 +433,7 @@ funcargs(Type *ft) ...@@ -433,7 +433,7 @@ funcargs(Type *ft)
while(t != T) { while(t != T) {
if(t->nname != N) if(t->nname != N)
t->nname->xoffset = t->width; t->nname->xoffset = t->width;
if(t->nname != N && t->nname->sym->name[0] != '_') { if(t->nname != N) {
addvar(t->nname, t->type, PPARAM); addvar(t->nname, t->type, PPARAM);
all |= 1; all |= 1;
} else } else
......
...@@ -34,6 +34,7 @@ enum ...@@ -34,6 +34,7 @@ enum
PRIME7 = 10067, PRIME7 = 10067,
PRIME8 = 10079, PRIME8 = 10079,
PRIME9 = 10091, PRIME9 = 10091,
PRIME10 = 10093,
AUNK = 100, AUNK = 100,
// these values are known by runtime // these values are known by runtime
......
...@@ -685,6 +685,8 @@ talph: ...@@ -685,6 +685,8 @@ talph:
s = pkglookup(s->name, context); s = pkglookup(s->name, context);
if(s->lexical == LIGNORE) if(s->lexical == LIGNORE)
goto l0; goto l0;
if(!exportname(s->name) && strcmp(package, s->opackage) != 0)
s = pkglookup(s->name, ".private");
} }
DBG("lex: %S %s\n", s, lexname(s->lexical)); DBG("lex: %S %s\n", s, lexname(s->lexical));
......
...@@ -1683,12 +1683,8 @@ eqtype(Type *t1, Type *t2, int d) ...@@ -1683,12 +1683,8 @@ eqtype(Type *t1, Type *t2, int d)
if(t1->nname != N && t1->nname->sym != S) { if(t1->nname != N && t1->nname->sym != S) {
if(t2->nname == N || t2->nname->sym == S) if(t2->nname == N || t2->nname->sym == S)
return 0; return 0;
if(strcmp(t1->nname->sym->name, t2->nname->sym->name) != 0) { if(strcmp(t1->nname->sym->name, t2->nname->sym->name) != 0)
// assigned names dont count return 0;
if(t1->nname->sym->name[0] != '_' ||
t2->nname->sym->name[0] != '_')
return 0;
}
} }
t1 = t1->down; t1 = t1->down;
t2 = t2->down; t2 = t2->down;
...@@ -2489,7 +2485,7 @@ expand0(Type *t) ...@@ -2489,7 +2485,7 @@ expand0(Type *t)
u = methtype(t); u = methtype(t);
if(u != T) { if(u != T) {
for(f=u->method; f!=T; f=f->down) { for(f=u->method; f!=T; f=f->down) {
if(!exportname(f->sym->name) && strcmp(f->sym->package, package) != 0) if(!exportname(f->sym->name) && strcmp(f->sym->opackage, package) != 0)
continue; continue;
if(f->sym->uniq) if(f->sym->uniq)
continue; continue;
......
...@@ -168,6 +168,13 @@ throw: ...@@ -168,6 +168,13 @@ throw:
prints(": missing method "); prints(": missing method ");
prints((int8*)iname); prints((int8*)iname);
prints("\n"); prints("\n");
if(iface_debug) {
prints("interface");
printsigi(si);
prints("\ntype");
printsigt(st);
prints("\n");
}
throw("interface conversion"); throw("interface conversion");
} }
m->bad = 1; m->bad = 1;
......
...@@ -232,7 +232,7 @@ fixedbugs/bug074.go:7: x: undefined ...@@ -232,7 +232,7 @@ fixedbugs/bug074.go:7: x: undefined
fixedbugs/bug081.go:5: no type x fixedbugs/bug081.go:5: no type x
=========== fixedbugs/bug083.go =========== fixedbugs/bug083.go
BUG: succeeds incorrectly fixedbugs/bug083.dir/bug1.go:9: syntax error near t0
=========== fixedbugs/bug086.go =========== fixedbugs/bug086.go
fixedbugs/bug086.go:5: function ends without a return statement fixedbugs/bug086.go:5: function ends without a return statement
......
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