From 84a1d5b1fef77b4de12deb5ae96413153f5554d0 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sun, 20 Oct 2019 16:49:42 +0200 Subject: [PATCH] :art: Set ref flag on auto abstract types --- src/parse/scan1.c | 8 ++++++-- tests/tree/auto_ref.gw | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 tests/tree/auto_ref.gw diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 7c96c839..50c2f1f5 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -82,8 +82,12 @@ 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); - } else if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, ref)) - ERR_B(exp_self(decl)->pos, _("Type '%s' is abstract, declare as ref. (use @)"), t->name) + } else if(GET_FLAG(t, abstract) && !GET_FLAG(decl->td, ref)) { + if(decl->td->xid && decl->td->xid->xid == insert_symbol("auto")) + SET_FLAG(decl->td, ref); + else + ERR_B(exp_self(decl)->pos, _("Type '%s' is abstract, declare as ref. (use @)"), t->name) + } if(env->class_def) type_contains(env->class_def, t); const Value v = var->value = former ?: new_value(env->gwion->mp, t, s_name(var->xid)); diff --git a/tests/tree/auto_ref.gw b/tests/tree/auto_ref.gw new file mode 100644 index 00000000..cd46a74b --- /dev/null +++ b/tests/tree/auto_ref.gw @@ -0,0 +1 @@ +me @=> auto a; -- 2.43.0