unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#62464: [PATCH] error-object-irritants may #f instead of a list
@ 2023-03-26 16:48 Vasilij Schneidermann
  0 siblings, 0 replies; only message in thread
From: Vasilij Schneidermann @ 2023-03-26 16:48 UTC (permalink / raw)
  To: 62464


[-- 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 --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-26 16:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-26 16:48 bug#62464: [PATCH] error-object-irritants may #f instead of a list Vasilij Schneidermann

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).