unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros
@ 2023-01-20 12:40 Vibhav Pant
  2023-01-20 13:03 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Vibhav Pant @ 2023-01-20 12:40 UTC (permalink / raw)
  To: emacs-devel, monnier

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros
  2023-01-20 12:40 byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros Vibhav Pant
@ 2023-01-20 13:03 ` Stefan Monnier
  2023-01-20 13:13   ` Vibhav Pant
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2023-01-20 13:03 UTC (permalink / raw)
  To: Vibhav Pant; +Cc: emacs-devel

Hi,

> 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.

Sounds like a bug.  Can you `M-x report-emacs-bug` (and put me in
`X-Debbugs-Cc:`) so we get a bug#nb for it?


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros
  2023-01-20 13:03 ` Stefan Monnier
@ 2023-01-20 13:13   ` Vibhav Pant
  2023-01-20 18:21     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Vibhav Pant @ 2023-01-20 13:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

On Fri, 2023-01-20 at 08:03 -0500, Stefan Monnier wrote:
> Hi,
> 
> > 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.
> 
> Sounds like a bug.  Can you `M-x report-emacs-bug` (and put me in
> `X-Debbugs-Cc:`) so we get a bug#nb for it?
> 
> 
>         Stefan
> 

Hi Stefan,

The error doesn't come up on master, because we don't enforce the
immutability of self evaluating forms. Becuase the same files get
compiled just fine on master, does it still count as a bug?

Thanks,
Vibhav

-- 
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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros
  2023-01-20 13:13   ` Vibhav Pant
@ 2023-01-20 18:21     ` Stefan Monnier
  2023-01-20 21:27       ` Vibhav Pant
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2023-01-20 18:21 UTC (permalink / raw)
  To: Vibhav Pant; +Cc: emacs-devel

> The error doesn't come up on master, because we don't enforce the
> immutability of self evaluating forms. Becuase the same files get
> compiled just fine on master, does it still count as a bug?

Yes.


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros
  2023-01-20 18:21     ` Stefan Monnier
@ 2023-01-20 21:27       ` Vibhav Pant
  0 siblings, 0 replies; 5+ messages in thread
From: Vibhav Pant @ 2023-01-20 21:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

On Fri, 2023-01-20 at 13:21 -0500, Stefan Monnier wrote:
> > The error doesn't come up on master, because we don't enforce the
> > immutability of self evaluating forms. Becuase the same files get
> > compiled just fine on master, does it still count as a bug?
> 
> Yes.
> 
> 
>         Stefan
> 

Done, thanks.

-- 
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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-20 21:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 12:40 byte-compile-preprocess+cconv seem to mutate self evaluating forms in expanded macros Vibhav Pant
2023-01-20 13:03 ` Stefan Monnier
2023-01-20 13:13   ` Vibhav Pant
2023-01-20 18:21     ` Stefan Monnier
2023-01-20 21:27       ` Vibhav Pant

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).