From 4cc4a9d38ba4bf9271f96a820decb64c33d61de5 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 6 May 2023 10:16:05 -0500 Subject: [PATCH] (and ... true) will return `true` as per docs. --- src/boot/boot.janet | 2 +- test/suite0001.janet | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index cc280ae9..5a89d832 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -280,7 +280,7 @@ (while (> i 0) (-- i) (def v (in forms i)) - (set ret (if (= ret true) + (set ret (if (= i (- len 1)) v (if (idempotent? v) ['if v ret v] diff --git a/test/suite0001.janet b/test/suite0001.janet index f26b873f..cbe356c7 100644 --- a/test/suite0001.janet +++ b/test/suite0001.janet @@ -345,6 +345,8 @@ (assert (= (and 0 1 nil) nil) "and 0 1 nil") (assert (= (and 1) 1) "and 1") (assert (= (and) true) "and with no arguments") +(assert (= (and 1 true) true) "and with trailing true") +(assert (= (and 1 true 2) 2) "and with internal true") (assert (= (or true true) true) "or true true") (assert (= (or true false) true) "or true false")