Skip to content
Browse files

Fixes #2258 -- allow parameter lists in the vertical style.

  • Loading branch information...
1 parent 8bc6001 commit 87257ea6b3c0ba138d56b4aabb1c2113d0efda22 @jashkenas jashkenas committed Apr 24, 2012
Showing with 164 additions and 141 deletions.
  1. +4 −0 lib/coffee-script/grammar.js
  2. +145 −141 lib/coffee-script/parser.js
  3. +2 −0 src/grammar.coffee
  4. +13 −0 test/functions.coffee
View
4 lib/coffee-script/grammar.js
@@ -127,6 +127,10 @@
return [$1];
}), o('ParamList , Param', function() {
return $1.concat($3);
+ }), o('ParamList OptComma TERMINATOR Param', function() {
+ return $1.concat($4);
+ }), o('ParamList OptComma INDENT ParamList OptComma OUTDENT', function() {
+ return $1.concat($4);
})
],
Param: [
View
286 lib/coffee-script/parser.js
145 additions, 141 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 src/grammar.coffee
@@ -193,6 +193,8 @@ grammar =
o '', -> []
o 'Param', -> [$1]
o 'ParamList , Param', -> $1.concat $3
+ o 'ParamList OptComma TERMINATOR Param', -> $1.concat $4
+ o 'ParamList OptComma INDENT ParamList OptComma OUTDENT', -> $1.concat $4
]
# A single parameter in a function definition can be ordinary, or a splat
View
13 test/functions.coffee
@@ -193,3 +193,16 @@ test "#1844: bound functions in nested comprehensions causing empty var statemen
test "#1859: inline function bodies shouldn't modify prior postfix ifs", ->
list = [1, 2, 3]
ok true if list.some (x) -> x is 2
+
+test "#2258: allow whitespace-style parameter lists in function definitions", ->
+ func = (
+ a, b, c
+ ) -> c
+ eq func(1, 2, 3), 3
+
+ func = (
+ a
+ b
+ c
+ ) -> b
+ eq func(1, 2, 3), 2

0 comments on commit 87257ea

Please sign in to comment.
Something went wrong with that request. Please try again.