It also returns nil if you use a type byte
as the index, not only for short
.
The reason this happens is that in the method valAt
in Clojure's source file APersistentVector.java, used to look up values in Clojure's PersistentVector class, calls a method isInteger in package clojure.lang.Util to determine whether the index is an integer type or not. That method returns true if its argument is of class java.lang.Integer, java.lang.Long, clojure.lang.BigInt, or java.math.BigInteger, but false for any other types.
I do not know if this is considered a bug, or more likely, a design decision to handle the most common cases (java.lang.Long is the default integer type in Clojure) quickly in this hot code path.