branch: master
commit b576cef1e8751b6ceb7532e2ab833b551fc46860
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
Declare vars created with renaming destructuring
Fixes regression from 0555a8a3.
---
js2-mode.el | 12 ++++++++++--
tests/parser.el | 3 ++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 00be32c..b2efce0 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 4a8c9c3..b546c1c 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]])];")