From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#64127: 30.0.50; mutate-constant warning with pure function Date: Sat, 17 Jun 2023 13:58:08 +0200 Message-ID: <42E68F81-EDE7-45E4-AF08-BF420EE53F4B@gmail.com> References: <87ttv6b9zh.fsf@epfl.ch> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1379"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64127@debbugs.gnu.org To: Basil Contovounesios Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 17 13:59:38 2023 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 1qAUaf-00008g-Ga for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 17 Jun 2023 13:59:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qAUa8-0006BH-9W; Sat, 17 Jun 2023 07:59:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qAUa6-0006B4-Fs for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 07:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qAUa6-0003CH-5l for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 07:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qAUa5-0000Vh-Lm for bug-gnu-emacs@gnu.org; Sat, 17 Jun 2023 07:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 17 Jun 2023 11:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64127 X-GNU-PR-Package: emacs Original-Received: via spool by 64127-submit@debbugs.gnu.org id=B64127.16870031001908 (code B ref 64127); Sat, 17 Jun 2023 11:59:01 +0000 Original-Received: (at 64127) by debbugs.gnu.org; 17 Jun 2023 11:58:20 +0000 Original-Received: from localhost ([127.0.0.1]:50971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAUZQ-0000Ui-Bo for submit@debbugs.gnu.org; Sat, 17 Jun 2023 07:58:20 -0400 Original-Received: from mail-lf1-f45.google.com ([209.85.167.45]:42381) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qAUZM-0000UO-6q for 64127@debbugs.gnu.org; Sat, 17 Jun 2023 07:58:18 -0400 Original-Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-4f762b3227dso2118355e87.1 for <64127@debbugs.gnu.org>; Sat, 17 Jun 2023 04:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687003090; x=1689595090; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=PzSQYxacgWgAUuvziJM9ak8MCYmkFMiUC++6LnWHTXE=; b=TtBBHRqRAMt8D9l8gg1+CVPWfLPU2LYI67usJes5rdahTdnHa7C0/wq066/rL6vbJB cKc5kz4J4dfHjmtjvnXxWkYkXBGNhvW1QnfJnWei/qVs1+WFPS5rDQwF3wwvj98A09qr RlOpY96AzNrC+i9WqQIkPOkmw8+bn6/sH1+n3/QUXAkDWNxCMGzu3ZPZJDBpjb+QsFgq lKLUJt3gu2AS3FtfZnj1QX3TIj6M+SouMPkybzl6QAsQVN1JjaiJoeBDH+rzZFpY7uCn q3Glxw17R9dUocXFhbAHrogldCujnqXoPdLyLqWPMA3FuL5sx4Xo2yLj/xVNVQ6Vv8bT 8e0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687003090; x=1689595090; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=PzSQYxacgWgAUuvziJM9ak8MCYmkFMiUC++6LnWHTXE=; b=Jic5XkfINtWTvNFIcpcj2f5vfDl7fLYoxc1TA7wRPz7xf+Ld1W8CEkHVKw4MZoPs23 M0WapqqCs4eOT7KYXpjDcQznvQDg/jbARn9C+5IgwW6Nc7bQlMXarCDO+juIItWEJylz us6xO2/CosRJSE9DKRWVNHIUu748IYjKg03UdA7tFs4TAWt4NeZj3pQs1sRbXYddwerT ko3n3UlUuC4pIUBqOR8YwT9bPsLFTPgzDRRFArCjKuBwZujWksq4twd28YOKv8Al6vkp OURq3BsQa54cQFnCr2jDTfxq8YiJUIwWyipMUwFxoxdOeWlN/1nutxgeGcEa/Qwyy7Pc wkxQ== X-Gm-Message-State: AC+VfDy7dyCjfv+tjhXjdgwn6oyxzjmKItle9eot5p26vwZ+FVX6xgE0 t+Un4ihIcBVRo15OIbEPiXc= X-Google-Smtp-Source: ACHHUZ7DRH67H57fEjcjRi8BlmlYJLQHCRk8bLahzEFggFZuuVX+AdQWr6aT3L47Cpv5xw2g+C+QXw== X-Received: by 2002:a05:6512:e96:b0:4f8:586a:d6ca with SMTP id bi22-20020a0565120e9600b004f8586ad6camr1217622lfb.9.1687003089685; Sat, 17 Jun 2023 04:58:09 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se. [188.150.165.235]) by smtp.gmail.com with ESMTPSA id n18-20020a2e86d2000000b002ada919a09asm4112870ljj.73.2023.06.17.04.58.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Jun 2023 04:58:09 -0700 (PDT) In-Reply-To: <87ttv6b9zh.fsf@epfl.ch> X-Mailer: Apple Mail (2.3654.120.0.1.15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263527 Archived-At: 17 juni 2023 kl. 13.32 skrev Basil Contovounesios : > Given a file foo.el that defines a pure function foo: > (defun foo (x) (declare (pure t)) (list x)) > and another file bar.el that mutates the result of foo: > (setcar (foo nil) t) > byte-compiling bar.el emits a mutate-constant warning, even though the > result of foo is a fresh list: No, the `pure` declaration means that the function can be evaluated at = compile time which the compiler happily does, yielding a constant list, = which your code then attempts to modify. This is why the function `list` itself is not declared `pure` -- while = it does look like a pure function when speaking informally, users relies = on it returning a freshly allocated list that can be modified and that = makes it non-pure. (If lists were immutable, then `list` would naturally = be pure.) Only the mutate-constant warning is new here; previously, the compiler = would have let you make this mistake undisturbed. Thus either you remove the pure-declaration from your function, or you = don't mutate what it returns.