1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-09 15:50:40 -08:00

macroexp.el: Fix missing warning for intermediate expansions

When a macro expanded to a call to an obsolete macro, we failed
to emit a warning for that use of the obsolete macro.

* lisp/emacs-lisp/macroexp.el (macroexp-macroexpand):
Use `macroexpand-1` to check obsolecence of intermediate expansions.

* test/lisp/emacs-lisp/macroexp-tests.el
(macroexp--test-obsolete-macro): New test.
This commit is contained in:
Stefan Monnier 2023-07-19 11:29:32 -04:00
parent b9a910a701
commit ca4bc9baf9
2 changed files with 29 additions and 15 deletions

View file

@ -124,4 +124,20 @@
(dyn dyn dyn dyn)
(dyn dyn dyn lex))))))
(defmacro macroexp--test-macro1 ()
(declare (obsolete "new-replacement" nil))
1)
(defmacro macroexp--test-macro2 ()
'(macroexp--test-macro1))
(ert-deftest macroexp--test-obsolete-macro ()
(should
(let ((res
(cl-letf (((symbol-function 'message) #'user-error))
(condition-case err
(macroexpand-all '(macroexp--test-macro2))
(user-error (error-message-string err))))))
(should (and (stringp res) (string-match "new-replacement" res))))))
;;; macroexp-tests.el ends here