Skip to content

Commit 0ec3870

Browse files
committed
CLJS-2838: [spec] s/& does not check preds if regex matches empty collection
1 parent c40a475 commit 0ec3870

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/cljs/cljs/spec/alpha.cljs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,8 @@
10121012
::accept true
10131013
nil nil
10141014
::amp (c/and (accept-nil? p1)
1015-
(c/or (noret? p1 (preturn p1))
1016-
(let [ret (-> (preturn p1) (and-preds ps (next forms)))]
1017-
(not (invalid? ret)))))
1015+
(let [ret (-> (preturn p1) (and-preds ps (next forms)))]
1016+
(not (invalid? ret))))
10181017
::rep (c/or (identical? p1 p2) (accept-nil? p1))
10191018
::pcat (every? accept-nil? ps)
10201019
::alt (c/some accept-nil? ps))))

src/test/cljs/cljs/spec_test.cljs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
plus (s/+ keyword?)
127127
opt (s/? keyword?)
128128
andre (s/& (s/* keyword?) even-count?)
129+
andre2 (s/& (s/* keyword?) #{[:a]})
129130
m (s/map-of keyword? string?)
130131
mkeys (s/map-of (s/and keyword? (s/conformer name)) any?)
131132
mkeys2 (s/map-of (s/and keyword? (s/conformer name)) any? :conform-keys true)
@@ -216,6 +217,10 @@
216217
andre [:k] ::s/invalid '[{:pred cljs.spec-test/even-count?, :val [:k]}]
217218
andre [:j :k] [:j :k] nil
218219

220+
andre2 nil ::s/invalid [{:pred #{[:a]}, :val []}]
221+
andre2 [] ::s/invalid [{:pred #{[:a]}, :val []}]
222+
andre2 [:a] [:a] nil
223+
219224
m nil ::s/invalid '[{:pred cljs.core/map?, :val nil}]
220225
m {} {} nil
221226
m {:a "b"} {:a "b"} nil

0 commit comments

Comments
 (0)