diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index f4d6479008..103163c9e4 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -535,7 +535,7 @@ }; Literal.prototype.toString = function() { - return " " + (this.isStatement() ? Literal.__super__.toString.apply(this, arguments) : this.constructor.name) + ": " + this.value; + return " " + (this.isStatement() ? Literal.__super__.toString.apply(this, (arguments)) : this.constructor.name) + ": " + this.value; }; return Literal; @@ -781,7 +781,7 @@ if (o.scope.parent == null) { this.error('yield can only occur inside functions'); } - return YieldReturn.__super__.compileNode.apply(this, arguments); + return YieldReturn.__super__.compileNode.apply(this, (arguments)); }; return YieldReturn; @@ -1037,7 +1037,7 @@ } delete this.needsUpdatedStartLocation; } - return Call.__super__.updateLocationDataIfMissing.apply(this, arguments); + return Call.__super__.updateLocationDataIfMissing.apply(this, (arguments)); }; Call.prototype.newInstance = function() { @@ -2725,7 +2725,7 @@ return this.name.assigns(name); }; - Splat.prototype.compileToFragments = function(o) { + Splat.prototype.compileNode = function(o) { return this.name.compileToFragments(o); }; @@ -2818,7 +2818,7 @@ While.prototype.makeReturn = function(res) { if (res) { - return While.__super__.makeReturn.apply(this, arguments); + return While.__super__.makeReturn.apply(this, (arguments)); } else { this.returns = !this.jumps({ loop: true @@ -3371,7 +3371,7 @@ StringWithInterpolations.prototype.compileNode = function(o) { var element, elements, expr, fragments, j, len1, value; if (!o.inTaggedTemplateCall) { - return StringWithInterpolations.__super__.compileNode.apply(this, arguments); + return StringWithInterpolations.__super__.compileNode.apply(this, (arguments)); } expr = this.body.unwrap(); elements = []; diff --git a/src/nodes.coffee b/src/nodes.coffee index 6ef56a7bb6..8625b74319 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1812,7 +1812,7 @@ exports.Splat = class Splat extends Base assigns: (name) -> @name.assigns name - compileToFragments: (o) -> + compileNode: (o) -> @name.compileToFragments o unwrap: -> @name diff --git a/test/arrays.coffee b/test/arrays.coffee index bffd512787..234c9ddcc9 100644 --- a/test/arrays.coffee +++ b/test/arrays.coffee @@ -36,9 +36,7 @@ test "array splat expansions with assignments", -> eq 4, b arrayEq [0,1,2,3,4], list - test "mixed shorthand objects in array lists", -> - arr = [ a:1 'b' @@ -58,7 +56,6 @@ test "mixed shorthand objects in array lists", -> eq arr[2].b, 1 eq arr[3], 'b' - test "array splats with nested arrays", -> nonce = {} a = [nonce] @@ -70,6 +67,30 @@ test "array splats with nested arrays", -> list = [1, 2, a...] arrayEq list, [1, 2, [nonce]] +test "#4260: splat after existential operator soak", -> + a = {b: [3]} + foo = (a) -> [a] + arrayEq [a?.b...], [3] + arrayEq [c?.b ? []...], [] + arrayEq foo(a?.b...), [3] + arrayEq foo(c?.b ? []...), [undefined] + e = yes + f = null + arrayEq [(a if e)?.b...], [3] + arrayEq [(a if f)?.b ? []...], [] + arrayEq foo((a if e)?.b...), [3] + arrayEq foo((a if f)?.b ? []...), [undefined] + +test "#1349: trailing if after splat", -> + a = [3] + b = yes + c = null + foo = (a) -> [a] + arrayEq [a if b...], [3] + arrayEq [(a if c) ? []...], [] + arrayEq foo((a if b)...), [3] + arrayEq foo((a if c) ? []...), [undefined] + test "#1274: `[] = a()` compiles to `false` instead of `a()`", -> a = false fn = -> a = true