Open vemv opened 3 years ago
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?
@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
var-info.edn: has various TBDs.
In addition, there's https://github.com/jonase/eastwood/issues/236#issuecomment-336291922