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

(eval-and-compile): Preserve the surrounding lexical context

Implement a better fix for bug#79634.

* lisp/emacs-lisp/byte-run.el (eval-and-compile):
* lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment)
<eval-and-compile>: Preserve the surrounding lexical context (the part
available during macroexpansion, i.e. which vars are dynbound).

* lisp/emacs-lisp/rx.el (<pcase> rx): Remove workaround.

* test/lisp/emacs-lisp/macroexp-tests.el
(macroexp--dynbound-eval-and-compile): New test.
This commit is contained in:
Stefan Monnier 2025-10-18 17:45:07 -04:00
parent 48357dc612
commit 4ec24ce2a1
4 changed files with 49 additions and 6 deletions

View file

@ -1685,10 +1685,6 @@ following constructs:
REF can be a number, as usual, or a name
introduced by a previous (let REF ...)
construct."
;; FIXME: We can't rely on the surrounding lexical context because
;; `pcase-defmacro' wraps this function inside an `eval-and-compile',
;; so we have to repeat the (defvar rx--pcase-vars).
(defvar rx--pcase-vars)
(let* ((rx--pcase-vars nil)
(regexp (rx--to-expr (rx--pcase-transform (cons 'seq regexps)))))
`(and (pred stringp)