Subject: bug#62067: 29.0.60; 'map-insert' implementation for lists is problematic

From: Augusto Stoffel <[email-masked]>
Date: Thu, 09 Mar 2023 08:48:02 +0100

Consider, for instance:

  (map-insert '(:a 1) :a 2)
  => (:a 2 :a 1)

This result will confuse users and other libraries:

  (json-encode (map-insert '(:a 1) :a 2))
  => "{\"a\":2,\"a\":1}"

Not even map.el can really handle these return values correctly:

  (let (x)
    (map-do (lambda (k v) (if (eq k :a) (setq x v)))
          (map-insert '(:a old) :a 'new))
    x)
  => old

The alist implementation has similar issues.