From: Jérémie Astor Date: Sun, 24 May 2020 20:11:05 +0000 (+0200) Subject: :art: Improve 'new' type checking X-Git-Tag: nightly~1520 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=f4e73514869a8c71996eb3c70dc9084f1e477965;p=gwion.git :art: Improve 'new' type checking --- diff --git a/src/lib/opfunc.c b/src/lib/opfunc.c index a7884390..9868d64e 100644 --- a/src/lib/opfunc.c +++ b/src/lib/opfunc.c @@ -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)) diff --git a/tests/error/new_prim.gw b/tests/error/new_prim.gw index dc7b6778..34e99d8e 100644 --- a/tests/error/new_prim.gw +++ b/tests/error/new_prim.gw @@ -1,2 +1,2 @@ -#! [contains] primitive types cannot be used as reference +#! [contains] can't use 'new' on non-object types... new int;