PersistentList/creator doesn't handle ArraySeqs correctly

Description

This should return '(2 3) but returns '(1 2 3) instead:

user=> ((fn [& args] (apply (fn [a & b] (println a b) (apply list b)) args)) 1 2 3) 1 (2 3) (1 2 3)

Note that using vector rather than list returns the correct values:

user=> ((fn [& args] (apply (fn [a & b] (println a b) (apply vector b)) args)) 1 2 3) 1 (2 3) [2 3]

The bug was reported in this stackoverflow question: https://stackoverflow.com/questions/27819418/strange-behaviour-of-clojure-trampoline and the bug identified in this comment: https://stackoverflow.com/questions/27819418/strange-behaviour-of-clojure-trampoline#comments-27821793

A simpler example of this bug:

user=> (apply list (next (clojure.lang.ArraySeq/create (object-array [1 2 3])))) (1 2 3)

Patch: CLJ-1633-v3.patch

Environment

None

Attachments

5
  • 08 Jan 2015, 07:55 PM
  • 07 Jan 2015, 11:42 PM
  • 07 Jan 2015, 11:03 PM
  • 07 Jan 2015, 10:59 PM
  • 07 Jan 2015, 05:29 PM

Activity

Show:

Alex Miller January 10, 2015 at 12:22 AM

Stu, doesn't look like this patch was applied but it was closed?

Nicola Mometto January 9, 2015 at 11:51 PM

This ticket has been closed but no patch has been committed

Alex Miller January 9, 2015 at 3:12 PM

Rich said to move this forward.

Michael Blume January 7, 2015 at 11:42 PM

Ok, this is kind of crude, and mostly a proof of concept, but this does catch the bug.

Output:

[java] FAIL in (seq-gentest) (sequences.clj:105) [java] {:acts1 (-> [] next (->> (cons :foo)) (->> (cons :foo)) next), [java] :acts2 [java] (-> [java] [] [java] next [java] (->> (cons :foo)) [java] (->> (cons :foo)) [java] into-array-seq [java] next [java] (->> (apply list))), [java] :result1 (:foo), [java] :result2 (:foo :foo), [java] :pass false} [java] [java] expected: (:result res) [java] actual: false

Michael Blume January 7, 2015 at 11:40 PM

No problem =)

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Fix versions

Created January 7, 2015 at 5:24 PM
Updated January 10, 2015 at 3:24 PM
Resolved January 10, 2015 at 3:24 PM