From f4e73514869a8c71996eb3c70dc9084f1e477965 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 24 May 2020 22:11:05 +0200 Subject: [PATCH] :art: Improve 'new' type checking --- src/lib/opfunc.c | 4 ++-- tests/error/new_prim.gw | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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; -- 2.43.0