bug#62464: [PATCH] error-object-irritants may #f instead of a list

Vasilij Schneidermann <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <ZCB3cKeUhkjPzDd3@odonien>
Hello,

I've tried to run a R7RS program and ran into an error with the
`error-object-irritants` procedure. According to R7RS-small, it returns
a list of irritants for the error object, but under Guile it returns #f
instead of an empty list. This behavior deviates from other R7RS
implementations I've tested the program against.

I've attached both a reproduction script (invoke with `guile -q --r7rs
-s test.scm`) and a patch that resolves the issue.

Guile version: 3.0.9
Machine type: x86_64-pc-linux-gnu
Operating system: Arch Linux
OS package version: `pacman -Q guile`: guile 3.0.9-1
test.scm (text/plain, 484 B)
(define-library (test)
  (import (scheme base))
  (import (scheme write))

  (begin
    (guard
     (ex ((error-object? ex)
          (display "[error] ")
          (display (error-object-message ex))
          (newline)
          (display "[irritants]")
          (newline)
          (for-each (lambda (irritant)
                      (display irritant)
                      (newline))
                    (error-object-irritants ex))))
     (error "An error without irritants"))))
0001-Make-error-object-irritants-always-returns-a-list.patch (text/plain, 1.1 KB)
From 923e677084733e8b077ab31cb625acf8f6ecdf55 Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <[email protected]>
Date: Sun, 26 Mar 2023 18:16:23 +0200
Subject: [PATCH] Make error-object-irritants always returns a list

Per R7RS-small, the procedure is defined to return "a list of the
irritants encapsulated by error-object", but currently it returns #f if
there are no irritants. This has been fixed now.

* module/scheme/base.scm (error-object-irritants): Improve R7RS
compliance by always returning a list of irritants.
---
 module/scheme/base.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/module/scheme/base.scm b/module/scheme/base.scm
index c6a73c092..eea2401b2 100644
--- a/module/scheme/base.scm
+++ b/module/scheme/base.scm
@@ -260,8 +260,9 @@
        (exception-message obj)))
 
 (define (error-object-irritants obj)
-  (and (exception-with-irritants? obj)
-       (exception-irritants obj)))
+  (if (exception-with-irritants? obj)
+      (exception-irritants obj)
+      '()))
 
 (define (r7:error message . irritants)
   (raise-exception
-- 
2.40.0
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCAAdFiEE0dAcySl3bqM8O17WFmfJg6zCifoFAmQgd20ACgkQFmfJg6zC
ifqraAgAmjowUF6lIy4u4JM1QpDCN1es0L2ZhDRFEBwMksL5c1IufP+muBqN+isf
A8IThQfTQ+WPFDTGylknzhaI4CJ4VA3us7RuKXHGcTdricfYWAG981bG88NYF5N8
oDHR+kenIJAQASMO/KOaT/shzU4I4XqAyDT6/mIzCPYG2txl+0s8JQsI0l/FJMkp
dXxgtr8Eupa3Fcyhsuwtqz17aQTjJn+G1O4pzDzVNmUjtVj5iTkSmLyW6ug3aA8W
XaKa4EEG7dlknRnFm1bcetqmjMVLHJNZnF6fTY9NRYGXz8XdvfrxlCKSPwghJRqf
yAn7ntp5sv5QNpLStgyDfAjr/mRy8A==
=D8ON
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.