Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Non-shadowing desctructuring in an if-let isn't properly recognized #742

Closed
tobias opened this issue Feb 7, 2020 · 1 comment
Closed

Comments

@tobias
Copy link

tobias commented Feb 7, 2020

version

clj-kondo v2020.01.27

platform

Native on MacOS.

editor

N/A

problem

When destructuring is used in an if-let, a binding defined outside of the if-let is considered unused even when it is used in the else branch if the destructuring in the if-let binds the same symbol.

repro

(ns foo)

(defn bar [a] ;; <-- warning: unused binding a
  (if-let [{:keys [a]} nil]
    a
    a))

Linting reports:

/tmp/foo.clj:3:13: warning: unused binding a

expected behavior

I would expect the binding to not be reported as unused, since it is actually used in the else branch.

@borkdude borkdude added the enhancement New feature or request label Feb 7, 2020
@borkdude
Copy link
Member

borkdude commented Feb 7, 2020

Thanks.

@borkdude borkdude added false positive and removed enhancement New feature or request labels Feb 7, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants