We're updating the issue view to help you get more done. 

into-array fails for sequences starting with nil

Description

The into-array doc string implies that into-array will fall back to an Object array if aseq is supplied, but if the first element of aseq is nil, an NPE occurs.

1 2 3 4 5 6 7 8 9 10 11 user=> (doc into-array) ------------------------- clojure.core/into-array ([aseq] [type aseq]) Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE. user=> (into-array [nil 1 2]) NullPointerException clojure.lang.RT.seqToTypedArray (RT.java:1691)

Approach: Check for nil and use Object as the array type.

Patch: CLJ-1644-array-first-nil-v2.patch

Screened by: Alex Miller

Environment

None

Status

Assignee

Michael Blume

Reporter

Michael Blume

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Priority

Minor