* 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.
This commit is contained in:
parent
40d8f83e53
commit
7561c01380
2 changed files with 8 additions and 2 deletions
|
@ -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)))
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue