From 5fbbfbcbe33551f8717415ff8d945a2a5ecdcc0c Mon Sep 17 00:00:00 2001 From: Timothy Jones Date: Wed, 23 Feb 2011 13:20:01 +1300 Subject: [PATCH] Closes #1082. Puts back use of function calls in parameter lists. --- lib/lexer.js | 3 ++- src/lexer.coffee | 4 ++-- test/function_literals.coffee | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 62a40410..fd5c08ab 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -436,9 +436,10 @@ stack.push(tok); break; case '(': + case 'CALL_START': if (stack.length) { stack.pop(); - } else { + } else if (tok[0] === '(') { tok[0] = 'PARAM_START'; return this; } diff --git a/src/lexer.coffee b/src/lexer.coffee index 11990a8d..f29ec69b 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -369,9 +369,9 @@ exports.Lexer = class Lexer switch tok[0] when ')' stack.push tok - when '(' + when '(', 'CALL_START' if stack.length then stack.pop() - else + else if tok[0] is '(' tok[0] = 'PARAM_START' return this this diff --git a/test/function_literals.coffee b/test/function_literals.coffee index 921f5b7e..01e8499a 100644 --- a/test/function_literals.coffee +++ b/test/function_literals.coffee @@ -148,6 +148,9 @@ test "default values with splatted arguments", -> eq 1, withSplats(1,1,1) eq 2, withSplats(1,1,1,1) +test "default values with function calls", -> + doesNotThrow -> CoffeeScript.compile "(x = f()) ->" + test "arguments vs parameters", -> doesNotThrow -> CoffeeScript.compile "f(x) ->" f = (g) -> g()