From 61f8f7f68f3bac5dc7ab41532902c480417552d8 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. --- 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 983694204df..5090e060372 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -604,7 +604,9 @@ The set of acceptable TYPEs (also called \"specializers\") is defined (defun cl--generic-get-dispatcher (dispatch) (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