Fork me on GitHub
#core-typed
<
2024-04-09
>
TJ Campanella15:04:51

This code is producing an error in the type checker. Seems to have to do with the Math/abs call.

(t/ann foo [t/Int :-> t/Str])
(defn foo [cents]
  (str (Math/abs cents)))
Execution error (AssertionError) at typed.cljc.checker.check.utils/Type->Class (utils.clj:495). Assert failed: (r/Type? t) Is there something wrong with the code or does it look like a bug?

TJ Campanella15:04:48

Seems clojure's abs function works but not Math/abs

ambrosebs15:04:23

Looks like a bug.

ambrosebs15:04:52

But you probably need to add a type hint for it to type check.

ambrosebs15:04:22

That might circumvent the bug.

ambrosebs15:04:24

If it fixes it, please file a report. And yes, clojure.core/abs is better here.