From: Ivan Andrus <darthandrus@gmail.com>
To: 40692@debbugs.gnu.org
Subject: bug#40692: 28.0.50; Constant list modified inside function
Date: Fri, 17 Apr 2020 17:45:12 -0600 [thread overview]
Message-ID: <57990C74-5CA1-42E6-83EC-7F6858AFD0E7@gmail.com> (raw)
Starting from Emacs -Q (I am building off of trunk, but my brother verified the same behavior in 26.3), if I evaluate the following code I get an error the second time I call withdraw.
(defmacro show (var)
`(message ,(format "%S %%S" var) ,var))
(defun my-test-fun (amount params)
(when (memq 'tricked-ya params)
(error "What happened here?"))
(show amount)
(show params)
(setcdr (cdr params) (list 'tricked-ya))
(show params))
(defun fun-withdraw (amount)
(my-test-fun amount
`((amount . , amount)
(const . some-constant))))
(fun-withdraw 12)
(fun-withdraw 12) ;; The second time it's called it will error because the "constant" list was modified.
I believe this is the root cause of a bug in magit/forge https://github.com/magit/forge/issues/267 in which all subsequent pull requests created have the same name. The maintainer of magit/forge (tarsius) was unable to reproduce that bug, so I tried my hand at creating a minimal test case, and I was able to get it down to this.
Now, I understand reference semantics of lists in general, but it seems like this should be different. If this behavior is intentional, what's the best way to for creation of a new list every time so that functions using the alist don't have to worry about not changing the list?
-Ivan Andrus
In GNU Emacs 28.0.50 (build 18, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G4032))
of 2020-04-10 built on iandrus-macOS
Repository revision: 965390ca5f206c6358014574fe5140ba40850391 -- some local changes on top of e18c24b35a7cf9bb1b91288b706fa448ed28a7c2
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1671
System Description: Mac OS X 10.14.6
Configured using:
'configure
PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig
--with-sound=yes --with-ns --with-modules --with-file-notification=yes
--enable-gcc-warnings=warn-only --with-xpm --with-jpeg --with-tiff
--with-gif --with-png --with-rsvg --with-xml2 --with-imagemagick
--with-json --with-xft --with-libotf --with-gnutls=no --with-makeinfo
--with-libgmp'
Configured features:
RSVG IMAGEMAGICK GLIB NOTIFY KQUEUE ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
XIM NS MODULES THREADS JSON PDUMPER GMP
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
next reply other threads:[~2020-04-17 23:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 23:45 Ivan Andrus [this message]
2020-04-18 3:05 ` bug#40692: 28.0.50; Constant list modified inside function Ivan Andrus
2020-04-18 9:18 ` Štěpán Němec
2020-04-18 22:49 ` Michael Heerdegen
2020-04-19 7:08 ` Štěpán Němec
2021-08-29 22:18 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57990C74-5CA1-42E6-83EC-7F6858AFD0E7@gmail.com \
--to=darthandrus@gmail.com \
--cc=40692@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).