diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-06 15:13:34 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-06 15:13:34 -0500 |
commit | 5ba1e753dcd745bcb5b81d9098f6c780840be897 (patch) | |
tree | dca614e3e74cdc5696d3191137d51600b99b6e91 | |
parent | 3cfbab5635fe31e825bc7b71946651fefd6fb5ba (diff) |
more new idents
-rw-r--r-- | types.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -372,8 +372,20 @@ static bool type_of_ident(Typer *tr, Location where, Identifier *ident, Type *t) assert(i->idents->scope == tr->block); if (i->decl_kind == IDECL_NONE) { long nblocks = (long)arr_len(tr->blocks); - for (long idx = nblocks - 1; idx >= 0; --idx) { - int x; + long idx; + for (idx = nblocks - 1; idx >= 0; --idx) { + Identifier translated = ident_translate(i, &tr->blocks[idx]->idents); + if (!translated) continue; + if (translated->decl_kind != IDECL_NONE) { + i = *ident = translated; + break; + } + } + if (idx == -1) { + char *s = ident_to_str(i); + err_print(where, "Undeclared identifier: %s", s); + free(s); + return false; } } |