From 386d3dd307ff87b3710e5d1d8b1b6230143acbbb Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 26 Jan 2010 21:15:56 -0500 Subject: [PATCH] complete implicit functions, I think these are done. --- lib/coffee_script/rewriter.rb | 2 +- test/fixtures/execution/test_functions.coffee | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/coffee_script/rewriter.rb b/lib/coffee_script/rewriter.rb index 1aecae82..d085c8f7 100644 --- a/lib/coffee_script/rewriter.rb +++ b/lib/coffee_script/rewriter.rb @@ -19,7 +19,7 @@ module CoffeeScript EXPRESSION_CLOSE = [:CATCH, :WHEN, :ELSE, :FINALLY] + EXPRESSION_TAIL # Tokens pairs that, in immediate succession, indicate an implicit call. - IMPLICIT_FUNC = [:IDENTIFIER, :SUPER] + IMPLICIT_FUNC = [:IDENTIFIER, :SUPER, ')', :CALL_END, ']', :INDEX_END] IMPLICIT_END = [:IF, :UNLESS, :FOR, :WHILE, "\n", :OUTDENT] IMPLICIT_CALL = [:IDENTIFIER, :NUMBER, :STRING, :JS, :REGEX, :NEW, :PARAM_START, :TRY, :DELETE, :INSTANCEOF, :TYPEOF, :SWITCH, :ARGUMENTS, diff --git a/test/fixtures/execution/test_functions.coffee b/test/fixtures/execution/test_functions.coffee index 9fe19c8b..50552ce3 100644 --- a/test/fixtures/execution/test_functions.coffee +++ b/test/fixtures/execution/test_functions.coffee @@ -64,3 +64,15 @@ result: call -> Math.Add(5, 5) print result is 10 + + +# And even with strange things like this: + +funcs: [(x) -> x, (x) -> x * x] +result: funcs[1] 5 + +print result is 25 + +result: ("hello".slice) 3 + +print result is 'lo' \ No newline at end of file