[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

byte-compile-preprocess+cconv seem to mutate self evaluating forms in ex

From: Vibhav Pant
Subject: byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros
Date: Fri, 20 Jan 2023 18:10:16 +0530
User-agent: Evolution 3.46.3

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

(defmacro define-purecopied-func ()
  `(defun foo-bar (arg)

(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
shouldn't we be use 'copy-tree' after macro expansion in these cases?

Vibhav Pant
GPG: 7ED1 D48C 513C A024 BE3A  785F E3FB 28CB 6AB5 9598

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]