summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-10-01 18:02:09 +0200
committerLudovic Courtès <ludo@gnu.org>2022-10-01 18:04:16 +0200
commit3ed7673ac067a8614dcf36e2f5293111ba60b243 (patch)
treea4037d84008577dd4b6c210ca66ebbf9e0bd3a53
parent78c7772eb77f9ce08147cf7a722226edce3f5aaa (diff)
downloadguile-3ed7673ac067a8614dcf36e2f5293111ba60b243.tar.gz
srfi-35: Fix expansion of 'condition' for compound conditions.
* module/srfi/srfi-35.scm (condition): Use 'make-exception' instead of 'make-compound-condition', which is unbound in this module. * test-suite/tests/srfi-35.test ("syntax")["compound condition, hygienic macro expansion"]: New test.
-rw-r--r--module/srfi/srfi-35.scm6
-rw-r--r--test-suite/tests/srfi-35.test18
2 files changed, 19 insertions, 5 deletions
diff --git a/module/srfi/srfi-35.scm b/module/srfi/srfi-35.scm
index e430833c4..99a93dc18 100644
--- a/module/srfi/srfi-35.scm
+++ b/module/srfi/srfi-35.scm
@@ -1,6 +1,6 @@
;;; srfi-35.scm --- Conditions -*- coding: utf-8 -*-
-;; Copyright (C) 2007-2011, 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2011, 2017, 2022 Free Software Foundation, Inc.
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -146,5 +146,5 @@ by C."
((_ (type field ...))
(condition-instantiation type () field ...))
((_ (type field ...) ...)
- (make-compound-condition (condition-instantiation type () field ...)
- ...))))
+ (make-exception (condition-instantiation type () field ...)
+ ...))))
diff --git a/test-suite/tests/srfi-35.test b/test-suite/tests/srfi-35.test
index df73c8442..dc95ddd37 100644
--- a/test-suite/tests/srfi-35.test
+++ b/test-suite/tests/srfi-35.test
@@ -1,7 +1,7 @@
;;;; srfi-35.test --- SRFI-35. -*- mode: scheme; coding: utf-8; -*-
;;;; Ludovic Courtès <ludo@gnu.org>
;;;;
-;;;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 2007, 2008, 2009, 2010, 2022 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -176,7 +176,21 @@
(c (condition (t1 (a 0) (b 1))
(t2 (c 2) (d 3)))))
(and (equal? c1 (extract-condition c t1))
- (equal? c2 (extract-condition c t2))))))
+ (equal? c2 (extract-condition c t2)))))
+
+ (pass-if "compound condition, hygienic macro expansion"
+ ;; In Guile 3.0.8, the 'condition' form below would refer to
+ ;; 'make-compound-condition' in an unhygienic fashion, leading to
+ ;; "unbound variable: make-compound-condition" if (srfi srfi-35) is
+ ;; not imported or imported with different bindings.
+ (let ((c (eval '(begin
+ (use-modules ((srfi srfi-35) #:prefix s:))
+
+ (s:condition (s:&error)
+ (s:&message (message "m"))))
+ (make-fresh-user-module))))
+ (and (condition? c)
+ (error? c) (message-condition? c)))))
;;;