diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-09-01 10:32:49 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-09-01 10:32:49 +0200 |
commit | fffcc7ab25021fd9d73d50cf685a77777d38265c (patch) | |
tree | 0cd51e80fa954e44dba418afb432fa3e1a735cf2 /lisp/emacs-lisp | |
parent | 4a1505904e3606046c201f87deec1171f7d4d406 (diff) | |
download | emacs-fffcc7ab25021fd9d73d50cf685a77777d38265c.tar.gz emacs-fffcc7ab25021fd9d73d50cf685a77777d38265c.tar.bz2 emacs-fffcc7ab25021fd9d73d50cf685a77777d38265c.zip |
Fix (setf (map-elt map key) (my-func))
* lisp/emacs-lisp/map.el (map-elt): Ensure that the value isn't
referenced more than once (bug#50290).
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/map.el | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el index 988a62a4e34..77431f0c594 100644 --- a/lisp/emacs-lisp/map.el +++ b/lisp/emacs-lisp/map.el @@ -119,14 +119,16 @@ or array." ((key key) (default default) (testfn testfn)) (funcall do `(map-elt ,mgetter ,key ,default) (lambda (v) - `(condition-case nil - ;; Silence warnings about the hidden 4th arg. - (with-no-warnings (map-put! ,mgetter ,key ,v ,testfn)) - (map-not-inplace - ,(funcall msetter - `(map-insert ,mgetter ,key ,v)) - ;; Always return the value. - ,v)))))))) + (macroexp-let2 nil v v + `(condition-case nil + ;; Silence warnings about the hidden 4th arg. + (with-no-warnings + (map-put! ,mgetter ,key ,v ,testfn)) + (map-not-inplace + ,(funcall msetter + `(map-insert ,mgetter ,key ,v)) + ;; Always return the value. + ,v))))))))) ;; `testfn' is deprecated. (advertised-calling-convention (map key &optional default) "27.1")) ;; Can't use `cl-defmethod' with `advertised-calling-convention'. |