diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-14 02:37:56 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-14 02:37:56 -0400 |
| commit | fdc3eadba25aff7894419e483519e73150be33d4 (patch) | |
| tree | ae0bf68e1bfa501fd9010b66d2211b0b1ef59a23 /typecheck.c | |
| parent | 130ddc8ea04060ec52d9a2fd03da8c9662d32f9c (diff) | |
Array comprehensions
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/typecheck.c b/typecheck.c index 769d8680..33e8bfee 100644 --- a/typecheck.c +++ b/typecheck.c @@ -307,7 +307,13 @@ type_t *get_type(env_t *env, ast_t *ast) item_type = parse_type_ast(env, array->type); } else if (array->items) { for (ast_list_t *item = array->items; item; item = item->next) { - type_t *t2 = get_type(env, item->ast); + type_t *t2; + if (item->ast->tag == For) { + env_t *scope = for_scope(env, item->ast); + t2 = get_type(scope, Match(item->ast, For)->body); + } else { + t2 = get_type(env, item->ast); + } type_t *merged = item_type ? type_or_type(item_type, t2) : t2; if (!merged) code_err(item->ast, |
