From 1e5393a57a3bbe3f9167fee59232c2e424afadf2 Mon Sep 17 00:00:00 2001 From: Vibhav Pant Date: Wed, 1 Mar 2023 15:04:34 +0530 Subject: Don't modify interactive closures destructively (Bug#60974). * lisp/emacs-lisp/cconv.el (cconv-convert): When form is an interactive lambda form, don't destructively modify it, as it might be a constant literal. Instead, create a new list with the relevant place(s) changed. * test/lisp/emacs-lisp/cconv-tests.el (cconv-tests-interactive-form-modify-bug60974): New test. --- test/lisp/emacs-lisp/cconv-tests.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/lisp/emacs-lisp') diff --git a/test/lisp/emacs-lisp/cconv-tests.el b/test/lisp/emacs-lisp/cconv-tests.el index 349ffeb7e47..6facd3452ea 100644 --- a/test/lisp/emacs-lisp/cconv-tests.el +++ b/test/lisp/emacs-lisp/cconv-tests.el @@ -376,6 +376,18 @@ (eval '(lambda (x) :closure-dont-trim-context (+ x 1)) `((y . ,magic-string))))))) +(ert-deftest cconv-tests-interactive-form-modify-bug60974 () + (let* ((f '(function (lambda (&optional arg) + (interactive + (list (if current-prefix-arg + (prefix-numeric-value current-prefix-arg) + 'toggle))) + (ignore arg)))) + (if (cadr (nth 2 (cadr f)))) + (if2)) + (cconv-closure-convert f) + (setq if2 (cadr (nth 2 (cadr f)))) + (should (eq if if2)))) (provide 'cconv-tests) ;;; cconv-tests.el ends here -- cgit v1.2.1