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

Map-destructuring :or fumble needs compiler warning

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: Release 1.8, Release 1.5
    • Fix versions: None
    • Patch:
      Code and Test

      Description

      Here is a map-destructuring blunder that I wish the compiler warned about:

      (defn server
        [{servlet ::servlet type ::type :or {::type :jetty} :as service-map}])
      

      It would be splendid to get a warning that :or keys that are not symbols being bound have no effect.

      The incomplete code snippet above comes from Pedestal.service 0.1.0.

      Here is a complete one-line example with the coding error:

      user> (defn picnic [{botulism :botulism :or {:botulism 6}}] botulism) 
      #'user/picnic 
      user> (picnic {}) 
      nil 
      user> ;; I intended 6. 
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: