diff options
Diffstat (limited to 'src/cmd/gc/subr.c')
| -rw-r--r-- | src/cmd/gc/subr.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index 9dfb445c6..2e0c6b07d 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -345,8 +345,19 @@ maptype(Type *key, Type *val) { Type *t; - if(key != nil && key->etype != TANY && algtype(key) == ANOEQ) - yyerror("invalid map key type %T", key); + if(key != nil && key->etype != TANY && algtype(key) == ANOEQ) { + if(key->etype == TFORW) { + // map[key] used during definition of key. + // postpone check until key is fully defined. + // if there are multiple uses of map[key] + // before key is fully defined, the error + // will only be printed for the first one. + // good enough. + if(key->maplineno == 0) + key->maplineno = lineno; + } else + yyerror("invalid map key type %T", key); + } t = typ(TMAP); t->down = key; t->type = val; |
