- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19
Fix multiple issues with destructuring #1091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
        
      
    
  
     Merged
                    Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -5806,45 +5806,47 @@ | |
| (:children ddef)) | ||
|  | ||
| kw-binding (fn [arg] | ||
| (let [kw-ns (namespace arg) | ||
| kw-name (name arg) | ||
| sym (symbol kw-name) | ||
| kw (if kw-ns | ||
| (keyword kw-ns kw-name) | ||
| (keyword kw-name)) | ||
| or-binding (get ors sym)] | ||
| (if or-binding | ||
| [sym `(or (get ~fn-arg ~kw) ~or-binding)] | ||
| (let [kw-ns (namespace arg) | ||
| kw-name (name arg) | ||
| sym (symbol kw-name) | ||
| kw (if kw-ns | ||
| (keyword kw-ns kw-name) | ||
| (keyword kw-name))] | ||
| (if (contains? ors sym) | ||
| [sym `(get ~fn-arg ~kw ~(get ors sym))] | ||
| [sym `(get ~fn-arg ~kw)]))) | ||
|  | ||
| map-binding (fn [f arg] | ||
| (let [k (f arg) | ||
| or-binding (get ors arg)] | ||
| (if or-binding | ||
| [arg `(or (get ~fn-arg ~k) ~or-binding)] | ||
| (let [k (f arg)] | ||
| (if (contains? ors arg) | ||
| [arg `(get ~fn-arg ~k ~(get ors arg))] | ||
| [arg `(get ~fn-arg ~k)]))) | ||
|  | ||
| sym-binding (fn [arg] | ||
| (let [sym-name (name arg) | ||
| sym (symbol sym-name) | ||
| or-binding (get ors sym)] | ||
| (if or-binding | ||
| [sym `(or (get ~fn-arg (quote ~arg)) ~or-binding)] | ||
| (let [sym-name (name arg) | ||
| sym (symbol sym-name)] | ||
| (if (contains? ors sym) | ||
| [sym `(get ~fn-arg (quote ~arg) ~(get ors sym))] | ||
| [sym `(get ~fn-arg (quote ~arg))]))) | ||
|  | ||
| named-binding (fn [arg] | ||
| (let [binding (get-in arg [:binding :name]) | ||
| key (:key arg) | ||
| or-binding (get ors binding)] | ||
| (if or-binding | ||
| [binding `(or (get ~fn-arg (quote ~key)) ~or-binding)] | ||
| (let [binding (get-in arg [:binding :name]) | ||
| key (:key arg)] | ||
| (if (contains? ors binding) | ||
| [binding `(get ~fn-arg (quote ~key) ~(get ors binding))] | ||
| [binding `(get ~fn-arg ~key)]))) | ||
|  | ||
| child-binding (fn [child] | ||
| (let [arg (get-in child [:binding :name]) | ||
| k (:key child)] | ||
| [arg `(get ~fn-arg ~k)]))] | ||
| (concat | ||
| [fn-arg | ||
| `(if (seq? ~fn-arg) | ||
| (if (next ~fn-arg) | ||
| (apply hash-map ~fn-arg) | ||
| (first ~fn-arg)) | ||
| ~fn-arg)] | ||
| 
      Comment on lines
    
      +5844
     to 
      +5849
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clojure apparently takes sequences and coerces them to maps for map destructuring or, if the sequence is only a single element, takes the first arg as if it were a map. | ||
| (mapcat kw-binding (:keys ddef)) | ||
| (mapcat (partial map-binding name) (:strs ddef)) | ||
| (mapcat sym-binding (:syms ddef)) | ||
|  | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was another latent bug (for all 4 groups below) where we would not provide the default if it was falsey. For
nilthat likely doesn't matter becausenilis already the default forget, but forfalsethis would make it impossible to override withfalse.