GNU bug report logs - #40693
28.0.50; json-encode-alist changes alist

Previous Next

Package: emacs;

Reported by: Ivan Andrus <darthandrus <at> gmail.com>

Date: Sat, 18 Apr 2020 03:01:02 UTC

Severity: normal

Tags: fixed, patch

Found in version 28.0.50

Fixed in version 28.1

Done: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 40693 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: Ivan Andrus <darthandrus <at> gmail.com>, 40693 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#40693: 28.0.50; json-encode-alist changes alist
Date: Sun, 19 Apr 2020 01:33:55 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Why?  Isn't this a classical example of modifiable code?  After some
> iterations
>
> (symbol-function 'fun-withdraw)
>
> =>
>
> (closure
>  (t)
>  (amount)
>  (json-encode-alist
>   (cons
>    (cons 'tamount amount)
>    '((const . some-constant)
>      (tamount . 12)
>      (tamount . 12)
>      (tamount . 12)))))
>
> So the problem is in the implementation of `fun-withdraw', not in that
> of `json-encode-alist' or `sort'.
>
> I mean, it's really an example of an ugly trap, but how is
> `json-encode-alist' different from other functions working with lists
> that would exploit the same problem?

A library function that encodes arbitrary Elisp objects as JSON
shouldn't destructively modify its argument; it should be possible to
call json-encode on the same object twice and get the same result.

-- 
Basil




This bug report was last modified 5 years and 58 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.