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

clojure.data/diff throws an exception when comparing map keys of different types when used on sorted maps

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects versions: Release 1.8
    • Fix versions: None
    • Labels:
      None

      Description

      e.g.

      (clojure.data/diff (sorted-map :foo 42) (sorted-map 1 42))
      (clojure.data/diff (sorted-map :foo 42) (sorted-map "x" 42))
      (clojure.data/diff (hash-map :foo 42) (sorted-map 1 42))
      (clojure.data/diff (hash-map :foo 42) (sorted-map "x" 42))
      

      will throw
      java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.Keyword
      while e.g.

      (clojure.data/diff (hash-map :foo 42) (hash-map 1 42))
      (clojure.data/diff (hash-map :foo 42) (hash-map "x" 2))
      (clojure.data/diff (sorted-map :foo 42) (sorted-map :bar 42))
      

      will not.

      The same applies to ClojureScript with a different exception (e.g. "Error: Cannot compare :foo to 1")

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tscheibl Thomas Scheiblauer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: