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

var-info.edn: address TBDs #396

Open
vemv opened this issue May 30, 2021 · 1 comment
Open

var-info.edn: address TBDs #396

vemv opened this issue May 30, 2021 · 1 comment

Comments

@vemv
Copy link
Collaborator

vemv commented May 30, 2021

var-info.edn: has various TBDs.

In addition, there's #236 (comment)

  • Review the underlying "DSL"
    • how is it used?
  • Address each item.
@tomdl89
Copy link

tomdl89 commented Nov 6, 2024

I'm currently looking through this file because clj-kondo uses it, and it's leading to some false negatives when linting unused values. For example:

(do (fn [] 1) 2)

doesn't raise any error, because var-info.edn doesn't say anything about fn's purity.

clj-kondo should probably mark things with :pure-if-fn-args-pure true as needing to be used, which would include comp and constantly (which also return functions) but that wouldn't help with fn as that isn't marked as such.

The following macros are marked as :pure-fn true:

clojure.java.jdbc/metadata-query
clojure.core.cache/defcache
clojure.tools.trace/dotrace
clojure.tools.trace/deftrace
clojure.core.async.impl.ioc-macros/gen-plan
clojure.tools.reader/syntax-quote
clojure.core.async.impl.ioc-macros/aset-all!

So I guess marking macros as :pure-fn true is ok? It's not clear to me why these are marked as pure while some macros that seem equally pure are not. Assuming it's just an oversight rather than intentional?

For posterity, here are some other inconsistencies
;; (and pure-fn (false? pure-if-fn-args-pure))
clojure.java.jdbc/metadata-query
clojure.tools.trace/trace-compose-throwable
clojure.tools.trace/clone-throwable
clojure.tools.trace/trace-forms
clojure.tools.trace/trace-form
clojure.tools.trace/trace-special-form
;; (and side-effect pure-if-fn-args-pure)
clojure.core/transduce
clojure.core/run!

@vemv I'd be interested in making a PR to address some inconsistencies, but want to avoid breaking Eastwood things which I don't know about. There may be good reasons for some vars being marked as :pure-fn true vs :pure-if-fn-args-pure true vs not marked on each/both, so want to make sure I understand that first. I'm not sure I even know what a "pure arg" is. For me, purity is a property of a function, so it makes sense for HOFs like run! but it's marked as true for things like simple-ident? which are not HOFs. Again, likely oversights rather than intentional, but I want to get a feel before wading in. Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants