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

From: Vasilij Schneidermann <[email-masked]>
Date: Sun, 26 Mar 2023 18:48:48 +0200

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
From 923e677084733e8b077ab31cb625acf8f6ecdf55 Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <[email-masked]>
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