From: Dmitry Gutov Date: Mon, 2 May 2016 00:26:52 +0000 (+0300) Subject: Declare vars created with renaming destructuring X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/b576cef1e8751b6ceb7532e2ab833b551fc46860 Declare vars created with renaming destructuring Fixes regression from 0555a8a3. --- diff --git a/js2-mode.el b/js2-mode.el index 00be32c12..b2efce007 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -8100,11 +8100,19 @@ declared; probably to check them for errors." (dolist (elem (js2-object-node-elems node)) ;; js2-infix-node-p catches both object prop node and initialized ;; binding element (which is directly an infix node). - (when (js2-infix-node-p elem) + (cond + ((js2-object-prop-node-p elem) + (push (js2-define-destruct-symbols + ;; In abbreviated destructuring {a, b}, right == left. + (js2-object-prop-node-right elem) + decl-type face ignore-not-in-block) + name-nodes)) + ;; Destructuring with default argument. + ((js2-infix-node-p elem) (push (js2-define-destruct-symbols (js2-infix-node-left elem) decl-type face ignore-not-in-block) - name-nodes))) + name-nodes)))) (apply #'append (nreverse name-nodes))) ((js2-array-node-p node) (dolist (elem (js2-array-node-elems node)) diff --git a/tests/parser.el b/tests/parser.el index 4a8c9c381..b546c1cff 100644 --- a/tests/parser.el +++ b/tests/parser.el @@ -188,7 +188,8 @@ the test." :warnings-count 0) (js2-deftest-parse destruct-in-arguments - "function f({a: aa, b: bb}) {\n}") + "function f({a: aa, b: bb}) {\n}" + :warnings-count 0) (js2-deftest-parse destruct-in-array-comp-loop "[a + b for ([a, b] in [[0, 1], [1, 2]])];")