<< Back to previous view

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

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

Generated at Mon Sep 15 04:37:05 CDT 2014 using JIRA 4.4#649-r158309.