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.
This commit is contained in:
parent
22d3f0e95a
commit
493ae66be0
2 changed files with 22 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue