From 8724dcd82164921e8fba0641989bc88b8ce02ec6 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 19 Jun 2024 16:09:22 -0400 Subject: Fix issue with using libraries --- environment.c | 1 - typecheck.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.c b/environment.c index aca60d28..dcd852e3 100644 --- a/environment.c +++ b/environment.c @@ -262,7 +262,6 @@ env_t *load_module_env(env_t *env, ast_t *ast) for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) bind_statement(module_env, stmt->ast); - Table$str_set(env->imports, name, module_env); return module_env; } diff --git a/typecheck.c b/typecheck.c index fe153ab5..fd4f8b0e 100644 --- a/typecheck.c +++ b/typecheck.c @@ -132,6 +132,7 @@ static env_t *load_module(env_t *env, ast_t *module_ast) if (!files_f) errx(1, "Couldn't open file: %s", resolved_path); env_t *module_env = fresh_scope(env); + Table$str_set(env->imports, libname, module_env); char *libname_id = heap_str(libname); for (char *c = libname_id; *c; c++) { if (!isalnum(*c) && *c != '_') @@ -594,7 +595,7 @@ type_t *get_type(env_t *env, ast_t *ast) if (fielded_t->tag == ModuleType) { const char *name = Match(fielded_t, ModuleType)->name; env_t *module_env = Table$str_get(*env->imports, name); - if (!module_env) code_err(access->fielded, "I couldn't find the environment for this module"); + if (!module_env) code_err(access->fielded, "I couldn't find the environment for the module %s", name); return get_type(module_env, WrapAST(ast, Var, access->field)); } else if (fielded_t->tag == TypeInfoType) { auto info = Match(fielded_t, TypeInfoType); -- cgit v1.2.3