summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-02-06 15:13:34 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-02-06 15:13:34 -0500
commit5ba1e753dcd745bcb5b81d9098f6c780840be897 (patch)
treedca614e3e74cdc5696d3191137d51600b99b6e91
parent3cfbab5635fe31e825bc7b71946651fefd6fb5ba (diff)
more new idents
-rw-r--r--types.c16
1 files 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;
}
}