Skip to content

Commit cca6143

Browse files
authored
Fix a bug with seqs in matching clauses of the case macro (#1152)
Fixes #1148
1 parent 50408ec commit cca6143

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Fixed
99
* Fix a bug where `#` characters were not legal in keywords and symbols (#1149)
10+
* Fix a bug where seqs were not considered valid input for matching clauses of the `case` macro (#1148)
1011

1112
## [v0.3.3]
1213
### Added

src/basilisp/core.lpy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3537,7 +3537,7 @@
35373537
(mapcat (fn [pair]
35383538
(let [binding (first pair)
35393539
expr `(fn [] ~(second pair))]
3540-
(if (list? binding)
3540+
(if (seq? binding)
35413541
(map #(vector (list 'quote %) expr) binding)
35423542
[[(list 'quote binding) expr]])))
35433543
(partition 2

tests/basilisp/test_core_macros.lpy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@
316316
(let [l #py [1 2 3]]
317317
(is (= 6 (areduce l idx ret 0 (+ ret (aget l idx)))))))
318318

319+
(defmacro case-with-seq
320+
[]
321+
`(case :val
322+
~(seq [:val]) :found))
323+
319324
(deftest case-test
320325
(is (= "yes" (case :a :b "nope" :c "mega nope" :a "yes" "nerp")))
321326
(is (= "nope" (case :b :b "nope" :c "mega nope" :a "yes" "nerp")))
@@ -328,6 +333,7 @@
328333
(is (= "also no" (case 'd :a "no" (b c d) "also no" "duh")))
329334
(is (= "duh" (case 'e :a "no" (b c d) "also no" "duh")))
330335
(is (= 0 (case 1 0)))
336+
(is (= :found (case-with-seq)))
331337
(let [out* (atom [])]
332338
(is (= 2 (case :2
333339
:1 (do (swap! out* conj 1) 1)

0 commit comments

Comments
 (0)