]> Nishi Git Mirror - gwion.git/commitdiff
:art: Set ref flag on auto abstract types
authorfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 20 Oct 2019 14:49:42 +0000 (16:49 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Sun, 20 Oct 2019 14:49:42 +0000 (16:49 +0200)
src/parse/scan1.c
tests/tree/auto_ref.gw [new file with mode: 0644]

index 7c96c8397e54ec47b6b3e55393723004aff581d2..50c2f1f5083d36bfc647a76b44fbe3a4b322e83e 100644 (file)
@@ -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 (file)
index 0000000..cd46a74
--- /dev/null
@@ -0,0 +1 @@
+me @=> auto a;