From 1b4582fec3fabc5ee3d41a0f878d676629f4a196 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Mon, 10 Feb 2014 07:53:09 -0800 Subject: [PATCH] Handle parameter list checking in closures. --- src/wren_core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wren_core.c b/src/wren_core.c index d72882fa..28a85aad 100644 --- a/src/wren_core.c +++ b/src/wren_core.c @@ -250,7 +250,16 @@ DEF_NATIVE(fiber_yield1) static PrimitiveResult callFunction(WrenVM* vm, Value* args, int numArgs) { - ObjFn* fn = AS_FN(args[0]); + ObjFn* fn; + if (IS_CLOSURE(args[0])) + { + fn = AS_CLOSURE(args[0])->fn; + } + else + { + fn = AS_FN(args[0]); + } + if (numArgs < fn->numParams) RETURN_ERROR("Function expects more arguments."); return PRIM_CALL;