Skip to content

Commit

Permalink
Fix several small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisrink10 committed Jul 3, 2020
1 parent 96fd7af commit 08c6fc0
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* 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)
* The compiler now uses the pre-computed hash to lookup keywords directly, which should improve lookup time for repeated invocations (#592)
* Symbol hashes are now pre-computed when they are created (#592)
* Moved `basilisp.core.template` to `basilisp.template` to match Clojure (#599)

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

### Removed
* Removed `pyfunctional` dependency in favor of Python standard library functions (#589)
Expand Down
8 changes: 4 additions & 4 deletions src/basilisp/core.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -3345,8 +3345,8 @@
is nil or there are no more forms."
[x & forms]
(if (seq forms)
`(let [result# (-> ~x ~(first forms))]
(when-not (nil? result#)
`(when-not (nil? ~x)
(let [result# (-> ~x ~(first forms))]
(some-> result# ~@(next forms))))
x))

Expand All @@ -3355,8 +3355,8 @@
is nil or there are no more forms."
[x & forms]
(if (seq forms)
`(let [result# (->> ~x ~(first forms))]
(when-not (nil? result#)
`(when-not (nil? ~x)
(let [result# (->> ~x ~(first forms))]
(some->> result# ~@(next forms))))
x))

Expand Down
2 changes: 1 addition & 1 deletion src/basilisp/lang/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ def _walk(inner_f, outer_f, form):
elif isinstance(form, IPersistentVector):
return outer_f(vector.vector(map(inner_f, form)))
elif isinstance(form, IPersistentMap):
return outer_f(lmap.from_entries(map(inner_f, form)))
return outer_f(lmap.hash_map(*chain.from_iterable(map(inner_f, form.seq()))))
elif isinstance(form, IPersistentSet):
return outer_f(lset.set(map(inner_f, form)))
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns basilisp.core.template
(ns basilisp.template
(:require
[basilisp.walk :refer [postwalk-replace]]))

Expand Down
2 changes: 1 addition & 1 deletion src/basilisp/test.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:import
inspect)
(:require
[basilisp.core.template :as template]))
[basilisp.template :as template]))

(def ^:private current-test-number
(atom 0))
Expand Down
7 changes: 7 additions & 0 deletions tests/basilisp/reader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,13 @@ def test_function_reader_macro():
),
llist.l(sym.symbol("identity"), sym.symbol("arg-3"), sym.symbol("arg-rest")),
)
assert read_str_first("#(identity {:arg %})") == llist.l(
sym.symbol("fn*"),
vec.v(sym.symbol("arg-1"),),
llist.l(
sym.symbol("identity"), lmap.map({kw.keyword("arg"): sym.symbol("arg-1")})
),
)

with pytest.raises(reader.SyntaxError):
read_str_first("#(identity #(%1 %2))")
Expand Down
8 changes: 6 additions & 2 deletions tests/basilisp/test_core_macros.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -563,18 +563,22 @@
(is (= 2 (some-> 1 inc)))
(is (= 1 (some-> 1 inc dec)))
(is (= 4 (some-> 10 inc (- 7))))
(is (= "the-key" (some-> (:key {:key :the-key}) (name))))

(is (= nil (some-> {:a 3} :b inc)))
(is (= 4 (some-> {:a 3} :a inc))))
(is (= 4 (some-> {:a 3} :a inc)))
(is (= nil (some-> (:key {}) (name)))))

(deftest some->>-test
(is (= :a (some->> :a)))
(is (= 2 (some->> 1 inc)))
(is (= 1 (some->> 1 inc dec)))
(is (= -4 (some->> 10 inc (- 7))))
(is (= "the-key" (some->> (:key {:key :the-key}) (name))))

(is (= nil (some->> {:a 3} :b (- 7))))
(is (= 5 (some->> {:a 3} :a (- 8)))))
(is (= 5 (some->> {:a 3} :a (- 8))))
(is (= nil (some->> (:key {}) (name)))))

(deftest cond->-test
(is (= 1 (cond-> 1)))
Expand Down
2 changes: 1 addition & 1 deletion tests/basilisp/test_edn.lpy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns basilisp.test-edn
(ns tests.basilisp.test-edn
(:require
[basilisp.edn :as edn]
[basilisp.test :refer [deftest are is testing]]))
Expand Down
6 changes: 3 additions & 3 deletions tests/basilisp/test_walk.lpy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns tests.basilisp.walk-test
(ns tests.basilisp.test-walk
(:require
[basilisp.test :refer [deftest is testing]]
[basilisp.walk :as walk]))
Expand Down Expand Up @@ -104,9 +104,9 @@
`(pl ~c1 (minus ~c1 ~c2)))

(deftest macroexpand-all-test
(is (= '(tests.basilisp.walk-test/pl 20 (tests.basilisp.walk-test/minus 20 30))
(is (= '(tests.basilisp.test-walk/pl 20 (tests.basilisp.test-walk/minus 20 30))
(macroexpand-1 '(calc 20 30))))
(is (= '(basilisp.core/+ 20 (tests.basilisp.walk-test/minus 20 30))
(is (= '(basilisp.core/+ 20 (tests.basilisp.test-walk/minus 20 30))
(macroexpand '(calc 20 30))))
(is (= '(basilisp.core/+ 20 (basilisp.core/- 20 30))
(walk/macroexpand-all '(calc 20 30)))))

0 comments on commit 08c6fc0

Please sign in to comment.