From: Vasilij Schneidermann <mail@vasilij.de>
To: 62464@debbugs.gnu.org
Subject: bug#62464: [PATCH] error-object-irritants may #f instead of a list
Date: Sun, 26 Mar 2023 18:48:48 +0200 [thread overview]
Message-ID: <ZCB3cKeUhkjPzDd3@odonien> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 591 bytes --]
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
[-- Attachment #1.2: test.scm --]
[-- Type: text/plain, Size: 484 bytes --]
(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"))))
[-- Attachment #1.3: 0001-Make-error-object-irritants-always-returns-a-list.patch --]
[-- Type: text/plain, Size: 1131 bytes --]
From 923e677084733e8b077ab31cb625acf8f6ecdf55 Mon Sep 17 00:00:00 2001
From: Vasilij Schneidermann <mail@vasilij.de>
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
reply other threads:[~2023-03-26 16:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZCB3cKeUhkjPzDd3@odonien \
--to=mail@vasilij.de \
--cc=62464@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).