1
0
mirror of https://github.com/golang/go synced 2024-11-17 04:14:52 -07:00

loop in subtype

SVN=127933
This commit is contained in:
Ken Thompson 2008-07-17 18:15:05 -07:00
parent c3e9c7d106
commit 0ca551fc36

View File

@ -1281,7 +1281,7 @@ eqtype(Type *t1, Type *t2, int d)
} }
static int static int
subtype(Type **stp, Type *t) subtype(Type **stp, Type *t, int d)
{ {
Type *st; Type *st;
@ -1289,6 +1289,11 @@ loop:
st = *stp; st = *stp;
if(st == T) if(st == T)
return 0; return 0;
d++;
if(d >= 10)
return 0;
switch(st->etype) { switch(st->etype) {
default: default:
return 0; return 0;
@ -1304,18 +1309,18 @@ loop:
break; break;
case TMAP: case TMAP:
if(subtype(&st->down, t)) if(subtype(&st->down, t, d))
break; break;
stp = &st->type; stp = &st->type;
goto loop; goto loop;
case TFUNC: case TFUNC:
for(;;) { for(;;) {
if(subtype(&st->type, t)) if(subtype(&st->type, t, d))
break; break;
if(subtype(&st->type->down->down, t)) if(subtype(&st->type->down->down, t, d))
break; break;
if(subtype(&st->type->down, t)) if(subtype(&st->type->down, t, d))
break; break;
return 0; return 0;
} }
@ -1323,7 +1328,7 @@ loop:
case TSTRUCT: case TSTRUCT:
for(st=st->type; st!=T; st=st->down) for(st=st->type; st!=T; st=st->down)
if(subtype(&st->type, t)) if(subtype(&st->type, t, d))
return 1; return 1;
return 0; return 0;
} }
@ -1333,7 +1338,7 @@ loop:
void void
argtype(Node *on, Type *t) argtype(Node *on, Type *t)
{ {
if(!subtype(&on->type, t)) if(!subtype(&on->type, t, 0))
fatal("argtype: failed %N %T\n", on, t); fatal("argtype: failed %N %T\n", on, t);
} }