Fix issue with using libraries

This commit is contained in:
Bruce Hill 2024-06-19 16:09:22 -04:00
parent c3a6e03bd2
commit 8724dcd821
2 changed files with 2 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);