From: Jérémie Astor Date: Sun, 3 Jan 2021 00:02:26 +0000 (+0100) Subject: :art: Array safety for abstract types X-Git-Tag: nightly~1063 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=38587347c4b88eed5789483ede3a9d38e7f11bf9;p=gwion.git :art: Array safety for abstract types --- diff --git a/src/parse/scan1.c b/src/parse/scan1.c index c1a7ce6e..a5766604 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -86,6 +86,10 @@ ANN static m_bool scan1_decl(const Env env, const Exp_Decl* decl) { CHECK_BB(scan1_exp(env, var->array->exp)) t = array_type(env, decl->type, var->array->depth); } + if(t->array_depth && GET_FLAG(array_base(t), abstract) && ((var->array && var->array->exp) + || (decl->td->array && decl->td->array->exp))) + ERR_B(var->pos, _("arrays of abstract type '%s' must be declared empty"), + array_base(t)->name); const Value v = var->value = var->value ?: new_value(env->gwion->mp, t, s_name(var->xid)); nspc_add_value(env->curr, var->xid, v); if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, late)) diff --git a/tests/error/abstract_array.gw b/tests/error/abstract_array.gw new file mode 100644 index 00000000..d89b9016 --- /dev/null +++ b/tests/error/abstract_array.gw @@ -0,0 +1,2 @@ +#! [contains] must be declared empty +var Shred[12] shreds;