]> git.eshelyaron.com Git - emacs.git/commit
Preserve source position of macro calls in macro expansions
authorAlan Mackenzie <acm@muc.de>
Sun, 13 Jul 2025 20:28:51 +0000 (20:28 +0000)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 08:47:08 +0000 (10:47 +0200)
commit06eda9c302ea19b447ba33feb722b05a8da8e36f
tree4dbc1ca4bf4f3e15732c7da8a777de96e4348aaf
parent86a143b455b68bc6dfffa50fd4b5d14f480eeceb
Preserve source position of macro calls in macro expansions

This allows the byte compiler to give correct positions, those
of the invoking forms, when an error or warning is caused by
the innards of the invoked macros.

This fixes bug#73725 and bug#73746.

* lisp/emacs-lisp/macroexp.el (macroexp--posify-form-1)
(macroexp--posify-form): New functions.
(macroexp-preserve-posification): New macro.
(macroexp--compiler-macro, macroexp-macroexpand): Use the new
macro to preserve a calling form's position.

* lisp/emacs-lisp/byte-opt.el (byte-optimize-form): Use the new
macro to preserve source positions.

* test/lisp/emacs-lisp/bytecomp-resources/bad-error-position.el
* test/lisp/emacs-lisp/bytecomp-resources/bad-error-position-2.el:
New test files.
* test/lisp/emacs-lisp/bytecomp-tests.el: Two new tests using
the new test files.

(cherry picked from commit c44903b0118357336cca964bd210835ca4881e87)
lisp/emacs-lisp/byte-opt.el
lisp/emacs-lisp/macroexp.el
test/lisp/emacs-lisp/bytecomp-resources/macro-warning-position-2.el [new file with mode: 0644]
test/lisp/emacs-lisp/bytecomp-resources/macro-warning-position.el [new file with mode: 0644]
test/lisp/emacs-lisp/bytecomp-tests.el