bugfix function closure value handling
@@ -30,6 +30,7 @@ HL_PRIM vclosure *hl_alloc_closure_void( hl_type *t, void *fvalue ) {
c->t = t;
c->fun = fvalue;
c->hasValue = false;
+ c->value = NULL;
return c;
}
@@ -80,11 +81,13 @@ HL_PRIM vdynamic *hl_make_closure( vdynamic *c, vdynamic *v ) {
HL_PRIM vdynamic* hl_get_closure_value( vdynamic *c ) {
vclosure *cl = (vclosure*)c;
+ if( !cl->hasValue )
+ return NULL;
if( cl->hasValue == 2 )
return hl_get_closure_value((vdynamic*)((vclosure_wrapper*)c)->wrappedFun);
- if( cl->hasValue && cl->fun != fun_var_args )
- return hl_make_dyn(&cl->value, cl->t->fun->parent->fun->args[0]);
+ if( cl->fun == fun_var_args )
return (vdynamic*)cl->value;
+ return hl_make_dyn(&cl->value, cl->t->fun->parent->fun->args[0]);
}
HL_PRIM bool hl_fun_compare( vdynamic *a, vdynamic *b ) {
