(scheme base) member: return #f, not (), for no match
authorRob Browning <rlb@defaultvalue.org>
Sun, 4 Oct 2020 15:43:09 +0000 (10:43 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 17 Jan 2021 19:25:40 +0000 (13:25 -0600)
* module/scheme/base.scm (member): Match the r7rs requirement, as assoc
  already does.

Thanks to Erik Dominikus for reporting the problem.

Closes: 43304
THANKS
module/scheme/base.scm
test-suite/tests/r7rs.test

diff --git a/THANKS b/THANKS
index 3d59c500c1177b4e2d40fefb57b392ec4998234a..aa4877e9576e97acf9386610f7fd8ca3a6caaf88 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -2,6 +2,7 @@ Contributors since the last release:
 
     Christopher Baines
            Greg Benison
+           Rob Browning
         Tristan Colgate-McFarlane
           Aleix Conchillo Flaqué
         Ludovic Courtès
@@ -79,6 +80,7 @@ For fixes or providing information which led to a fix:
            Josh Datko
           David Diffenbaugh
           Hyper Division
+           Erik Dominikus
       Alexandre Duret-Lutz
            Nils Durner
          John W Eaton
index b97259f18b38d33847c2d723a02b997973cc53c3..20e280467b558d54d6020970aafb2e37e4f1f294 100644 (file)
     (unless (procedure? =)
       (error "not a procedure" =))
     (let lp ((ls ls))
-      (if (or (null? ls) (= (car ls) x))
-          ls
-          (lp (cdr ls)))))))
+      (cond
+       ((null? ls) #f)
+       ((= (car ls) x) ls)
+       (else (lp (cdr ls))))))))
 
 (define* (assoc x ls #:optional (= equal?))
   (cond
index 0914f0c5e334f2cecd32c02bfa451ccf54a7c3a7..1cc8cd31ea24ead120c9b3c447d0249ea5e73fc1 100644 (file)
        (let ((out (open-output-string))
              (x (list 1)))
          (set-cdr! x x)
-         (write x out)
+         (write-shared x out)
          (get-output-string out))
        ;; labels not guaranteed to be 0 indexed, spacing may differ
        '("#0=(1 . #0#)" "#1=(1 . #1#)"))