From 944a114400d12221704015d2fdb53c55198305b6 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Thu, 6 Jan 2011 12:38:40 -0500 Subject: [PATCH 1/2] tests for #1011 --- test/function_invocation.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/function_invocation.coffee b/test/function_invocation.coffee index a13a0eee30..fe5bdbd5ff 100644 --- a/test/function_invocation.coffee +++ b/test/function_invocation.coffee @@ -298,7 +298,7 @@ ok pen is 2 method 1, 2 ok pen is 2 -# Finally, splats with super() within classes. +# splats with super() within classes. class Parent meth: (args...) -> args @@ -308,6 +308,12 @@ class Child extends Parent super nums... ok (new Child).meth().join(' ') is '3 2 1' +test "#1011: passing a splat to a method of a number", -> + eq '1011', 11.toString [2]... + eq '1011', (31).toString [3]... + eq '1011', 69.0.toString [4]... + eq '1011', (131.0).toString [5]... + #### Implicit Return From b158f1cbe64d28920c8becc2b1d2b0234d355e72 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Thu, 6 Jan 2011 12:38:54 -0500 Subject: [PATCH 2/2] fix for #1011 --- lib/nodes.js | 3 +++ src/nodes.coffee | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/nodes.js b/lib/nodes.js index 296f5616a2..3e29c405c5 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -668,6 +668,9 @@ fun = "(" + ref + " = " + (base.compile(o, LEVEL_LIST)) + ")" + (name.compile(o)); } else { fun = base.compile(o, LEVEL_ACCESS); + if (SIMPLENUM.test(fun)) { + fun = "(" + fun + ")"; + } if (name) { ref = fun; fun += name.compile(o); diff --git a/src/nodes.coffee b/src/nodes.coffee index 47f000cc08..3ecea60cc3 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -529,6 +529,7 @@ exports.Call = class Call extends Base fun = "(#{ref} = #{ base.compile o, LEVEL_LIST })#{ name.compile o }" else fun = base.compile o, LEVEL_ACCESS + fun = "(#{fun})" if SIMPLENUM.test fun if name ref = fun fun += name.compile o