This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-19
Channels
- # announcements (2)
- # babashka (1)
- # beginners (159)
- # biff (19)
- # clj-http (2)
- # clj-kondo (14)
- # clojure (105)
- # clojure-argentina (1)
- # clojure-art (3)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-spain (1)
- # clojure-spec (3)
- # clojure-uk (26)
- # clojurescript (15)
- # conjure (4)
- # cursive (17)
- # datomic (8)
- # gratitude (1)
- # humbleui (1)
- # hyperfiddle (30)
- # joyride (10)
- # kaocha (1)
- # lsp (41)
- # malli (11)
- # off-topic (1)
- # pedestal (1)
- # polylith (12)
- # releases (1)
- # sci (4)
- # shadow-cljs (136)
- # squint (32)
- # tools-deps (28)
Before opening an issue: would it be feasible to also err when end < start
in the following case?
$ echo '(subs "foo" 1 -1)' | clj-kondo --lint -
<stdin>:1:15: error: Expected: natural integer, received: negative integer.
On cljs the above code works fine: it delegates to js’ String.substring
which swaps the positions when end < start
and rounds any negative position up to 0
and rounds any position > s.length to s.length.
clj errs when start
or end
is outside [0,n]
or when end < start
.
To help writing compatible code, the linter would not only check for type but also emit an error when end < start
.👍 not familiar with clj-kondo design-goals when it comes to clj/cljs-compat, but it could be a warning in cljs?
so if you write a .cljc file, you'd get only a warning if the expression occurs in something that is relevant to clj
since in cljs it's valid to so those negative indexes and it might be on purpose, unless the docstring says it's not ok to do so in cljs