Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Major
-
Resolution: Declined
-
Affects Version/s: Release 1.3
-
Fix Version/s: Release 1.5
-
Component/s: None
-
Labels:None
-
Environment:Gentoo GNU/Linux
Description
Using the clojure git head as of 2011-07-14 (commit f704853751d02faf72bd53be599ee0be6c1da63e), int coercion doesn't work:
user> (class (int 1))
java.lang.Long
byte, short, double, and float coercion work fine, though:
user> (class (byte 1))
java.lang.Byte
user> (class (short 1))
java.lang.Short
user> (class (double 1))
java.lang.Double
user> (class (float 1))
java.lang.Float
Also creating integers directly works fine:
user> (class (Integer. "100"))
java.lang.Integer
user> (class (Integer/valueOf 1))
java.lang.Integer
user> (class (Integer. 100))
java.lang.Integer
This is probably related to CLJ-439.
Related documentation here: http://dev.clojure.org/display/doc/Enhanced+Primitive+Support
all long-or-smaller integers are boxed as Long
You can't use primitive coercions to force specific box types
Your code was broken if you were relying on that
So, apparently (int) has the correct behavior. It's byte and short which should be also boxed into Longs