unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Basil Contovounesios via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Mattias Engdegård" <mattias.engdegard@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	64404@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#64404: 30.0.50; condition-case-unless-debug mishandles :success
Date: Mon, 03 Jul 2023 10:24:04 +0100	[thread overview]
Message-ID: <87r0pp8i17.fsf@epfl.ch> (raw)
In-Reply-To: <88ACE707-A181-4D76-9773-A1B772C28CC1@gmail.com> ("Mattias Engdegård"'s message of "Sun, 2 Jul 2023 11:57:25 +0200")

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

Mattias Engdegård [2023-07-02 11:57 +0200] wrote:

> Good catch! I don't think we need to bother about the Lisp
> interpreter, but I added a byte-compiler warning for it in 59a350cb91.

Thanks.

> Would you like to repair condition-case-unless-debug?

Like so?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-condition-case-unless-debug-with-success.patch --]
[-- Type: text/x-diff, Size: 2120 bytes --]

From 8b47f52c81fe5d039a555f5037921f978191d2aa Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 3 Jul 2023 10:10:47 +0100
Subject: [PATCH] Fix condition-case-unless-debug with :success

* lisp/subr.el (condition-case-unless-debug): Don't add debug
condition to :success handler (bug#64404).
* test/lisp/subr-tests.el (condition-case-unless-debug-success):
New test.
---
 lisp/subr.el            |  9 ++++++---
 test/lisp/subr-tests.el | 11 +++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 4c462830120..483083b29c3 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4987,9 +4987,12 @@ condition-case-unless-debug
   `(condition-case ,var
        ,bodyform
      ,@(mapcar (lambda (handler)
-                 `((debug ,@(if (listp (car handler)) (car handler)
-                              (list (car handler))))
-                   ,@(cdr handler)))
+                 (let ((condition (car handler)))
+                   (if (eq condition :success)
+                       handler
+                     `((debug ,@(if (listp condition) condition
+                                  (list condition)))
+                       ,@(cdr handler)))))
                handlers)))
 
 (defmacro with-demoted-errors (format &rest body)
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 1c220b1da18..14caf54b380 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1256,5 +1256,16 @@ subr--copy-tree
                              "((a b) (a b) #2# #2# #3# #3#)"
                              "((a b) (a b) [c d] [c d] #s(e f) #s(e f))")))))))
 
+(ert-deftest condition-case-unless-debug-success ()
+  "Test `condition-case-unless-debug' with :success (bug#64404)."
+  (should (= 1 (condition-case-unless-debug nil
+                   0
+                 (:success 1)
+                 (t 2))))
+  (should (= 1 (condition-case-unless-debug var
+                   0
+                 (:success (1+ var))
+                 (t var)))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here
-- 
2.34.1


[-- Attachment #3: Type: text/plain, Size: 11 bytes --]


-- 
Basil

  reply	other threads:[~2023-07-03  9:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-01 19:32 bug#64404: 30.0.50; condition-case-unless-debug mishandles :success Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-02  4:50 ` Eli Zaretskii
2023-07-02  9:57 ` Mattias Engdegård
2023-07-03  9:24   ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-07-03 10:09     ` Mattias Engdegård
2023-07-03 11:10       ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-03 11:12         ` Mattias Engdegård
2023-07-08 12:26           ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors

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/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0pp8i17.fsf@epfl.ch \
    --to=bug-gnu-emacs@gnu.org \
    --cc=64404@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=eliz@gnu.org \
    --cc=mattias.engdegard@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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