diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-06-19 16:09:22 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-06-19 16:09:22 -0400 |
| commit | 8724dcd82164921e8fba0641989bc88b8ce02ec6 (patch) | |
| tree | 5560d5893d7903d1fb386d5009c0ade9c5f5067e | |
| parent | c3a6e03bd2aebeddc1251c3e8ff925290b19226c (diff) | |
Fix issue with using libraries
| -rw-r--r-- | environment.c | 1 | ||||
| -rw-r--r-- | 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); |
