emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 1748361c68 2/2: Fix condition-case empty success handler misinter


From: Mattias Engdegård
Subject: master 1748361c68 2/2: Fix condition-case empty success handler misinterpretation
Date: Sat, 24 Dec 2022 06:15:06 -0500 (EST)

branch: master
commit 1748361c68aeb3e18e6007369f153657227e6059
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Fix condition-case empty success handler misinterpretation
    
    (condition-case X E (:success)) should return nil; the compiler
    behaves correctly in this case.
    
    * src/eval.c (internal_lisp_condition_case):
    Evaluate an empty :success handler as nil instead of pretending it
    isn't there.
    * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
    Add test case.
---
 src/eval.c                             | 6 +++---
 test/lisp/emacs-lisp/bytecomp-tests.el | 5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/eval.c b/src/eval.c
index 99f3650fc9..cff4b92477 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1367,7 +1367,7 @@ internal_lisp_condition_case (Lisp_Object var, 
Lisp_Object bodyform,
        error ("Invalid condition handler: %s",
               SDATA (Fprin1_to_string (tem, Qt, Qnil)));
       if (CONSP (tem) && EQ (XCAR (tem), QCsuccess))
-       success_handler = XCDR (tem);
+       success_handler = tem;
       else
        clausenb++;
     }
@@ -1430,7 +1430,7 @@ internal_lisp_condition_case (Lisp_Object var, 
Lisp_Object bodyform,
   if (!NILP (success_handler))
     {
       if (NILP (var))
-       return Fprogn (success_handler);
+       return Fprogn (XCDR (success_handler));
 
       Lisp_Object handler_var = var;
       if (!NILP (Vinternal_interpreter_environment))
@@ -1442,7 +1442,7 @@ internal_lisp_condition_case (Lisp_Object var, 
Lisp_Object bodyform,
 
       specpdl_ref count = SPECPDL_INDEX ();
       specbind (handler_var, result);
-      return unbind_to (count, Fprogn (success_handler));
+      return unbind_to (count, Fprogn (XCDR (success_handler)));
     }
   return result;
 }
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el 
b/test/lisp/emacs-lisp/bytecomp-tests.el
index 36f541e867..47200de7a0 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -752,6 +752,11 @@ inner loops respectively."
       (condition-case nil
           (characterp x)               ; value (no :success, no var)
         (error 'bad)))
+
+    (condition-case nil
+        (bytecomp-test-identity 3)
+      (error 'bad)
+      (:success))                       ; empty handler
     )
   "List of expressions for cross-testing interpreted and compiled code.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]