aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-22 18:32:31 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-22 18:32:31 -0500
commitf10273d2ef7d5bdd3592c4c19476bd62a9b4a164 (patch)
tree8c49059d74aac88c105adf474a15fdd86d04ffe1
parent354605f56937e6f51695084d208521f7f2df890c (diff)
Allow writes without reads to global varsv2025-12-22
-rw-r--r--src/compile/functions.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/compile/functions.c b/src/compile/functions.c
index ec37c0ad..01377a89 100644
--- a/src/compile/functions.c
+++ b/src/compile/functions.c
@@ -630,6 +630,8 @@ static void check_unused_vars(env_t *env, arg_ast_t *args, ast_t *body) {
const char *name;
} *entry = unused.entries.data + i * unused.entries.stride;
if (streq(entry->name, "_")) continue;
+ // Global/file scoped vars are okay to mutate without reading
+ if (get_binding(env, entry->name) != NULL) continue;
ast_t *var = Table$str_get(assigned_vars, entry->name);
code_err(var, "This variable was assigned to, but never read from.");
}