{
ast_instantiate(ast_function, ctx, ast_function_delete);
- if (!vtype ||
- vtype->hasvalue ||
- vtype->expression.vtype != TYPE_FUNCTION)
- {
+ if (!vtype) {
+ compile_error(ast_ctx(self), "internal error: ast_function_new condition 0");
+ goto cleanup;
+ } else if (vtype->hasvalue || vtype->expression.vtype != TYPE_FUNCTION) {
compile_error(ast_ctx(self), "internal error: ast_function_new condition %i %i type=%i (probably 2 bodies?)",
(int)!vtype,
(int)vtype->hasvalue,
vtype->expression.vtype);
- mem_d(self);
- return NULL;
+ goto cleanup;
}
self->vtype = vtype;
self->return_value = NULL;
return self;
+
+cleanup:
+ mem_d(self);
+ return NULL;
}
void ast_function_delete(ast_function *self)