Subject: bug#56739: 29.0.50; `cl-psetq' and `cl-psetf' fail to recognize symbol macros

From: Stefan Kangas <[email-masked]>
Date: Thu, 7 Sep 2023 11:31:34 -0700

Stefan Monnier <[email-masked]> writes:

>> -  (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)
>
> This looks like a safe way to make it work when the place is
> a symbol macro.
>
>> +                (and (symbolp (nth 1 p))
>> +                     (assq (nth 1 p) smacros))
>> +                (cl--expr-depends-p (nth 1 p) vars))
>
> But this doesn't look strong enough; if (nth 1 p) is (+ c c) where `c`
> is a symbol macro the same problem will appear.  So the test needs to be
> pushed into `cl--expr-depends-p` (probably into `cl--safe-expr-p` where
> it will fix other related problems elsewhere).

(That was one year ago.)

Michael, did you have a chance to look into this?  It would be nice to
get this bug fixed.