Skip to content

Commit

Permalink
[#529] if with falsy literal returns nil
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Feb 9, 2021
1 parent 730d809 commit 6fff41d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

For a list of breaking changes, check [here](#breaking-changes)

## v0.2.3

### Enhancements / fixes

- if with falsy literal returns nil [#529](https://github.com/borkdude/sci/issues/529)

## v0.2.2

### Enhancements / fixes
Expand Down
2 changes: 1 addition & 1 deletion resources/SCI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.3-SNAPSHOT
0.2.3
2 changes: 1 addition & 1 deletion src/sci/impl/analyzer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
3 (let [condition (nth children 0)
then (nth children 1)
else (nth children 2)]
(cond (not condition) nil
(cond (not condition) else
(constant? condition) then
:else (ctx-fn
(fn [ctx]
Expand Down
2 changes: 2 additions & 0 deletions test/sci/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
(testing "if and when"
(is (= 1 (eval* 0 '(if (zero? *in*) 1 2))))
(is (= 2 (eval* 1 '(if (zero? *in*) 1 2))))
(is (= 10 (eval* "(if true 10 20)")))
(is (= 20 (eval* "(if false 10 20)")))
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"Too few arguments to if"
(eval* '(if))))
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"Too few arguments to if"
Expand Down

0 comments on commit 6fff41d

Please sign in to comment.