GNU bug report logs -
#5450
Variable Capturing and other problems in assoc.el
Previous Next
Reported by: michael_heerdegen <at> web.de
Date: Fri, 22 Jan 2010 18:08:01 UTC
Severity: normal
Done: Chong Yidong <cyd <at> stupidchicken.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hello,
In the code of assoc.el, local variables in the functions `aput',
`adelete' and `amake' may hide the alist-symbol in the `eval'-clauses,
which produces wrong results.
Example:
(tested with my Emacs 22 -Q, and also with the current CVS version of
assoc.el):
ELISP> (require 'assoc)
assoc
ELISP> (setq alist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (setq blist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (aput 'alist "a" 123456)
(("a" . 123456))
ELISP> (aput 'blist "a" 123456)
("a" . 123456)
ELISP> alist
(("a" . 1)
("b" . 2))
ELISP> blist
(("a" . 123456)
("b" . 2))
------
ELISP> (setq alist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (setq blist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (adelete 'alist "a")
(("b" . 2))
ELISP> (adelete 'blist "a")
(("b" . 2))
ELISP> alist
(("a" . 1)
("b" . 2))
ELISP> blist
(("b" . 2))
---
Another thing: the doc of `aelement' is misleading in my opinion:
aelement is a compiled Lisp function in `assoc.el'.
(aelement KEY VALUE)
Makes a list of a cons cell containing car of KEY and cdr of VALUE.
The returned list is suitable as an element of an alist.
The returned value is an one element list with a cons cell, suitable
for `nconc', but not directly as an element of an alist.
---
It is also not fine that `amake' doesn't assign to unbound symbols:
ELISP> (amake 'clist '("a" "b") '(1 2))
*** Eval error *** Symbol's value as variable is void: clist
so the package misses a real alist constructor.
This bug report was last modified 15 years and 117 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.