static OP_CHECK(opck_func_call) {
Exp_Binary *bin = (Exp_Binary *)data;
Exp_Call call = {.func = bin->rhs, .args = bin->lhs};
+ call.allow_curry = true;
Exp e = exp_self(bin);
e->exp_type = ae_exp_call;
memcpy(&e->d.exp_call, &call, sizeof(Exp_Call));
OP_CHECK(opck_new) {
Exp_Unary *unary = (Exp_Unary *)data;
DECL_ON(const Type, t, = known_type(env, unary->ctor.td));
+ if (type_ref(t))
+ ERR_N(unary->ctor.td->pos, _("can't use 'new' on ref type '%s'\n"), t->name);
+ if (tflag(t, tflag_infer))
+ ERR_N(unary->ctor.td->pos, _("can't use 'new' on '%s'\n"),
+ t->name);
+ if (unary->ctor.td->array) CHECK_BN(check_subscripts(env, unary->ctor.td->array, 1));
if(unary->ctor.exp) {
const Exp self = exp_self(unary);
const Exp args = cpy_exp(env->gwion->mp, unary->ctor.exp);
self->d.exp_call.func = func;
self->d.exp_call.args = args;
self->d.exp_call.tmpl = NULL;
+ self->d.exp_call.allow_curry = 0;
self->exp_type = ae_exp_call;
CHECK_BN(traverse_exp(env, self));
return self->type;
// unarytype
}
- 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(unary->ctor.td->pos, _("can't use 'new' on ref type '%s'\n"), t->name);
if (GET_FLAG(t, abstract))
ERR_N(unary->ctor.td->pos, _("can't use 'new' on abstract type '%s'\n"),
t->name);
- if (unary->ctor.td->array) CHECK_BN(check_subscripts(env, unary->ctor.td->array, 1));
+ if (isa(t, env->gwion->type[et_object]) < 0)
+ ERR_N(exp_self(unary)->pos, _("can't use 'new' on non-object types...\n"));
return t;
}
}
ANN static Type check_exp_call(const Env env, Exp_Call *exp) {
- if (curried(env, exp->args))
+ if (exp->allow_curry && curried(env, exp->args))
return env->gwion->type[et_curry];
if (exp->tmpl) {
DECL_BO(const m_bool, ret, = func_check(env, exp));