greglook / clj-cbor

Native Clojure CBOR codec implementation.
The Unlicense
70 stars 7 forks source link

Decoder unpredictably returns non-Long types when decoding integers #4

Closed aengelberg closed 7 years ago

aengelberg commented 7 years ago
user=> (into {} (map (juxt identity (comp type first cbor/decode cbor/encode))) [0 1 23 24 255 256 65535 65536 1000000 (inc' Long/MAX_VALUE)])
{0 #class java.lang.Long,
 1 #class java.lang.Long,
 23 #class java.lang.Long,
 24 #class java.lang.Integer,
 255 #class java.lang.Integer,
 256 #class java.lang.Integer,
 65535 #class java.lang.Integer,
 65536 #class java.lang.Long,
 1000000 #class java.lang.Long,
 9223372036854775808N #class clojure.lang.BigInt}

Similarly, if a tagged CBOR type wraps an integer, its read handler may receive either an Integer, Long, or BigInt.