Welcome! Please see the About page for a little more info on how this works.

0 votes
in Errors by

With the new :warn-on-boxed (CLJ-1325), these examples do not report a boxed math warning although they each do boxing:

user=> (defn f1 [^long x] (inc x)) f1 user=> (defn f2 [x] (aget (long-array [1 2]) 0)) f2 user=> (defn f3 [x] (aget (int-array [1 2]) 0)) f3 user=> (defn f4 [^String s] (.indexOf s "a"))

Cause: emitBoxReturn has a hard-coded call to box a prim return value.

Solution: If **unchecked-math** is set to :warn-on-boxed, emit a warning on boxing of primitive numeric return types.

Patch:

2 Answers

0 votes
by

Comment made by: alexmiller

Attached patch does the job, but from trying it out on some real code, it finds both problematic cases and lots of cases that could safely be ignored and/or where there is no obvious way to fix the warning. I think it may need some more tuning to reduce the rate of unfixable things a bit.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1585 (reported by alexmiller)
...