1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Closes #1082. Puts back use of function calls in parameter lists.

This commit is contained in:
Timothy Jones 2011-02-23 13:20:01 +13:00
parent cf6c21a0d2
commit 5fbbfbcbe3
3 changed files with 7 additions and 3 deletions

View file

@ -436,9 +436,10 @@
stack.push(tok); stack.push(tok);
break; break;
case '(': case '(':
case 'CALL_START':
if (stack.length) { if (stack.length) {
stack.pop(); stack.pop();
} else { } else if (tok[0] === '(') {
tok[0] = 'PARAM_START'; tok[0] = 'PARAM_START';
return this; return this;
} }

View file

@ -369,9 +369,9 @@ exports.Lexer = class Lexer
switch tok[0] switch tok[0]
when ')' when ')'
stack.push tok stack.push tok
when '(' when '(', 'CALL_START'
if stack.length then stack.pop() if stack.length then stack.pop()
else else if tok[0] is '('
tok[0] = 'PARAM_START' tok[0] = 'PARAM_START'
return this return this
this this

View file

@ -148,6 +148,9 @@ test "default values with splatted arguments", ->
eq 1, withSplats(1,1,1) eq 1, withSplats(1,1,1)
eq 2, withSplats(1,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", -> test "arguments vs parameters", ->
doesNotThrow -> CoffeeScript.compile "f(x) ->" doesNotThrow -> CoffeeScript.compile "f(x) ->"
f = (g) -> g() f = (g) -> g()