Commit 493ae66b authored by Mattias Engdegård's avatar Mattias Engdegård
Browse files

Preserve doc string in `byte-compile` (bug#55830)

* lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function):
Don't transpose doc string and interactive spec, which must come
in this order.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-function-attributes): New test.
parent 22d3f0e9
Pipeline #18373 failed with stages
in 230 minutes and 29 seconds
......@@ -2926,6 +2926,7 @@ FUN should be either a `lambda' value or a `closure' value."
(push (pop body) preamble))
(when (eq (car-safe (car body)) 'interactive)
(push (pop body) preamble))
(setq preamble (nreverse preamble))
;; Turn the function's closed vars (if any) into local let bindings.
(dolist (binding env)
(cond
......
......@@ -1553,6 +1553,27 @@ EXPECTED-POINT BINDINGS (MODES \\='\\='(ruby-mode js-mode python-mode)) \
(should (byte-compile--suspicious-defcustom-choice
'(choice (const :tag "foo" 'bar)))))
(ert-deftest bytecomp-function-attributes ()
;; Check that `byte-compile' keeps the declarations, interactive spec and
;; doc string of the function (bug#55830).
(let ((fname 'bytecomp-test-fun))
(fset fname nil)
(put fname 'pure nil)
(put fname 'lisp-indent-function nil)
(eval `(defun ,fname (x)
"tata"
(declare (pure t) (indent 1))
(interactive "P")
(list 'toto x))
t)
(let ((bc (byte-compile fname)))
(should (byte-code-function-p bc))
(should (equal (funcall bc 'titi) '(toto titi)))
(should (equal (aref bc 5) "P"))
(should (equal (get fname 'pure) t))
(should (equal (get fname 'lisp-indent-function) 1))
(should (equal (aref bc 4) "tata\n\n(fn X)")))))
;; Local Variables:
;; no-byte-compile: t
;; End:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment