-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unused variable or function #515
Comments
/Cc @lelit |
I see, thank you for the report: will try to fix the issue as soon as time permits.
|
And on line 82 var4 should have a warning about not beeing initialized. |
@dgutov, about NodeJS raises a ReferenceError for both function foo(a) {
const x = {a, x};
}
function bar() {
const y = z;
const z = 1;
} Should |
@lelit considering that declaring a While we're at it, it would be nice to take care of temporal dead zone for variables declared with |
@lelit, I think so. Unless there's evidence that NodeJS behaves against the spec, which is unlikely. |
Destructured function parameters are not properly recognized.
The above changes seems to cure one half of the reported problem. I wasn't so lucky trying to solve the other half, the undefined reference in the diff --git a/js2-mode.el b/js2-mode.el
index 567d629..0c2e881 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -2314,7 +2314,7 @@ Returns nil if there is no enclosing scope node."
Returns `js2-scope' in which NAME is defined, or nil if not found.
If POINT is non-nil, and if the found declaration type is
-`js2-LET', also check that the declaration node is before POINT."
+`js2-LET' or `js2-CONST', also check that the declaration node is before POINT."
(let ((sym (if (symbolp name)
name
(intern name)))
@@ -2325,7 +2325,7 @@ If POINT is non-nil, and if the found declaration type is
(let ((entry (cdr (assq sym (js2-scope-symbol-table scope)))))
(and entry
(or (not point)
- (not (eq js2-LET (js2-symbol-decl-type entry)))
+ (not (memq (js2-symbol-decl-type entry) (list js2-LET js2-CONST)))
(>= point
(js2-node-abs-pos (js2-symbol-ast-node entry))))))
(and (eq sym 'arguments) but that has not the expected outcome... Will try harder, but maybe you can point me in the right direction :-) |
Please let me know if you prefer splitting that into a separate issue, opening a PR with these changes alone, or if instead it would be better to wait for a fix to the |
I'll open a seperate issue for the missing var4 warning/error. |
If you can test my branch and tell if it effectively cures your case, it would be great! |
Yes, I have tested it a bit now. And it looks like it works. |
Sorry, can't help there. But usually Dmitry is very responsive in releasing bug-fixes :-) |
I consider myself done testing now :) |
Thanks a lot! |
Thank you for fixing the bugs :) |
Merged, thanks for the report. |
3 problems here.
var0
is not used, but there is not warning for that.Variable ’var1’ referenced but never initialized
But it fact it is destructedUnused variable or function ’var2’
even tough it is used 2 times.The text was updated successfully, but these errors were encountered: