Welcome! Please see the About page for a little more info on how this works.

+2 votes
in core.match by

Unless i'm mistaken, it looks like there is some interaction problem between & patterns and :as patterns

(match (link: [:bar :baz)]
(link: ([:bar & r) :as m)] m)
-> (link: :bar)

I'm expecting (link: :bar :baz) here

This is as I expect :
(match (link: [:bar :baz)]
(link: [:bar & r)] :a)
-> :a

This is also as expected :
(match (link: [:bar :baz)]
(link: ([:bar :baz) :as m)] m)
-> (link: :bar :baz)

so & and :as each work on its own.

by
Can confirm the issue still exists in 1.11.1. Also, glchapman's workaround handles it, but I would never have guessed that solution if I hadn't found this ticket.

3 Answers

+1 vote
by

Comment made by: glchapman

Using 1.8, I get the same result. However, changing the match to a seq match produces the correct result:

user=> (match [[:bar :baz]] [(([:bar & r] :seq) :as m)] m) [:bar :baz]

So perhaps the bad interaction is specific to vector patterns.

0 votes
by

Comment made by: carkh

I just tested with clojure 1.7 and get the same results

0 votes
by
Reference: https://clojure.atlassian.net/browse/MATCH-112 (reported by alex+import)
...