From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vibhav Pant Newsgroups: gmane.emacs.devel Subject: byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros Date: Fri, 20 Jan 2023 18:10:16 +0530 Message-ID: <72894d80f874ba934fab76ada4ab366c27831d8d.camel@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-zz/WdVu6XpwPYhmEiZWu" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31416"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.46.3 To: emacs-devel , monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 20 13:41:31 2023 Return-path: Envelope-to: ged-emacs-devel@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 1pIqi2-000815-Jy for ged-emacs-devel@m.gmane-mx.org; Fri, 20 Jan 2023 13:41:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIqh7-0006qB-96; Fri, 20 Jan 2023 07:40:33 -0500 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 1pIqh5-0006pk-OC for emacs-devel@gnu.org; Fri, 20 Jan 2023 07:40:31 -0500 Original-Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIqh4-0002r1-0J for emacs-devel@gnu.org; Fri, 20 Jan 2023 07:40:31 -0500 Original-Received: by mail-ej1-x62e.google.com with SMTP id kt14so13658596ejc.3 for ; Fri, 20 Jan 2023 04:40:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:date:to:from:subject:message-id:from:to:cc :subject:date:message-id:reply-to; bh=SsK7dj+l8uDHD/Vj3ugbCYUuVzr66fnO3WSSZ2g6S44=; b=hwREvVRWm96kNJBECVpyod3XUsWV5y0ElSctGry9rJccGJDALxKTH6kC6wk0kE5J9n DcXyey2I3fHoaMvRAuFT2d8jYFiwDqFXZZXlLNUP+J2px29GrChSw7iD+/m4H9E8PPqJ 9HBjc5fw/hagZkbQ0R2dUHeEmJUe+r5n1bnas2IjcnGU13Tdx+xmjsPdtCweWpX/g81C IaSHYgxN0tWSkyDss6Rv9QZjJpeqdt/u1OjiU+aGbq1IuE+kuAuXnm41M4Mgv3/hQBBt pKHtpmGWGkpifvREa/0e40U04FadJSD/X3v1pkMpGznjWIgV6OgAqRR3MvtAXUrGq3gj BvUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:date:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SsK7dj+l8uDHD/Vj3ugbCYUuVzr66fnO3WSSZ2g6S44=; b=GbFkwvjMObfLDCxZfdjd27wGt8nBiIeQQzDhQvPO+NcvzHd0pUm6IRPDgc/Vzv9tgG zLeffkWoJFPs5INLo1RZ+245ZnIEQNzlh5DFjSuJSZkp6dvqJ03eqUe0dDNSSImIyPE9 2AmHPLE4kGfCFt1X3eEYuA3wO9GRgPzCWoFK1mIy8YO+tiLChgN1xKsqA0efXNa2x/OP p/NFuQieGg900y45PFKZJ/NA8Rsv0EiFBtooPfyUi9i0liQ1dvorDWhrlBWAVYzknt3c vYVJUD5W90wE5Z1bMg8hEtEGdrbKw83vShVYv9pzTOhs21u1IqBTU6PJKaWvpZB9sTJX akyw== X-Gm-Message-State: AFqh2ko/mz3DvXwwsAt9+f2sTD4PIHEzqhoN1lA+0EAvHRJNcTRL/Vy+ hPEqsMwHDxB7pVl29GYEtTT1lepz4AilFg== X-Google-Smtp-Source: AMrXdXsAjJNoI3mTH1aQlTt5dJbi/VZJNwx+hjkzJnJLyx3c9YZTPjNA1mJJmPtbMoh1J1y4bgBIAg== X-Received: by 2002:a17:906:81b:b0:869:a799:1f85 with SMTP id e27-20020a170906081b00b00869a7991f85mr28049219ejd.76.1674218425917; Fri, 20 Jan 2023 04:40:25 -0800 (PST) Original-Received: from vibhavp-mbp.local ([182.69.182.193]) by smtp.gmail.com with ESMTPSA id p11-20020a05640243cb00b0049e19136c22sm6560701edc.95.2023.01.20.04.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 04:40:25 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=vibhavp@gmail.com; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302572 Archived-At: --=-zz/WdVu6XpwPYhmEiZWu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable While working on scratch/comp-static-data, which adds support for native compiling self evaluating forms in Lisp code as static consts in the eln (with immutability enforced additionally by `CHECK_IMPURE`), I noticed that compiling minor-mode definitions would result in a `pure_write_error`. This arises as cconv-closure-convert, called from `byte-compile-preprocess` would call `setcar` on a self evaluating interactive form as part of the minor-mode's function body. A hacky way to reproduce this would be to stuff the following snippet into loadup.el (purecopy ensures modifying the list triggers an error): ``` (load "emacs-lisp/bytecomp") (setq sample-interactive-spec (purecopy '(interactive (list (if current-prefix-arg (prefix-numeric-value=20 current-prefix-arg) 'toggle))))) (defmacro define-purecopied-func () `(defun foo-bar (arg) ,sample-interactive-spec)) (let ((byte-compile-debug t)) (byte-compile '(define-purecopied-func))) ``` (Alternatively, just building scratch/comp-static-data will also reproduce these errors) Because modifying self-evaluating forms is technically undefined behaviour as per the Elisp reference manual (https://www.gnu.org/software/emacs/manual/html_node/elisp/Mutability.html)= , shouldn't we be use 'copy-tree' after macro expansion in these cases? --=20 Vibhav Pant vibhavp@gmail.com GPG: 7ED1 D48C 513C A024 BE3A 785F E3FB 28CB 6AB5 9598 --=-zz/WdVu6XpwPYhmEiZWu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEftHUjFE8oCS+Onhf4/soy2q1lZgFAmPKi7AACgkQ4/soy2q1 lZh4FggAi1Eb+/pUNyWj/rf25ZG4Acdp1fiIkWlQ8RN+wt4Emt4evUcp2micXAHr t0GZTyejLLdjPNLvwlhLeqTmQwEw9Xm7dMhJVi5zKJeKo5itdH3UlO5Sbv/iR6DQ 8NtChji8rqYLkWUBOYx2i9ojyApOg+wxKQ0QKRV1DG9Bnh5Yma24qxiDW+2NcCJe 9g6XP8QOgt4sS/ep3uZfIGlERcC5YQZvt7duVKwRPQbzQmp8N1UjgIMpQ8DV+Ov8 rpmXW+avU7kMZvMfu79SHSaU61a1yZygmhD+evb3U9kJqdgLB/0pfkAmhQoOwjQ5 jOoQz24YVM9ExaZeEw9RRHix2xR54w== =ap7z -----END PGP SIGNATURE----- --=-zz/WdVu6XpwPYhmEiZWu--