Skip to content

Commit 44d2a0b

Browse files
authored
Fix several small bugs (#599)
Fixes #597 Fixes #598 Two other smaller issues that didn't warrant writing up as issues: * Rename `tests.basilisp.test-edn` and ` tests.basilisp.test-walk` namespaces so they would be correctly picked up for timing info by CircleCI (and just generally to match the patterns used by the other Basilisp tests). * Rename `basilisp.core.template` to `basilisp.template` to match Clojure's organization.
1 parent 96fd7af commit 44d2a0b

File tree

9 files changed

+27
-13
lines changed

9 files changed

+27
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
* Keyword hashes are now pre-computed when they are created, so they do not need to be recomputed again to be fetched from the intern cache (#592)
2121
* The compiler now uses the pre-computed hash to lookup keywords directly, which should improve lookup time for repeated invocations (#592)
2222
* Symbol hashes are now pre-computed when they are created (#592)
23+
* Moved `basilisp.core.template` to `basilisp.template` to match Clojure (#599)
2324

2425
### Fixed
2526
* Fixed a bug where `def` forms did not permit recursive references to the `def`'ed Vars (#578)
2627
* Fixed a bug where `concat` could cause a `RecursionEror` if used on a `LazySeq` instance which itself calls `concat` (#588)
28+
* Fixed a bug where map literals in function reader macro forms caused errors during reading (#599)
29+
* Fixed a bug where `some->` and `some->>` threading macros would thread `nil` first arguments (#599)
2730

2831
### Removed
2932
* Removed `pyfunctional` dependency in favor of Python standard library functions (#589)

src/basilisp/core.lpy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,8 +3345,8 @@
33453345
is nil or there are no more forms."
33463346
[x & forms]
33473347
(if (seq forms)
3348-
`(let [result# (-> ~x ~(first forms))]
3349-
(when-not (nil? result#)
3348+
`(when-not (nil? ~x)
3349+
(let [result# (-> ~x ~(first forms))]
33503350
(some-> result# ~@(next forms))))
33513351
x))
33523352

@@ -3355,8 +3355,8 @@
33553355
is nil or there are no more forms."
33563356
[x & forms]
33573357
(if (seq forms)
3358-
`(let [result# (->> ~x ~(first forms))]
3359-
(when-not (nil? result#)
3358+
`(when-not (nil? ~x)
3359+
(let [result# (->> ~x ~(first forms))]
33603360
(some->> result# ~@(next forms))))
33613361
x))
33623362

src/basilisp/lang/reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ def _walk(inner_f, outer_f, form):
951951
elif isinstance(form, IPersistentVector):
952952
return outer_f(vector.vector(map(inner_f, form)))
953953
elif isinstance(form, IPersistentMap):
954-
return outer_f(lmap.from_entries(map(inner_f, form)))
954+
return outer_f(lmap.hash_map(*chain.from_iterable(map(inner_f, form.seq()))))
955955
elif isinstance(form, IPersistentSet):
956956
return outer_f(lset.set(map(inner_f, form)))
957957
else:

src/basilisp/core/template.lpy renamed to src/basilisp/template.lpy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(ns basilisp.core.template
1+
(ns basilisp.template
22
(:require
33
[basilisp.walk :refer [postwalk-replace]]))
44

src/basilisp/test.lpy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(:import
33
inspect)
44
(:require
5-
[basilisp.core.template :as template]))
5+
[basilisp.template :as template]))
66

77
(def ^:private current-test-number
88
(atom 0))

tests/basilisp/reader_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,13 @@ def test_function_reader_macro():
11571157
),
11581158
llist.l(sym.symbol("identity"), sym.symbol("arg-3"), sym.symbol("arg-rest")),
11591159
)
1160+
assert read_str_first("#(identity {:arg %})") == llist.l(
1161+
sym.symbol("fn*"),
1162+
vec.v(sym.symbol("arg-1"),),
1163+
llist.l(
1164+
sym.symbol("identity"), lmap.map({kw.keyword("arg"): sym.symbol("arg-1")})
1165+
),
1166+
)
11601167

11611168
with pytest.raises(reader.SyntaxError):
11621169
read_str_first("#(identity #(%1 %2))")

tests/basilisp/test_core_macros.lpy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,18 +563,22 @@
563563
(is (= 2 (some-> 1 inc)))
564564
(is (= 1 (some-> 1 inc dec)))
565565
(is (= 4 (some-> 10 inc (- 7))))
566+
(is (= "the-key" (some-> (:key {:key :the-key}) (name))))
566567

567568
(is (= nil (some-> {:a 3} :b inc)))
568-
(is (= 4 (some-> {:a 3} :a inc))))
569+
(is (= 4 (some-> {:a 3} :a inc)))
570+
(is (= nil (some-> (:key {}) (name)))))
569571

570572
(deftest some->>-test
571573
(is (= :a (some->> :a)))
572574
(is (= 2 (some->> 1 inc)))
573575
(is (= 1 (some->> 1 inc dec)))
574576
(is (= -4 (some->> 10 inc (- 7))))
577+
(is (= "the-key" (some->> (:key {:key :the-key}) (name))))
575578

576579
(is (= nil (some->> {:a 3} :b (- 7))))
577-
(is (= 5 (some->> {:a 3} :a (- 8)))))
580+
(is (= 5 (some->> {:a 3} :a (- 8))))
581+
(is (= nil (some->> (:key {}) (name)))))
578582

579583
(deftest cond->-test
580584
(is (= 1 (cond-> 1)))

tests/basilisp/test_edn.lpy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(ns basilisp.test-edn
1+
(ns tests.basilisp.test-edn
22
(:require
33
[basilisp.edn :as edn]
44
[basilisp.test :refer [deftest are is testing]]))

tests/basilisp/test_walk.lpy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(ns tests.basilisp.walk-test
1+
(ns tests.basilisp.test-walk
22
(:require
33
[basilisp.test :refer [deftest is testing]]
44
[basilisp.walk :as walk]))
@@ -104,9 +104,9 @@
104104
`(pl ~c1 (minus ~c1 ~c2)))
105105

106106
(deftest macroexpand-all-test
107-
(is (= '(tests.basilisp.walk-test/pl 20 (tests.basilisp.walk-test/minus 20 30))
107+
(is (= '(tests.basilisp.test-walk/pl 20 (tests.basilisp.test-walk/minus 20 30))
108108
(macroexpand-1 '(calc 20 30))))
109-
(is (= '(basilisp.core/+ 20 (tests.basilisp.walk-test/minus 20 30))
109+
(is (= '(basilisp.core/+ 20 (tests.basilisp.test-walk/minus 20 30))
110110
(macroexpand '(calc 20 30))))
111111
(is (= '(basilisp.core/+ 20 (basilisp.core/- 20 30))
112112
(walk/macroexpand-all '(calc 20 30)))))

0 commit comments

Comments
 (0)