From 4161a368499a3326d13113aa5c6ab332047df767 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 5 Jan 2022 14:28:08 -0500 Subject: [PATCH] cl-generic.el: Fix bug#46722 Fix longstanding bug due to unexpected interference via side-effect. * lisp/emacs-lisp/cl-generic.el (cl--generic-get-dispatcher): Copy the `dispatch` arg before storing it into the hash-table. Backport from `master` (cherrypick from commit 61f8f7f68f). --- lisp/emacs-lisp/cl-generic.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index a7e24236a32..add8e7fda0c 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -602,7 +602,9 @@ The set of acceptable TYPEs (also called \"specializers\") is defined (defun cl--generic-get-dispatcher (dispatch) (cl--generic-with-memoization - (gethash dispatch cl--generic-dispatchers) + ;; We need `copy-sequence` here because this `dispatch' object might be + ;; modified by side-effect in `cl-generic-define-method' (bug#46722). + (gethash (copy-sequence dispatch) cl--generic-dispatchers) ;; (message "cl--generic-get-dispatcher (%S)" dispatch) (let* ((dispatch-arg (car dispatch)) (generalizers (cdr dispatch)) -- 2.39.2