From: Jérémie Astor Date: Sun, 6 Dec 2020 13:05:54 +0000 (+0100) Subject: :art:Improve array type creation. X-Git-Tag: nightly~1125 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d6b43062f3ea40a89014694a922ce62ebfc535d9;p=gwion.git :art:Improve array type creation. --- diff --git a/src/env/type.c b/src/env/type.c index 73dbd1c0..fdf63d04 100644 --- a/src/env/type.c +++ b/src/env/type.c @@ -99,7 +99,9 @@ ANN Type array_type(const Env env, const Type src, const m_uint depth) { const Type type = nspc_lookup_type1(src->info->owner, sym); if(type) return type; - const Type t = new_type(env->gwion->mp, s_name(sym), env->gwion->type[et_array]); + const Type parent = src->info->parent ? + array_type(env, src->info->parent, depth) : env->gwion->type[et_array]; + const Type t = new_type(env->gwion->mp, s_name(sym), parent); t->array_depth = depth + src->array_depth; t->info->base_type = array_base(src) ?: src; t->info->owner = src->info->owner; @@ -111,7 +113,7 @@ ANN Type array_type(const Env env, const Type src, const m_uint depth) { *(f_release**)(t->nspc->info->class_data) = (depth > 1 || !tflag(src, tflag_struct)) ? object_release : struct_release; } else - nspc_addref((t->nspc = env->gwion->type[et_array]->nspc)); + nspc_addref((t->nspc = parent->nspc)); mk_class(env, t); nspc_add_type_front(src->info->owner, sym, t); return t;