From: Stefan Monnier Date: Wed, 5 Jan 2022 19:28:08 +0000 (-0500) Subject: cl-generic.el: Fix bug#46722 X-Git-Tag: emacs-29.0.90~3238 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=61f8f7f68f3bac5dc7ab41532902c480417552d8;p=emacs.git 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. --- 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))