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

0 votes
in core.match by

All three of these expressions should work (according to @dnolen in IRC):

user> (match/match [5] [((:or 5 6) :as x)] x) CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context user> (match/match [5] [(:or (5 :as x) (6 :as x))] x) 5 user> (match/match [5] [(:or (5 :as x) (6 :as y))] x) CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context

(The first makes sense to me, but the latter two don't; e.g. should {{y}} be {{nil}} in the last example, or something else?)

Though it's not necessary, it'd be nice if the following "sugared" form worked, too:

user> (match/match [5] [(:or 5 6 :as x)] x) CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context

3 Answers

0 votes
by

Comment made by: glchapman

Same problem occurs with :guard patterns:

user=> (match/match 1 ((_ :guard odd?) :as n) n :else 0)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: n in this context

0 votes
by

Comment made by: ticking

Some weirdness is also going on with & in vectors.

This is the working vector matching behaviour without &.

(match (link: [1 2 3)]

   (link: ([u v w) :as a)] a)

=> (link: 1 2 3)

And this is the result of adding a rest match.

(match (link: [1 2 3])

   (link: ([h & r) :as a)] a)

=> (link: 1)

Both should be the same.

0 votes
by
Reference: https://clojure.atlassian.net/browse/MATCH-93 (reported by cemerick)
...