GNU bug report logs -
#56739
29.0.50; `cl-psetq' and `cl-psetf' fail to recognize symbol macros
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Hello,
I think we can fix this (both cases mentioned) similarly as in cl-letf:
[0001-WIP-Fix-symbol-macros-used-in-cl-psetf-Bug-56739.patch (text/x-diff, inline)]
From 29ea21a751ab6e71b2fb34c781131e31fc7b950d Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen <at> web.de>
Date: Wed, 3 Aug 2022 02:06:16 +0200
Subject: [PATCH] WIP: Fix symbol macros used in cl-psetf (Bug#56739)
---
lisp/emacs-lisp/cl-macs.el | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 78d19db479..f3051752ba 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2653,12 +2653,17 @@ cl-psetf
\(fn PLACE VAL PLACE VAL ...)"
(declare (debug setf))
- (let ((p args) (simple t) (vars nil))
+ (let ((p args) (simple t) (vars nil)
+ (smacros (alist-get :cl-symbol-macros macroexpand-all-environment)))
(while p
- (if (or (not (symbolp (car p))) (cl--expr-depends-p (nth 1 p) vars))
- (setq simple nil))
- (if (memq (car p) vars)
- (error "Destination duplicated in psetf: %s" (car p)))
+ (when (or (not (symbolp (car p)))
+ (assq (car p) smacros)
+ (and (symbolp (nth 1 p))
+ (assq (nth 1 p) smacros))
+ (cl--expr-depends-p (nth 1 p) vars))
+ (setq simple nil))
+ (when (memq (car p) vars)
+ (error "Destination duplicated in psetf: %s" (car p)))
(push (pop p) vars)
(or p (error "Odd number of arguments to cl-psetf"))
(pop p))
--
2.30.2
[Message part 3 (text/plain, inline)]
But I'm not a fan of symbol macros any more: the concept sounds nice
first, but actually you only save one pair of parens when coding while
they introduce a special case that one always has too keep in mind for
macro expansions: any symbol might not just be a symbol.
I guess this is not the only place where they are not handled correctly.
Michael.
This bug report was last modified 1 year and 282 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.