Subject: bug#60974: 30.0.50; byte-compile-preprocess mutates self evaluating forms in expanded macro bodies

From: Vibhav Pant <[email-masked]>
Date: Sat, 21 Jan 2023 03:05:51 +0530

The attached patch should fix this, thoughts?

Best,
Vibhav

-- 
Vibhav Pant
[email-masked]
GPG: 7ED1 D48C 513C A024 BE3A  785F E3FB 28CB 6AB5 9598
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index aa9521e5a65..847965e6af6 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2581,7 +2581,8 @@ byte-compile-flush-pending
 
 (defun byte-compile-preprocess (form &optional _for-effect)
   (let ((print-symbols-bare t))         ; Possibly redundant binding.
-    (setq form (macroexpand-all form byte-compile-macro-environment)))
+    (setq form (copy-tree
+                (macroexpand-all form byte-compile-macro-environment))))
   ;; FIXME: We should run byte-optimize-form here, but it currently does not
   ;; recurse through all the code, so we'd have to fix this first.
   ;; Maybe a good fix would be to merge byte-optimize-form into