From 6560444d0970a58ea40bfa18f06ea5410fd904f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 30 Aug 2021 18:09:39 +0200 Subject: [PATCH] :bug: Fix access to globals --- src/parse/check.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/parse/check.c b/src/parse/check.c index b52b9175..9e36af90 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -252,6 +252,11 @@ ANN static inline Value get_value(const Env env, const Symbol sym) { return NULL; } +ANN static inline bool is_value_global(const Env env, const Value v) { + if(GET_FLAG(v, global)) return true; + return from_global_nspc(env, v->from->owner); +} + ANN static Value check_non_res_value(const Env env, const Symbol *data) { const Symbol var = *data; const Value value = get_value(env, var); @@ -270,7 +275,7 @@ ANN static Value check_non_res_value(const Env env, const Symbol *data) { return v; } else if (SAFE_FLAG(env->class_def, global) || (env->func && GET_FLAG(env->func->def->base, global))) { - if (!value || !GET_FLAG(value, global)) + if (!value || !is_value_global(env, value)) ERR_O(prim_pos(data), _("non-global variable '%s' used from global function/class."), s_name(var)) -- 2.43.0