Uploaded image for project: 'Clojure'
  1. CLJ-1612

clojure.core.reducers/mapcat can call f1 with undefined arity of 0 arguments?

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: Release 1.7, Release 1.6
    • Fix versions: None
    • Labels:

      Description

      I have not run across this with running code, so perhaps it is impossible for reasons I have not understood. Also not sure whether fixing issues with reducers is of any importance, given transducers. This was found while testing the Eastwood lint tool on some Clojure namespaces, including clojure.core.reducers.

      (defcurried mapcat
        "Applies f to every value in the reduction of coll, concatenating the result
        colls of (f val). Foldable."
        {:added "1.5"}
        [f coll]
        (folder coll
         (fn [f1]
           (let [f1 (fn
                      ([ret v]
                        (let [x (f1 ret v)] (if (reduced? x) (reduced x) x)))
                      ([ret k v]
                        (let [x (f1 ret k v)] (if (reduced? x) (reduced x) x))))]
             (rfn [f1 k]
                  ([ret k v]
                     (reduce f1 ret (f k v))))))))
      

      The definition of macro rfn expands to a (fn ...) that can call f1 with no arguments, which is not a defined arity for f1.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jafingerhut Andy Fingerhut
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: