From d6b43062f3ea40a89014694a922ce62ebfc535d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 6 Dec 2020 14:05:54 +0100 Subject: [PATCH] :art:Improve array type creation. --- src/env/type.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; -- 2.43.0