Functions folder and reducer broken for types nil and array + fix for typo


  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test


1. This currently doesn't work:

(->> nil
(r/map identity)
(r/reduce + 0))
; org.mozilla.javascript.JavaScriptException: Error: No protocol method IReduce.-reduce defined for type null

The reason for this is that reducers created by r/reducer or r/folder, invoke -reduce (of IReduce) directly. They thereby bypass the special case for nil in the function r/reduce.

2. An entirely analogous problem exists for collections of type array.

3. The patch CLJS-700 mistakenly defined coll-fold for the type cljs.core/IPersistentVector. This should have been cljs.core/PersistentVector. (There exists no protocol IPersistentVector in ClojureScript.)

I will shortly attach a patch that addresses all of the above problems by implementing IReduce for nil and array. The patch also includes unit tests.

  1. CLJS-736.patch
    29/Dec/13 10:36 AM
    3 kB
    Jonas De Vuyst
  2. CLJS-736-alt.patch
    29/Dec/13 2:22 PM
    5 kB
    Jonas De Vuyst
  3. CLJS-736-patch-1-redux.patch
    31/Dec/13 2:47 AM
    4 kB
    Jonas De Vuyst
  4. CLJS-alt-satisfies.patch
    30/Dec/13 11:24 AM
    5 kB
    Jonas De Vuyst


Jonas De Vuyst made changes -
Field Original Value New Value
Attachment CLJS-736.patch [ 12566 ]
Jonas De Vuyst made changes -
Attachment CLJS-736-alt.patch [ 12567 ]
Jonas De Vuyst made changes -
Attachment CLJS-alt-satisfies.patch [ 12571 ]
Jonas De Vuyst made changes -
Attachment CLJS-736-patch-1-redux.patch [ 12578 ]
David Nolen made changes -
Priority Major [ 3 ] Minor [ 4 ]


Vote (0)
Watch (2)


  • Created: