From fdc3eadba25aff7894419e483519e73150be33d4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 14 Mar 2024 02:37:56 -0400 Subject: Array comprehensions --- typecheck.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'typecheck.c') 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, -- cgit v1.2.3