diff --git a/CHANGELOG.md b/CHANGELOG.md index fe07d241..805bac1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/squint/core.js b/src/squint/core.js index de6cede1..932f762f 100644 --- a/src/squint/core.js +++ b/src/squint/core.js @@ -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) { diff --git a/test/squint/compiler_test.cljs b/test/squint/compiler_test.cljs index f2d4f278..ec7eb41e 100644 --- a/test/squint/compiler_test.cljs +++ b/test/squint/compiler_test.cljs @@ -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))