Skip to content

Commit

Permalink
Fix #575: map? should not return true for array (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored Nov 19, 2024
1 parent bb7596f commit 98c925b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## v0.8.125 (2024-11-19)

- Fix [#575](https://github.com/squint-cljs/squint/issues/575): `map?` should not return `true` for array
- Fix [#577](https://github.com/squint-cljs/squint/issues/577): support `$default` + `:refer`

## v0.8.124 (2024-11-08)
Expand Down
7 changes: 5 additions & 2 deletions src/squint/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2112,8 +2112,11 @@ export function min(x, y, ...more) {
return Math.min(x, y, ...more);
}

export function map_QMARK_(x) {
return x instanceof Object;
export function map_QMARK_(coll) {
if (coll == null) return false;
if (isObj(coll)) return true;
if (coll instanceof Map) return true;
return false;
}

export function every_pred(...preds) {
Expand Down
4 changes: 4 additions & 0 deletions test/squint/compiler_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2304,5 +2304,9 @@ new Foo();")
(is (eq [0 2 1 2 1]
(jsv! "(def a (atom 0)) (def x (delay (do (swap! a inc) 2))) [@a @x @a @x @a]"))))

(deftest map?-test
(is (eq [true true false]
(jsv! "[(map? {}) (map? (new Map [])) (map? [])]"))))

(defn init []
(t/run-tests 'squint.compiler-test 'squint.jsx-test 'squint.string-test 'squint.html-test))

0 comments on commit 98c925b

Please sign in to comment.