diff --git a/lib/nodes.js b/lib/nodes.js index 38c10961..38d51947 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 59280e5a..5b515941 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 diff --git a/test/function_invocation.coffee b/test/function_invocation.coffee index a13a0eee..fe5bdbd5 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