From: Vibhav Pant <vibhavp@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>, monnier@iro.umontreal.ca
Subject: byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros
Date: Fri, 20 Jan 2023 18:10:16 +0530 [thread overview]
Message-ID: <72894d80f874ba934fab76ada4ab366c27831d8d.camel@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]
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
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?
--
Vibhav Pant
vibhavp@gmail.com
GPG: 7ED1 D48C 513C A024 BE3A 785F E3FB 28CB 6AB5 9598
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next reply other threads:[~2023-01-20 12:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 12:40 Vibhav Pant [this message]
2023-01-20 13:03 ` byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros Stefan Monnier
2023-01-20 13:13 ` Vibhav Pant
2023-01-20 18:21 ` Stefan Monnier
2023-01-20 21:27 ` Vibhav Pant
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=72894d80f874ba934fab76ada4ab366c27831d8d.camel@gmail.com \
--to=vibhavp@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.