<< Back to previous view

[MATCH-93] Simple capturing of :or matches with :as doesn't work Created: 30/Jan/14  Updated: 12/Apr/15

Status: Open
Project: core.match
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Chas Emerick Assignee: David Nolen
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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


 Comments   
Comment by Greg Chapman [ 10/Sep/14 4:04 PM ]

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

Comment by Jan-Paul Bultmann [ 12/Apr/15 6:14 PM ]

Some weirdness is also going on with `&` in vectors.

This is the working vector matching behaviour without `&`.

(match [[1 2 3]]
[([u v w] :as a)] a)
=> [1 2 3]

And this is the result of adding a rest match.

(match [[1 2 3]]
[([h & r] :as a)] a)
=> [1]

Both should be the same.

Generated at Tue Aug 04 00:35:53 CDT 2015 using JIRA 4.4#649-r158309.