mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Single string literal in body is return value only, not doc string
A function or macro body consisting of a single string literal now only uses it as a return value. Previously, it had the dual uses as return value and doc string, which was never what the programmer wanted and had some inconvenient consequences (bug#69387). This change applies to `lambda`, `defun`, `defsubst` and `defmacro` forms; most other defining forms already worked in the sensible way. * lisp/emacs-lisp/bytecomp.el (byte-compile-lambda): Don't use a lone string literal as doc string. * test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defun.el (foo): Update docstring warning test. * doc/lispref/functions.texi (Function Documentation): Update. * etc/NEWS: Announce.
This commit is contained in:
parent
8aabd83574
commit
61b2f5f96b
4 changed files with 28 additions and 13 deletions
|
|
@ -3061,12 +3061,11 @@ lambda-expression."
|
|||
(append (if (not lexical-binding) arglistvars)
|
||||
byte-compile-bound-variables))
|
||||
(body (cdr (cdr fun)))
|
||||
(doc (if (stringp (car body))
|
||||
;; Treat a final string literal as a value, not a doc string.
|
||||
(doc (if (and (cdr body) (stringp (car body)))
|
||||
(prog1 (car body)
|
||||
;; Discard the doc string from the body
|
||||
;; unless it is the last element of the body.
|
||||
(if (cdr body)
|
||||
(setq body (cdr body))))))
|
||||
;; Discard the doc string from the body.
|
||||
(setq body (cdr body)))))
|
||||
(int (assq 'interactive body))
|
||||
command-modes)
|
||||
(when lexical-binding
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue