You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
quick-lint-js parses the following code incorrectly [1]:
(x => y => { x; y; });
This confuses the linter, leading to false positives:
hello.js:1:14: warning: use of undeclared variable: x [E0057]
Why does this false positive happen? The inner function is sent to the
linter immediately, then the outer function's parameter list is sent to
the linter:
visit_enter_function_scope
visit_variable_declaration // y
visit_enter_function_scope_body
visit_variable_use // x
visit_variable_use // y
visit_exit_function_scope
visit_enter_function_scope
visit_variable_declaration // x
visit_enter_function_scope_body
visit_exit_function_scope
This didn't happen in the past. Commit
8087d21 changed the behavior, causing
arrow functions with statements to be visited immediately, but deferring
visitation for arrow functions with expressions.
Fix the parser to visit arrow functions with expressions immediately
too:
visit_enter_function_scope
visit_variable_declaration // x
visit_enter_function_scope_body
visit_enter_function_scope
visit_variable_declaration // y
visit_enter_function_scope_body
visit_variable_use // x
visit_variable_use // y
visit_exit_function_scope
visit_exit_function_scope
This fixes the false positive.
Cleanup will happen in future commits.
[1] #636
0 commit comments