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
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)
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.
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.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: