Skip to content

Commit

Permalink
add support for trailing comma in function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
olessavluk committed Sep 30, 2017
1 parent df51992 commit daed014
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,5 +1,9 @@
# History of user-visible changes

## Next

* Support for trailing comma in function arguments

## 2017-07-21

* Support for async arrow function without parentheses.
Expand Down
4 changes: 3 additions & 1 deletion js2-mode.el
Expand Up @@ -10238,7 +10238,9 @@ Returns the list in reverse order. Consumes the right-paren token."
(js2-unget-token)
(push (js2-parse-assign-expr) result)))
while
(js2-match-token js2-COMMA))
(and (js2-match-token js2-COMMA)
(or (< js2-language-version 200)
(not (= js2-RP (js2-peek-token))))))
(js2-must-match js2-RP "msg.no.paren.arg")
result)))

Expand Down
4 changes: 4 additions & 0 deletions tests/parser.el
Expand Up @@ -106,6 +106,10 @@ the test."
(js2-deftest-parse function-statement
"function foo() {\n}")

(js2-deftest-parse trailing-comma-in-function-arguments
"f(a, b,);"
:reference "f(a, b);")

(js2-deftest-parse function-statement-inside-block
"if (true) {\n function foo() {\n }\n}")

Expand Down

0 comments on commit daed014

Please sign in to comment.