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

Correctly analyse recur arity in dosync block #1081

Closed
yuhan0 opened this issue Nov 27, 2020 · 0 comments
Closed

Correctly analyse recur arity in dosync block #1081

yuhan0 opened this issue Nov 27, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@yuhan0
Copy link
Contributor

yuhan0 commented Nov 27, 2020

version
clj-kondo v2020.11.07

platform
native

editor
Emacs, flycheck

problem
dosync blocks wrap their body in a (fn [], causing calls to recur to jump there instead of the outer loop/fn form.
clj-kondo does not take this into account and analyses the arity of the outer form.

repro

(ns repro)
(defn foo [_a _b]
  (dosync
    (recur)))

output:

repro.clj:4:5: error: recur argument count mismatch (expected 2, got 0)
linting took 13ms, errors: 1, warnings: 2

config
not related

expected behavior
dosync blocks should be analysed with a ctx of {:recur-arity 0}

Additional context: calling macroexpand on the dosync block produces:

(defn foo [a b]
  (. clojure.lang.LockingTransaction
    (clojure.core/runInTransaction
      (fn [] (recur)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants