diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-06-08 14:39:52 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-06-08 14:39:52 -0400 |
| commit | 39ac885125795b24afeae2f14abeebddab7c0179 (patch) | |
| tree | ea17c1fad4dc9f4ca646c60ff4922882ea8a318f /typecheck.c | |
| parent | 66062f399a63281e6825376b24267a1f3e85cb06 (diff) | |
Change c/header transpilation order and fix some issues
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/typecheck.c b/typecheck.c index 2c6c6a01..d7c49307 100644 --- a/typecheck.c +++ b/typecheck.c @@ -303,9 +303,11 @@ void bind_statement(env_t *env, ast_t *statement) struct {const char *name; binding_t *binding; } *entry = Table$entry(*bindings, i); if (entry->name[0] == '_' || streq(entry->name, "main")) continue; - if (Table$str_get(*env->locals, entry->name)) + binding_t *b = Table$str_get(*env->locals, entry->name); + if (!b) + Table$str_set(env->locals, entry->name, entry->binding); + else if (b != entry->binding) code_err(statement, "This module imports a symbol called '%s', which would clobber another variable", entry->name); - Table$str_set(env->locals, entry->name, entry->binding); } } for (int64_t i = 1; i <= Table$length(*module_env->types); i++) { |
