This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-02
Channels
- # aleph (3)
- # announcements (2)
- # babashka (4)
- # beginners (74)
- # calva (21)
- # clj-kondo (30)
- # cljs-dev (7)
- # cljsrn (42)
- # clojure (121)
- # clojure-dev (13)
- # clojure-europe (23)
- # clojure-losangeles (2)
- # clojure-nl (2)
- # clojure-norway (7)
- # clojure-spec (140)
- # clojure-uk (58)
- # clojuredesign-podcast (9)
- # clojurescript (49)
- # clojutre (2)
- # cursive (32)
- # datascript (2)
- # datomic (59)
- # duct (7)
- # figwheel-main (6)
- # fulcro (18)
- # graphql (5)
- # jackdaw (1)
- # joker (6)
- # juxt (7)
- # leiningen (9)
- # off-topic (1)
- # pedestal (14)
- # quil (2)
- # re-frame (3)
- # reitit (8)
- # shadow-cljs (78)
- # sql (8)
- # timbre (3)
- # vim (69)
I feel I’m starting to somewhat understand the type checking. What’s the reason to keep :seqable-out
separate from :seqable
, though?
@borkdude could you please release a new version? I want to update to the latest but the false positives on types for partition and conj are stopping me.
@mynomoto There's one last bit I want to tweak about a new linter and then I'll release
The challenge with the new unused-private-var linter is that some private fns defined in .cljc/.cljs may be used in .cljs/.cljc, so it's not just a matter of checking all defs/calls in one file
I guess joker also just does that, since it lints one file at a time. So maybe it would be OK if you could exclude certain private fns from being reported
@hannu.hartikainen The reason for seqable-out is that I want to exclude nil and string that are normally seqable. So you should not rely on a seqable-out function to be able to produce nil or a string
@borkdude good to know. There’s already a bug with next
and the functions that use it, then 🙂
since you might have an argument type where nil could be a valid value and then seqable would match, while the non-nilable variant of that type could not be a seqable at all
it’s just that next
can return nil
I don't think that will lead to a false positive in practice. Excluding string is probably the most pressing reason, to still be able to output errors like:
$ clj -A:clj-kondo --lint - <<< '(defn foo [^String _x]) (foo (next [1 2 3]))'
<stdin>:1:30: warning: Expected: string or nil, received: seqable collection.
it sounds a bit confusing I know, but I think starting with a false positive is better than just changing it
a seqable-out is a seqable and when you call next you expect a seqable back, so that mostly works. there aren't any functions expecting explicitly a nil value.
yes, that’s absolutely true
but when in the future someone extends the type system to give warnings of missing nil checks, that wrong type will cause false negatives
so it’s not very worrying but I’ll change to :nilable/seqable-out
someday… not today though
I guess making seqable-out contain nil will probably work out everywhere btw, but not doing that has probably the same effect in terms of linting, since there are no functions requiring an explicit nil anywhere
but turning next into seqable -> seqable (instead of seqable-out) will stop this from warning:
clj -A:clj-kondo --lint - <<< '(defn foo [^String _x]) (foo (next [1 2 3]))'
linting took 82ms, errors: 0, warnings: 0
Just tried that. So let's forget about what I said about nil, seqable-out is about excluding strings.There is more to this "type system" that's not always telling the truth for a 100%, but it's made with linting in mind. Like:
$ clj -A:clj-kondo --lint - <<< '(reduce 1 1 1)'
<stdin>:1:9: warning: Expected: function, received: positive integer.
<stdin>:1:13: warning: Expected: seqable collection, received: positive integer.
Actually reduce expects a reducible, not a seqable. But in practice this works well enough so far.@mynomoto if you want to use the latest, you can do that and turn the type checking off like any other linter. or override the types for problematic functions in your config. like so: https://github.com/borkdude/clj-kondo/issues/470
@mynomoto oh, and if I can make you happy with a binary from master, I think you were using linux right? https://6255-176829714-gh.circle-artifacts.com/0/release/clj-kondo-2019.09.23-alpha-SNAPSHOT-linux-amd64.zip
@borkdude I will try it thanks, but to run on ci I need a proper release. I'm happy to wait, if I do configuration to ignore something it tends to be forgotten 😕