From: Stefan Monnier Date: Mon, 25 May 2015 14:53:52 +0000 (-0400) Subject: (cl-generic-define-method): Side effects are evil (bug#20644) X-Git-Tag: emacs-25.0.90~1977 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9b995d55c566737ef7aa3432826e1b7b656ff1c7;p=emacs.git (cl-generic-define-method): Side effects are evil (bug#20644) * lisp/emacs-lisp/cl-generic.el (cl-generic-define-method): Don't reuse cons-cells that might be used as keys in an `equal' hash-table. --- diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index b3c127f48f7..24a04d445de 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -432,8 +432,10 @@ which case this method will be invoked when the argument is `eql' to VAL. (> (cl--generic-generalizer-priority x) (cl--generic-generalizer-priority y))))))) (setq i (1+ i)))) - (if me (setcar me method) - (setf (cl--generic-method-table generic) (cons method mt))) + ;; We used to (setcar me method), but that can cause false positives in + ;; the hash-consing table of the method-builder (bug#20644). + ;; See the related FIXME in cl--generic-build-combined-method. + (setf (cl--generic-method-table generic) (cons method (delq (car me) mt))) (cl-pushnew `(cl-defmethod . (,(cl--generic-name generic) . ,specializers)) current-load-list :test #'equal) ;; FIXME: Try to avoid re-constructing a new function if the old one