]> Nishi Git Mirror - gwion.git/commitdiff
:art: Improve 'new' type checking
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 24 May 2020 20:11:05 +0000 (22:11 +0200)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Sun, 24 May 2020 20:11:16 +0000 (22:11 +0200)
src/lib/opfunc.c
tests/error/new_prim.gw

index a78843900859aa30cccdfa36e95b3d02361eb71a..9868d64e908f8b42b875304cdd2a64e706a0d2e1 100644 (file)
@@ -84,8 +84,8 @@ OP_CHECK(opck_new) {
   const Exp_Unary* unary = (Exp_Unary*)data;
   SET_FLAG(unary->td, ref);
   DECL_ON(const Type, t, = known_type(env, unary->td))
-  if(isa(t, env->gwion->type[et_object]) < 0 && isa(t, env->gwion->type[et_function]) < 0)
-    ERR_N(exp_self(unary)->pos, _("primitive types cannot be used as reference (@)...\n"))
+  if(isa(t, env->gwion->type[et_object]) < 0)
+    ERR_N(exp_self(unary)->pos, _("can't use 'new' on non-object types...\n"))
   if(type_ref(t))
     ERR_N(td_pos(unary->td), _("can't use 'new' on ref type '%s'\n"), t->name)
   if(GET_FLAG(t, abstract))
index dc7b67782260f63093c96c233758f21bceb62aea..34e99d8ec80a500f5771569df359b8eda6eba308 100644 (file)
@@ -1,2 +1,2 @@
-#! [contains] primitive types cannot be used as reference
+#! [contains] can't use 'new' on non-object types...
 new int;