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

Reduce broken on some primitive vectors

Description

In some cases, reduce over a sequence from a primitive vector created with vector-of will return incorrect answers:

1 2 3 4 user=> (into [] (drop 32 (into [] (range 33)))) [32] user=> (into [] (drop 32 (into (vector-of :int) (range 33)))) [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32]

Second call should return [32] just like the first one.

Cause: VecSeq (seq on primitive Vec obtained with vector-of) maintains two flags: i is the total number of elements prior to the current node in this seq. offset is the offset in the current anode. When using internal-reduce on a VecSeq, the starting index for the reduce was using offset and ignoring i.

Solution: Use (+ i offset) as the starting index.

Patch: clj-1362-v1.patch

Screened by:

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Release 1.5
Release 1.4
Release 1.3
Release 1.6

Priority

Major