Permalink
Browse files

* src/main/clojure/clojure/core/match/core.clj: MATCH-16: support mat…

…ching empty vector
  • Loading branch information...
1 parent cc2b9b6 commit 9ba924ddd4e8cf9f08d44f2362bf04add1b69ae1 @swannodette swannodette committed Sep 25, 2011
Showing with 12 additions and 4 deletions.
  1. +5 −4 src/main/clojure/clojure/core/match/core.clj
  2. +7 −0 src/test/clojure/clojure/core/match/test/core.clj
@@ -1253,7 +1253,7 @@
(defn emit-patterns
([ps] (emit-patterns ps []))
([ps v]
- (if (nil? ps)
+ (if (empty? ps)
v
(let [p (first ps)]
(cond
@@ -1320,9 +1320,10 @@
(defmethod emit-pattern-for-syntax :seq
[pat]
- (if (empty? pat)
- (literal-pattern ())
- (seq-pattern (emit-patterns (first pat)))))
+ (let [p (first pat)]
+ (if (empty? p)
+ (literal-pattern ())
+ (seq-pattern (emit-patterns p)))))
(defmethod emit-pattern-for-syntax ::vector
[[p t offset-key offset]] (let [ps (emit-patterns p)]
@@ -353,3 +353,10 @@
[a] a
:else :a1))
1)))
+
+(deftest empty-vector-1
+ (is (= (let [v []]
+ (match [v]
+ [[]] 1
+ :else 2))
+ 1)))

0 comments on commit 9ba924d

Please sign in to comment.