Subject: bug#64292: 30.0.50; setf strange when lexical-binding is nil

From: Stefan Monnier <[email-masked]>
Date: Tue, 27 Jun 2023 09:36:07 -0400

Mattias Engdegård [2023-06-27 15:21:08] wrote:

>> (setq lexical-binding nil)
>> (require 'nnheader)
>> (macroexpand '(setf (mail-header-date header) date))
>>  => (let* ((v #'(lambda (cl-x) (progn (progn (aref cl-x 3)))))
>>            (v header))
>>       (\(setf\ funcall\) date v v))
>> 
>> This looks broken, though it gets normal if lexical-binding is t.
>> Because of this, an old ELisp module doesn't work.  In addition,
>> the funny portion is replaced with
>> \(setf\ internal--with-suppressed-warnings\)...
>> if the code is byte-compiled.
>
> This is effectively an encrypted "you should use lexical-binding:t" error message.
> Stefan, should we just bypass the suppression here, or the entire `cl--slet`
> business, in dynbound mode?

Can someone confirm that the patch below reverts the regression?

        Stefan

diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index aadb498609a..eed7199fcc2 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -247,9 +247,10 @@ cl--slet
   "Like `cl--slet*' but for \"parallel let\"."
   (let ((dyns nil)) ;Vars declared as dynbound among the bindings?
     ;; `seq-some' lead to bootstrap problems.
-    (dolist (binding bindings)
-      (when (macroexp--dynamic-variable-p (car binding))
-        (push (car binding) dyns)))
+    (when lexical-binding
+      (dolist (binding bindings)
+        (when (macroexp--dynamic-variable-p (car binding))
+          (push (car binding) dyns))))
     (cond
      (dyns
       (let ((form `(funcall (lambda (,@(mapcar #'car bindings))