[Top][All Lists]

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

[elpa] master 523b3cb 38/49: Add a STRICT parameter to js2--collect-decl

From: Dmitry Gutov
Subject: [elpa] master 523b3cb 38/49: Add a STRICT parameter to js2--collect-declared-symbols
Date: Mon, 16 Jan 2017 15:35:49 +0000 (UTC)

branch: master
commit 523b3cbfc06dc3e559e79bb838e2010ec60dd7c6
Author: Lele Gaifax <address@hidden>
Commit: Lele Gaifax <address@hidden>

    Add a STRICT parameter to js2--collect-declared-symbols
 js2-mode.el |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index dd7574b..e0ad317 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -7144,9 +7144,10 @@ The latter two cases happen in destructuring 
assignments: recursively update the
   (dolist (elt (js2--collect-declared-symbols targets))
     (js2--add-or-update-symbol elt inition used vars)))
-(defun js2--collect-declared-symbols (node)
+(defun js2--collect-declared-symbols (node strict)
   "Collect the `js-name-node' symbols declared in NODE and return a list of 
-NODE is either `js2-array-node', `js2-object-node', or `js2-name-node'."
+NODE is either `js2-array-node', `js2-object-node', or `js2-name-node'.
+When STRICT, signal an error if NODE is not one of the expected types."
   (let (targets)
      ((js2-name-node-p node)
@@ -7159,7 +7160,7 @@ NODE is either `js2-array-node', `js2-object-node', or 
                           ((js2-unary-node-p elt) ;; rest (...)
                            (js2-unary-node-operand elt))
                           (t elt)))
-          (setq targets (append (js2--collect-declared-symbols elt) 
+          (setq targets (append (js2--collect-declared-symbols elt strict) 
      ((js2-object-node-p node)
       (dolist (elt (js2-object-node-elems node))
         (let ((subexpr (cond
@@ -7179,10 +7180,11 @@ NODE is either `js2-array-node', `js2-object-node', or 
                          (js2-unary-node-operand elt)))))
           (when subexpr
             (setq targets (append
-                           (js2--collect-declared-symbols subexpr)
+                           (js2--collect-declared-symbols subexpr strict)
-     (t (js2-report-error "msg.no.parm" nil (js2-node-abs-pos node)
-                          (js2-node-len node))
+     (strict
+      (js2-report-error "msg.no.parm" nil (js2-node-abs-pos node)
+                        (js2-node-len node))
@@ -8145,7 +8147,7 @@ NODE is either `js2-array-node', `js2-object-node', or 
 Return a list of `js2-name-node' nodes representing the symbols
 declared; probably to check them for errors."
-  (let ((name-nodes (js2--collect-declared-symbols node)))
+  (let ((name-nodes (js2--collect-declared-symbols node t)))
     (dolist (node name-nodes)
       (let (leftpos)
         (js2-define-symbol decl-type (js2-name-node-name node)

reply via email to

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