This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-18
Channels
- # announcements (8)
- # aws (5)
- # babashka (69)
- # beginners (37)
- # calva (222)
- # cider (10)
- # clj-commons (8)
- # clj-kondo (69)
- # cljdoc (5)
- # clojure (62)
- # clojure-dev (23)
- # clojure-europe (37)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-sg (6)
- # clojure-uk (5)
- # clojurescript (25)
- # clojureverse-ops (12)
- # conjure (1)
- # cursive (1)
- # fulcro (9)
- # gorilla (1)
- # graalvm (6)
- # graphql (1)
- # gratitude (1)
- # honeysql (7)
- # introduce-yourself (4)
- # jobs (1)
- # kaocha (9)
- # keyboards (4)
- # leiningen (8)
- # lsp (21)
- # malli (9)
- # music (3)
- # nextjournal (17)
- # nrepl (6)
- # off-topic (10)
- # pathom (12)
- # portal (25)
- # reagent (8)
- # releases (1)
- # specter (1)
- # xtdb (1)
Before I raise an issue, thought I’d check here to see if this is now expected behaviour. I was reviewing clj-kondo dev docs and it has this example:
$ clojure -M:clj-kondo/dev --lint - <<< "(defn foo [x] (if-let [x 1] x x x))"
<stdin>:1:15: error: if-let body requires one or two forms
linting took 73ms, errors: 1, warnings: 0
But if I run this today, I get no warnings:
❯ clojure -M:clj-kondo/dev --lint - <<< "(defn foo [x] (if-let [x 1] x x x))"
linting took 115ms, errors: 0, warnings: 0
Retry with current version of clj-kondo:
❯ clj-kondo --lint - <<< "(defn foo [x] (if-let [x 1] x x x))"
linting took 50ms, errors: 0, warnings: 0
Issue welcome. Could be nice to bisect to which clj-kondo version this changed and to see what caused it
borkdude@MBP2019 /tmp $ clojure -Sdeps '{:deps {clj-kondo/clj-kondo {:mvn/version "2020.03.20"}}}' -M -m clj-kondo.main --lint - <<< "(defn foo [x] (if-let [x 1] x x x))"
<stdin>:1:15: error: if-let body requires one or two forms
linting took 171ms, errors: 1, warnings: 0
borkdude@MBP2019 /tmp $ clojure -Sdeps '{:deps {clj-kondo/clj-kondo {:mvn/version "2020.04.05"}}}' -M -m clj-kondo.main --lint - <<< "(defn foo [x] (if-let [x 1] x x x))"
linting took 71ms, errors: 0, warnings: 0
perhaps related: https://github.com/clj-kondo/clj-kondo/commit/935d70c7a718f7dc6c449e540f38faf87fd4bd10
Raised the issue: https://github.com/clj-kondo/clj-kondo/issues/1426
I guess it doesn't report it because of this: https://github.com/clojure/clojure/blob/b8132f92f3c3862aa6cdd8a72e4e74802a63f673/src/clj/clojure/core.clj#L1853
So it looks like they allowed for more args to support better assert errors? Or maybe some backward compat since it is called oldform
?
There is some low hanging fruit to move the override thing to a different place which prevents us from doing this at runtime each time
@UE21H2HHD did you know you can write jet --query ':foo :bar :baz'
? :)
I shall also raise one more issue. Not sure if you’ll want to it fixed. For, what seem to me obscure, signatures of defn and defmacro, there can be an optional 2nd attr-map, which clj-kondo currently ignores.
(defn name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?)
(defmacro name doc-string? attr-map? ([params*] body) + attr-map?)
actually SCI does support it, let me look up the issue of why I supported it, it was because of some lib
dang, no context: https://github.com/borkdude/sci/issues/567
Ok, maybe I’ll raise the issue, and your grasp results can be a good enough reason to close it. Documentation of why we don’t do it, in case it crops up again. Or grasp might tell us we should do it.
I'm grasping like this:
(ns trailing-meta)
(require
'[clojure.core.specs.alpha :as specs]
'[clojure.spec.alpha :as s]
'[grasp.api :as g])
(s/def ::defn (s/cat :defn #{'defn} :args ::specs/defn-args))
(s/def ::defn-trailing-attr-map (s/and ::defn (fn [conformed]
(->> conformed
:args :fn-tail second :attr-map))))
(def matches (g/grasp "/Users/borkdude/.m2" ::defn-trailing-attr-map))
;; (prn (s/conform ::defn-trailing-attr-map (first matches)))
(run! (fn [match]
(print (meta meta) " " match)
(println)) matches)
Oh. You might curse me. Because it might kind of work already.
clojure -M:clj-kondo/dev --config '{:config-paths ^:replace [] :output {:format :edn :analysis {:var-definitions {:meta true}}}}' \
--lint - <<< '(defn x ([]) {:doc "attr-map2"})' \
| jet --query ':analysis :var-definitions first' --pretty
{:fixed-arities #{0},
:end-row 1,
:meta {:doc "attr-map2"},
:name-end-col 8,
:name-end-row 1,
:name-row 1,
:ns user,
:name x,
:defined-by clojure.core/defn,
:filename "<stdin>",
:col 1,
:name-col 7,
:end-col 33,
:doc "attr-map2",
:row 1}
Might be just the merge order that is broken when multiple specified? I’ll do more tests.Ok there is something amiss certainly with :doc
derivation from this source but we already have an issue for that.
And I think the new :meta
analysis might not merge the 2nd attr-map properly if at all. Soo… I do have a small bit of work here.
> {:line 272, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}
{:line 272, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}
{:line 312, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}
{:line 372, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}
{:line 390, :column 1, :url "jar:file:/Users/borkdude/.m2/repository/com/grammarly/omniconf/0.4.3/omniconf-0.4.3.jar!/omniconf/core.clj"}