You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read the Clojure etiquette and will respect it when communicating on this platform.
Is your feature request related to a problem? Please describe.
Currently the following error appears for (subs "012" 1 -1):
$ echo '(subs "012" 1 -1)' | clj-kondo --lint -
:1:15: error: Expected: natural integer, received: negative integer.
On cljs this code works fine though (ie it yields "0") because it delegates to Javascript's String.substring which swaps the start and end arguments when end < start and rounds any negative position up to 0 and rounds any position > s.length to s.length. So for this example it's equivalent to (subs "012" 0 1).
In clj when either start or end are not in [0, n] an exception is thrown. Same when end < start.
Describe the solution you'd like
Make the linter (more) in line with the clj behavior:
emit when end < start
emit when either start or end are not in [0, n]
Not sure how viable option 2 is.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Currently the following error appears for
(subs "012" 1 -1)
:$ echo '(subs "012" 1 -1)' | clj-kondo --lint -
:1:15: error: Expected: natural integer, received: negative integer.
On cljs this code works fine though (ie it yields
"0"
) because it delegates to Javascript'sString.substring
which swaps thestart
andend
arguments whenend
<start
and rounds any negative position up to 0 and rounds any position > s.length to s.length. So for this example it's equivalent to(subs "012" 0 1)
.In clj when either
start
orend
are not in[0, n]
an exception is thrown. Same whenend < start
.Describe the solution you'd like
Make the linter (more) in line with the clj behavior:
start
orend
are not in[0, n]
Not sure how viable option 2 is.
The text was updated successfully, but these errors were encountered: