Skip to content

Commit 174d5ff

Browse files
authored
Fix issue with concat on maps returning keys instead of key/values (#872)
Hi, could you please consider patch to have `concat` on maps return k/v pairs instead of keys. It fixes #871. The issue as I understand it that the underlying map library iterates over keys rather than k/v pairs, and thus it needs to be converted first to a sequence (which correctly converts map into a seq of pairs). Thanks --------- Co-authored-by: ikappaki <[email protected]>
1 parent 85035c1 commit 174d5ff

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
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
* Fix a bug where the function returned by `partial` retained the meta, arities, and `with_meta` method of the wrapped function rather than creating new ones (#847)
2626
* Fix a bug where exceptions arising while reading reader conditional forms did not include line and column information (#854)
2727
* Fix a bug where names `def`'ed without reader metadata would cause the compiler to throw an exception (#850)
28+
* Fix an issue where `concat` on maps was iterating over the keys instead of the key/value pairs (#871)
2829

2930
## [v0.1.0b1]
3031
### Added

src/basilisp/lang/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ def cons(o, seq) -> ISeq:
10731073

10741074
def concat(*seqs: Any) -> ISeq:
10751075
"""Concatenate the sequences given by seqs into a single ISeq."""
1076-
return lseq.sequence(itertools.chain.from_iterable(filter(None, seqs)))
1076+
return lseq.sequence(itertools.chain.from_iterable(filter(None, map(to_seq, seqs))))
10771077

10781078

10791079
def apply(f, args):

tests/basilisp/runtime_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ def test_concat():
247247
s1 = runtime.concat(llist.l(1, 2, 3), vec.v(4, 5, 6))
248248
assert s1 == llist.l(1, 2, 3, 4, 5, 6)
249249

250+
s1 = runtime.concat(lmap.map({"a": 1}), lmap.map({"b": 2}))
251+
assert s1 == llist.l(vec.v("a", 1), vec.v("b", 2))
252+
253+
s1 = runtime.concat(vec.v(1, 2), None, "ab")
254+
assert s1 == llist.l(1, 2, "a", "b")
255+
250256

251257
def test_apply():
252258
assert vec.v() == runtime.apply(vec.v, [[]])

0 commit comments

Comments
 (0)