Skip to content
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

Lint "improper" use of :or mapping in map destructuring forms #2459

Open
1 task done
yenda opened this issue Dec 31, 2024 · 0 comments
Open
1 task done

Lint "improper" use of :or mapping in map destructuring forms #2459

yenda opened this issue Dec 31, 2024 · 0 comments

Comments

@yenda
Copy link

yenda commented Dec 31, 2024

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

  • I have read the Clojure etiquette and will respect it when communicating on this platform.

Is your feature request related to a problem? Please describe.
I have encountered in multiple projects issues caused by the developer's expectation that the :or in destructuring behaves lazily like an or, meaning it stops evaluating at the first truthy expression. It actually evals the default value regardless:

user> (defn f1 [] (println "WOW YOU DON'T WANT THIS TO RUN"))
#'user/f1
user> (let [{:keys [x] :or {x (f1)}} {:x 1}] x)
WOW YOU DON'T WANT THIS TO RUN
1

Describe the solution you'd like
I think clj-kondo should mark the use of s-expressions as default value in the :or mapping of map destructuring forms as an error.

@github-project-automation github-project-automation bot moved this to Needs triage in clj-kondo Dec 31, 2024
@borkdude borkdude moved this from Needs triage to High priority (next release) in clj-kondo Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: High priority (next release)
Development

No branches or pull requests

1 participant