This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-05
Channels
- # aleph (6)
- # announcements (2)
- # babashka (8)
- # beginners (121)
- # calva (7)
- # cider (7)
- # clj-kondo (25)
- # clojure (167)
- # clojure-android (1)
- # clojure-italy (1)
- # clojure-sweden (1)
- # clojuredesign-podcast (2)
- # clojurescript (11)
- # community-development (33)
- # cursive (23)
- # data-science (1)
- # datascript (11)
- # datomic (7)
- # emacs (12)
- # events (1)
- # fulcro (15)
- # graalvm (3)
- # hoplon (1)
- # instaparse (1)
- # malli (12)
- # off-topic (1)
- # planck (3)
- # re-frame (5)
- # shadow-cljs (61)
- # test-check (2)
i.e. I can see it currently doesn't, but would that be within its capabilities / design scope?
I recently made a typo with a clojure.string function, looked at clj-kondo's types.clojure.string
namespace to see that it hadn't been specced yet, then saw from the clojure.string
source that most functions were already hinted with ^String or ^CharSequence
(defn ^String reverse
"Returns s with its characters reversed."
{:added "1.2"}
[^CharSequence s]
(.toString (.reverse (StringBuilder. s))))
(set! *warn-on-reflection* true)
(defn f1 [])
(defn f2 ^String [])
(defn ^String f3 [])
(fn []
(.length (f1))
(.length (f2))
(.length (f3)))
^ Only f1 gets a reflection warningEven though it's not documented on https://clojure.org/reference/java_interop#typehints
so the type hint on a var also gets used for inferring the return type? if you can confirm that this is correct behavior clj-kondo could adopt this
I posted it on https://ask.clojure.org/index.php/8993/where-to-place-function-return-type-hints
Looks like the answer is yes, tags on function vars can be used to infer the return type
Note that you have to re-run script/extract-var-info after making the change, so the tags will be picked up from the code.
Is there a functionality in clj-kondo IntelliJ IDEA integration to have all warnings and errors listed in IDEA's "Errors box" and then double click certain error/warning and cursor would go to that row in source file?
I really like clj-kondo, good tool!