ClojureScript

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

Details

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

Description

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

Activity

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: