Skip to content

Commit 6fff41d

Browse files
committed
[#529] if with falsy literal returns nil
1 parent 730d809 commit 6fff41d

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
## v0.2.3
6+
7+
### Enhancements / fixes
8+
9+
- if with falsy literal returns nil [#529](https://github.com/borkdude/sci/issues/529)
10+
511
## v0.2.2
612

713
### Enhancements / fixes

resources/SCI_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.3-SNAPSHOT
1+
0.2.3

src/sci/impl/analyzer.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
3 (let [condition (nth children 0)
475475
then (nth children 1)
476476
else (nth children 2)]
477-
(cond (not condition) nil
477+
(cond (not condition) else
478478
(constant? condition) then
479479
:else (ctx-fn
480480
(fn [ctx]

test/sci/core_test.cljc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
(testing "if and when"
5151
(is (= 1 (eval* 0 '(if (zero? *in*) 1 2))))
5252
(is (= 2 (eval* 1 '(if (zero? *in*) 1 2))))
53+
(is (= 10 (eval* "(if true 10 20)")))
54+
(is (= 20 (eval* "(if false 10 20)")))
5355
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"Too few arguments to if"
5456
(eval* '(if))))
5557
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"Too few arguments to if"

0 commit comments

Comments
 (0)