From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Newsgroups: gmane.emacs.bugs Subject: bug#40692: 28.0.50; Constant list modified inside function Date: Sat, 18 Apr 2020 11:18:46 +0200 Message-ID: <87ftd1883t.fsf@gmail.com> References: <57990C74-5CA1-42E6-83EC-7F6858AFD0E7@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="8915"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 40692@debbugs.gnu.org To: Ivan Andrus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 18 11:19:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPjd2-0002Bk-6b for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 11:19:12 +0200 Original-Received: from localhost ([::1]:56156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPjd0-0007zB-RL for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Apr 2020 05:19:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58125) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPjct-0007yr-Pd for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 05:19:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPjcs-0001Yw-F7 for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 05:19:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jPjcs-0001XJ-C2 for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 05:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jPjcs-0004zw-5E for bug-gnu-emacs@gnu.org; Sat, 18 Apr 2020 05:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Apr 2020 09:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40692 X-GNU-PR-Package: emacs Original-Received: via spool by 40692-submit@debbugs.gnu.org id=B40692.158720149619155 (code B ref 40692); Sat, 18 Apr 2020 09:19:02 +0000 Original-Received: (at 40692) by debbugs.gnu.org; 18 Apr 2020 09:18:16 +0000 Original-Received: from localhost ([127.0.0.1]:41995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPjc8-0004ys-F9 for submit@debbugs.gnu.org; Sat, 18 Apr 2020 05:18:16 -0400 Original-Received: from mail-wm1-f49.google.com ([209.85.128.49]:36666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPjc6-0004yg-Vv for 40692@debbugs.gnu.org; Sat, 18 Apr 2020 05:18:15 -0400 Original-Received: by mail-wm1-f49.google.com with SMTP id u127so4310196wmg.1 for <40692@debbugs.gnu.org>; Sat, 18 Apr 2020 02:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=ioRt1eDxTrBFg66yXipuTiuHPJFnE/eGlYIEnKlsBv0=; b=FzAPGPq8YnwMH7cJj0Ws8q9ZMpN1x9l5mAnEj8bWkWlfFQz2wiTqnlYFQoM8jb63jk GhllXFk6unftUjSzq6AS0WRd5HP5xHSHCTF2ZrllyvUtbsfwixsGRkajrS4rgr6rY2sw wsYh8pXZah4R07frwFfUGo/dtD+166Q6fpMbqJr81fruuYjcxvcRlU2YT1vTLx5tBugi HEYT73/LXgZsbLTLeNAVlecSq7wcxfTUvGyl/s3bkbi7GbBK9ws11c1hY+SQdsLUzUtC G0/QQ7ps/8Ua5biRnZq4+OKdBJ2ps5y1eaZuTOjvwffKEMKd5Lw1VOR+zdQ8uFeTR5KS BN6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=ioRt1eDxTrBFg66yXipuTiuHPJFnE/eGlYIEnKlsBv0=; b=nS0nuahDlcMvWf/twtkOwKHfsfUCO5kPz7DDsgJg9o2u9RCWB9LTuK+bZ/nIAm1CTl XkHyFKdFCd1nu6L3RB1gsuwqK+z64rkGw7I6XZpXQxLEd15Q6cN6/saTPZiDvTJCLY+l mcyWvqy9Scq0xGUR2BYAVq+WX8dyxuJpY3ALTvij4SJs6PcfBlNrYbtyGhS8ewUT6LBD TxwshqEdY/Ipa7l4mROfBlN6CnOZrLvx+O09U8cF2TUoAbWJ5doxTY7LtgsQcTBLo6XZ aSDi2B+PZ4CfRx+VADQYxLdG6LNpmg/UqsUbK4pPvm2WhmzoXP4qur/Fx4ulTAYvFBlb v9aA== X-Gm-Message-State: AGi0PubNb57DTWoMFNVSw18Tp75pON56nqatmH323i49r8aZTh+2ohuR wk+ZfcDjza9u/1QbOMhIl4M= X-Google-Smtp-Source: APiQypLfQEZHYxXTqQfLCB3P30rmOL8dV/gsWq02bryRlw67w7ryXeVxKBjS1lrKLGaTzBmErGccqQ== X-Received: by 2002:a7b:c456:: with SMTP id l22mr7156627wmi.148.1587201489053; Sat, 18 Apr 2020 02:18:09 -0700 (PDT) Original-Received: from localhost ([185.112.167.47]) by smtp.gmail.com with ESMTPSA id u17sm38897865wra.63.2020.04.18.02.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Apr 2020 02:18:08 -0700 (PDT) In-Reply-To: <57990C74-5CA1-42E6-83EC-7F6858AFD0E7@gmail.com> (Ivan Andrus's message of "Fri, 17 Apr 2020 17:45:12 -0600") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:178553 Archived-At: On Fri, 17 Apr 2020 17:45:12 -0600 Ivan Andrus wrote: > 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, I think it is, although I admit I was confused by it, too, as I've somehow come to believe that e.g. `(list) macroexpands to (list 'list), but that's not the case: it expands to '(list). > 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? If you change the backquoted form in `fun-withdraw' to (list `(amount . ,amount) '(const . some-constant)) it works as desired.