diff --git a/lib/nodes.js b/lib/nodes.js index 29831b5f..c1e168bf 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -514,12 +514,23 @@ CurryNode.prototype.type = 'Curry'; CurryNode.prototype.code = "function(func, obj, args) {\n return function() {\n return func.apply(obj || {}, args.concat(__slice.call(arguments, 0)));\n };\n}"; CurryNode.prototype.slice = "Array.prototype.slice"; + CurryNode.prototype.arguments = function arguments(o) { + var _a, _b, _c, arg; + _a = this.args; + for (_b = 0, _c = _a.length; _b < _c; _b++) { + arg = _a[_b]; + if (arg instanceof SplatNode) { + return literal(this.compile_splat_arguments(o)); + } + } + return new ArrayNode(this.args); + }; CurryNode.prototype.compile_node = function compile_node(o) { var call, ref; o.scope.assign('__curry', this.code, true); o.scope.assign('__slice', this.slice, true); ref = new ValueNode(literal('__curry')); - call = new CallNode(ref, [this.meth, this.bind, new ArrayNode(this.args)]); + call = new CallNode(ref, [this.meth, this.bind, this.arguments(o)]); return call.compile(o); }; return CurryNode; diff --git a/src/nodes.coffee b/src/nodes.coffee index f574e3c3..c34fd3d8 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -405,11 +405,16 @@ exports.CurryNode: class CurryNode extends CallNode constructor: (meth, bind, args) -> @children: flatten [@meth: meth, @bind: bind or literal('this'), @args: (args or [])] + arguments: (o) -> + for arg in @args + return literal(@compile_splat_arguments(o)) if arg instanceof SplatNode + new ArrayNode(@args) + compile_node: (o) -> o.scope.assign('__curry', @code, true) o.scope.assign('__slice', @slice, true) ref: new ValueNode literal('__curry') - call: new CallNode ref, [@meth, @bind, new ArrayNode(@args)] + call: new CallNode ref, [@meth, @bind, @arguments(o)] call.compile(o)