Previously this function discriminated against nodes that did not have
parents. For such nodes, nil should have been returned, but instead an
error was emitted because a parentless node would produce the initial
parent nil, which would cause js2-node-parent to blow up. This fixes
that.
(defun js2-node-get-enclosing-scope (node)
"Return the innermost `js2-scope' node surrounding NODE.
Returns nil if there is no enclosing scope node."
- (let ((parent (js2-node-parent node)))
- (while (not (js2-scope-p parent))
- (setq parent (js2-node-parent parent)))
- parent))
+ (while (and (setq node (js2-node-parent node))
+ (not (js2-scope-p node))))
+ node)
(defun js2-get-defining-scope (scope name &optional point)
"Search up scope chain from SCOPE looking for NAME, a string or symbol.