Not sure if I'm hitting a bug here or not. I'm getting a warning here for something that is supposed to be always a number and never nil:
WARNING: cljs.core/<=, all arguments must be numbers, got [number #{nil clj-nil}] instead at line 120 /Users/borkdude/dev/edamame/src/edamame/impl/parser.cljc
WARNING: cljs.core/<=, all arguments must be numbers, got [#{nil clj-nil} number] instead at line 120 /Users/borkdude/dev/edamame/src/edamame/impl/parser.cljc
but this local is bound in if-let so it's guaranteed to be never nil. I'll post the whole function in a thread for further inspectionI think it's probably just another instance of the problem, this has been reported for some time, we have a special case for handling protocols, but I am thinking about a more general solution
(defn parse-symbol
"Parses a string into a vector of the namespace and symbol"
[^String token]
(when-not (or (= "" token)
(.endsWith token ":")
(.startsWith token "::"))
(let [ns-idx (.indexOf token "/")]
(if-let [^String ns (and (pos? ns-idx)
(subs token 0 ns-idx))]
(let [ns-idx (inc ns-idx)]
(when-not (== ns-idx (count token))
(let [^String sym (subs token ns-idx)]
(when (not (.endsWith ns ":"))
(if-let [n (when (= 1 #?(:clj (.length sym)
:cljs (.-length sym)))
(try #?(:clj (Integer/parseInt sym)
:cljs (let [x (js/parseInt sym)]
(when-not (NaN? x)
x)))
(catch Exception _ nil)))]
(when (<= 1 n 9)
[ns sym])
(when (and (not (utils/numeric? (nth sym 0)))
;; can't reach here probably?
(not (= "" sym))
(or (= "/" sym )
(== -1 (.indexOf sym "/"))))
[ns sym]))))))
(when (or (= "/" token)
(== -1 (.indexOf token "/")))
[nil token])))))The warning comes from
(when (<= 1 n 9)
[ns sym])Perhaps this? https://clojure.atlassian.net/browse/CLJS-3414 Originally discussed in https://clojurians.slack.com/archives/C03S1L9DN/p1720080756766299
Can't say for sure if this is the exact same case
Slapping a ^js type hint on it helps