Clojure

inconsistent destructuring behaviour when using nested maps

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.1, Release 1.2, Release 1.3, Release 1.4, Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    This should happen on any system. I have tested it on macs in version 1.4 and 1.2.1
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

The way destructuring happens should not be affected by the fact that I have the same w at two-levels.
user>> (let [{{a :a b :b :as w} :c a1 :a b1 :b :as w} {:a 10 :b 20 :c {:a 30 :b 40}}] {:a a :b b :b1 b1 :a1 a1})
{:a 30, :b 40, :b1 40, :a1 30} <- unexpected behaviour.....

user>> (let [{{a :a b :b :as w} :c a1 :a b1 :b :as w1} {:a 10 :b 20 :c {:a 30 :b 40}}] {:a a :b b :b1 b1 :a1 a1})
{:a 30, :b 40, :b1 20, :a1 10} <- expected behaviour ..

Even having the :as things from both should not affet how others are destructured.. The email thread talking about the same is here

https://groups.google.com/forum/?fromgroups#!topic/clojure/3z3JtXhcDB0

Activity

Hide
Hubert Iwaniuk added a comment -

Test to reproduce reported issue and code fixing it.

Show
Hubert Iwaniuk added a comment - Test to reproduce reported issue and code fixing it.
Hubert Iwaniuk made changes -
Field Original Value New Value
Attachment CLJ-975-test.patch [ 11071 ]
Hide
Hubert Iwaniuk added a comment -

Test to reproduce and clearly visualise this issue as well as code fixing it included.

Show
Hubert Iwaniuk added a comment - Test to reproduce and clearly visualise this issue as well as code fixing it included.
Hubert Iwaniuk made changes -
Patch Code and Test [ 10002 ]
Hubert Iwaniuk made changes -
Assignee Hubert Iwaniuk [ neotyk ]
Hide
Stuart Halloway added a comment -

A less eye-bleeding example

(let [{{inner :a :as w} :c outer :a :as w}
      {:a 10 :c {:a 30}}]
  outer)
Show
Stuart Halloway added a comment - A less eye-bleeding example
(let [{{inner :a :as w} :c outer :a :as w}
      {:a 10 :c {:a 30}}]
  outer)
Stuart Halloway made changes -
Approval Screened [ 10004 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: