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).
This commit is contained in:
parent
4a1505904e
commit
fffcc7ab25
2 changed files with 19 additions and 8 deletions
|
@ -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'.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue