emacs-diffs
[Top][All Lists]
Advanced

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

master 7561c01: * lisp/emacs-lisp/cconv.el: Don't confuse a string for a


From: Stefan Monnier
Subject: master 7561c01: * lisp/emacs-lisp/cconv.el: Don't confuse a string for a docstring
Date: Tue, 9 Mar 2021 11:04:07 -0500 (EST)

branch: master
commit 7561c01380aa3347901eeddd2d0a466cb29ebbd8
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/emacs-lisp/cconv.el: Don't confuse a string for a docstring
    
    (cconv--convert-funcbody): Check there's something after a docstring.
    
    * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-string-vs-docstring):
    New corresponding test.
---
 lisp/emacs-lisp/cconv.el               | 5 +++--
 test/lisp/emacs-lisp/bytecomp-tests.el | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index bd0a3e8..68e930f 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -295,8 +295,9 @@ of converted forms."
     (if wrappers
         (let ((special-forms '()))
           ;; Keep special forms at the beginning of the body.
-          (while (or (stringp (car funcbody)) ;docstring.
-                     (memq (car-safe (car funcbody)) '(interactive declare)))
+          (while (or (and (cdr funcbody) (stringp (car funcbody))) ;docstring.
+                     (memq (car-safe (car funcbody))
+                           '(interactive declare :documentation)))
             (push (pop funcbody) special-forms))
           (let ((body (macroexp-progn funcbody)))
             (dolist (wrapper wrappers) (setq body (funcall wrapper body)))
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el 
b/test/lisp/emacs-lisp/bytecomp-tests.el
index 03c267c..5147cd2 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -1222,6 +1222,11 @@ compiled correctly."
         (byte-compile 'counter)
         (should (equal (counter) 1))))))
 
+(ert-deftest bytecomp-string-vs-docstring ()
+  ;; Don't confuse a string return value for a docstring.
+  (let ((lexical-binding t))
+    (should (equal (funcall (byte-compile '(lambda (x) "foo")) 'dummy) 
"foo"))))
+
 ;; Local Variables:
 ;; no-byte-compile: t
 ;; End:



reply via email to

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