From 5ba1e753dcd745bcb5b81d9098f6c780840be897 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Thu, 6 Feb 2020 15:13:34 -0500 Subject: more new idents --- types.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/types.c b/types.c index 0daf0ca..b89eb9c 100644 --- a/types.c +++ b/types.c @@ -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; } } -- cgit v1.2.3