emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master a6f2a94 15/38: Allow plain parameters after default


From: Dmitry Gutov
Subject: [elpa] master a6f2a94 15/38: Allow plain parameters after default
Date: Wed, 09 Sep 2015 18:41:41 +0000

branch: master
commit a6f2a9410a441c272084e629b4307905f37431d1
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Allow plain parameters after default
    
    https://bugzilla.mozilla.org/show_bug.cgi?id=777060
    Fixes #257
---
 js2-mode.el     |   17 ++++-------------
 tests/parser.el |    6 ++----
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index e4b4a55..c802a66 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -8041,7 +8041,7 @@ represented by FN-NODE at POS."
                                  (eq (js2-current-token-type) js2-NAME)))
           params param
           param-name-nodes new-param-name-nodes
-          default-found rest-param-at)
+          rest-param-at)
       (when paren-free-arrow
         (js2-unget-token))
       (cl-loop for tt = (js2-peek-token)
@@ -8051,8 +8051,6 @@ represented by FN-NODE at POS."
                 ((and (not paren-free-arrow)
                       (or (= tt js2-LB) (= tt js2-LC)))
                  (js2-get-token)
-                 (when default-found
-                   (js2-report-error "msg.no.default.after.default.param"))
                  (setq param (js2-parse-destruct-primary-expr)
                        new-param-name-nodes (js2-define-destruct-symbols
                                              param js2-LP 'js2-function-param))
@@ -8074,14 +8072,8 @@ represented by FN-NODE at POS."
                  (js2-check-strict-function-params param-name-nodes (list 
param))
                  (setq param-name-nodes (append param-name-nodes (list param)))
                  ;; default parameter value
-                 (when (or (and default-found
-                                (not rest-param-at)
-                                (js2-must-match js2-ASSIGN
-                                                
"msg.no.default.after.default.param"
-                                                (js2-node-pos param)
-                                                (js2-node-len param)))
-                           (and (>= js2-language-version 200)
-                                (js2-match-token js2-ASSIGN)))
+                 (when (and (>= js2-language-version 200)
+                            (js2-match-token js2-ASSIGN))
                    (cl-assert (not paren-free-arrow))
                    (let* ((pos (js2-node-pos param))
                           (tt (js2-current-token-type))
@@ -8091,8 +8083,7 @@ represented by FN-NODE at POS."
                           (len (- (js2-node-end right) pos)))
                      (setq param (make-js2-assign-node
                                   :type tt :pos pos :len len :op-pos op-pos
-                                  :left left :right right)
-                           default-found t)
+                                  :left left :right right))
                      (js2-node-add-children param left right)))
                  (push param params)))
                (when (and rest-param-at (> (length params) (1+ rest-param-at)))
diff --git a/tests/parser.el b/tests/parser.el
index bfc5653..dc8c001 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -226,12 +226,10 @@ the test."
   "function foo(a = 1, b = a + 1) {\n}")
 
 (js2-deftest-parse function-with-no-default-after-default
-  "function foo(a = 1, b) {\n}"
-  :syntax-error "b")
+  "function foo(a = 1, b) {\n}")
 
 (js2-deftest-parse function-with-destruct-after-default
-  "function foo(a = 1, {b, c}) {\n}"
-  :syntax-error "{")
+  "function foo(a = 1, {b, c}) {\n}")
 
 (js2-deftest-parse function-with-rest-parameter
   "function foo(a, b, ...rest) {\n}")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]