From: Jérémie Astor Date: Mon, 30 Aug 2021 16:09:39 +0000 (+0200) Subject: :bug: Fix access to globals X-Git-Tag: nightly~470^2~33 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=6560444d0970a58ea40bfa18f06ea5410fd904f2;p=gwion.git :bug: Fix access to globals --- 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))