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

[spec] Nesting cat inside ? causes unform to return nested result

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects versions: Release 1.9
    • Fix versions: Release 1.11
    • Labels:
    • Approval:
      Vetted
    • Patch:
      Code and Test

      Description

      Calling conform and then unform with a spec that consists of some cat nested inside of some ? creates an extra level of nesting in the result:

      (require '[clojure.spec :as s])
      
      (let [spec (s/? (s/cat :foo #{:foo}))
            initial [:foo]
            conformed (s/conform spec initial)
            unformed (s/unform spec conformed)]
        [initial conformed unformed])
      ;;=> [[:foo] {:foo :foo} [(:foo)]]
      

      This behavior does not occur with just ? or cat alone:

      (let [spec (s/? #{:foo})]
        (s/unform spec (s/conform spec [:foo])))
      ;;=> [:foo]
      
      (let [spec (s/cat :foo #{:foo})]
        (s/unform spec (s/conform spec [:foo])))
      ;;=> (:foo)
      

      Patch: CLJ-2003-corrected.patch

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              6 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: