aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-16 14:02:39 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-16 14:02:39 -0400
commit35339e2aa028942d297f15521c26e1400fe1eca2 (patch)
tree0d02d1a53c4e37a190bfcb48d2601db937bcb0fb /compile.c
parent1e283dd31048e2d21c22784b1a438836ffbea7c4 (diff)
Fix globals issue
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index ecde6bfe..27b4a442 100644
--- a/compile.c
+++ b/compile.c
@@ -2054,7 +2054,11 @@ module_code_t compile_file(ast_t *ast)
Table$str_set(env->imports, name, env);
for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) {
+ // Hack: make sure global is bound as foo$var:
+ if (stmt->ast->tag == Declare)
+ env->scope_prefix = heap_strf("%s$", name);
bind_statement(env, stmt->ast);
+ env->scope_prefix = NULL;
}
for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) {
if (stmt->ast->tag == Declare) {