Skip to content

Commit

Permalink
Fix #537: not should wrap entire expression (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored Jun 11, 2024
1 parent 1b3db03 commit 995b6be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

[Squint](https://github.com/squint-cljs/squint): Light-weight ClojureScript dialect

## Unreleased
## v0.7.111

- [#537](https://github.com/squint-cljs/squint/issues/537): Fix `not`: wrap argument in parens
- Return interop expression in function body

## v0.7.110
Expand Down
2 changes: 1 addition & 1 deletion src/squint/compiler.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
(defmethod emit-special 'not [_ env [_ form]]
(let [js (emit form (expr-env env))]
(if (:bool js)
(emit-return (cc/bool-expr (str "!" js)) env)
(emit-return (cc/bool-expr (format "!(%s)" js)) env)
(cc/bool-expr
(emit (list 'js* (format "~{}(%s)" js) 'clojure.core/not)
env)))))
Expand Down
2 changes: 2 additions & 0 deletions test/squint/compiler_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,8 @@ new Foo();")
(deftest interop-test
(is (= 1 (jsv! "(defn foo [x] x.a) (foo {:a 1})"))))

(deftest issue-537-test
(is (true? (jsv! "(not (= 1 2))"))))

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

0 comments on commit 995b6be

Please sign in to comment.