[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2dd1c2ab19: gv.el and cl-macs.el: Fix bug#57397
From: |
Stefan Monnier |
Subject: |
master 2dd1c2ab19: gv.el and cl-macs.el: Fix bug#57397 |
Date: |
Sat, 3 Sep 2022 22:38:37 -0400 (EDT) |
branch: master
commit 2dd1c2ab19f7fb99ecee60e27e63b2fb045f6970
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
gv.el and cl-macs.el: Fix bug#57397
* lisp/emacs-lisp/gv.el (gv-get): Obey symbol macros.
* lisp/emacs-lisp/cl-macs.el (cl--letf): Remove workaround placed to
try and handle symbol macros.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-test--symbol-macrolet):
Add new testcase.
---
lisp/emacs-lisp/cl-macs.el | 2 +-
lisp/emacs-lisp/gv.el | 6 +++++-
test/lisp/emacs-lisp/cl-macs-tests.el | 15 ++++++++++++++-
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index edd633675d..9755c2636d 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2762,7 +2762,7 @@ Each PLACE may be a symbol, or any generalized variable
allowed by `setf'.
(funcall setter vold)))
binds))))
(let* ((binding (car bindings))
- (place (macroexpand (car binding) macroexpand-all-environment)))
+ (place (car binding)))
(gv-letplace (getter setter) place
(macroexp-let2 nil vnew (cadr binding)
(if (symbolp place)
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index eaab6439ad..1db9d96d99 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -87,7 +87,11 @@ with a (not necessarily copyable) Elisp expression that
returns the value to
set it to.
DO must return an Elisp expression."
(cond
- ((symbolp place) (funcall do place (lambda (v) `(setq ,place ,v))))
+ ((symbolp place)
+ (let ((me (macroexpand-1 place macroexpand-all-environment)))
+ (if (eq me place)
+ (funcall do place (lambda (v) `(setq ,place ,v)))
+ (gv-get me do))))
((not (consp place)) (signal 'gv-invalid-place (list place)))
(t
(let* ((head (car place))
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el
b/test/lisp/emacs-lisp/cl-macs-tests.el
index 19ede627a1..2a647e0830 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -539,7 +539,20 @@ collection clause."
((p (gv-synthetic-place cl (lambda (v) `(setcar l
,v)))))
(cl-incf p)))
l)
- '(1))))
+ '(1)))
+ ;; Make sure `gv-synthetic-place' isn't macro-expanded before
+ ;; `cl-letf' gets to see its `gv-expander'.
+ (should (equal
+ (condition-case err
+ (let ((x 1))
+ (list x
+ (cl-letf (((gv-synthetic-place (+ 1 2)
+ (lambda (v) `(setq x
,v)))
+ 7))
+ x)
+ x))
+ (error err))
+ '(1 7 3))))
(ert-deftest cl-macs-loop-conditional-step-clauses ()
"These tests failed under the initial fixes in #bug#29799."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 2dd1c2ab19: gv.el and cl-macs.el: Fix bug#57397,
Stefan Monnier <=