GNU bug report logs -
#23648
[PATCH] `defun-declarations-alist' can be unintentionally modified
Previous Next
Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>
Date: Sun, 29 May 2016 14:12:02 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 25.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23648 in the body.
You can then email your comments to 23648 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Sun, 29 May 2016 14:12:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Pogonyshev <pogonyshev <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 29 May 2016 14:12:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I quite often get the following messages:
Warning: Unknown defun property ‘compiler-macro’ in ...
As far as I could trace it, the problem is indirectly caused by
`define-inline'. While definition of `defun-declarations-alist' does
contain `compiler-macro' in its init form, it can be removed later.
E.g. when I evaluated the variable, it was not there anymore, only
`gv-setter' was there.
It seems this is done unintentionally by `elisp-completion-at-point':
(`declare
(list t (mapcar (lambda (x) (symbol-name (car x)))
(delete-dups
;; FIXME: We should include some
;; docstring with each entry.
(append
macro-declarations-alist
defun-declarations-alist)))))
Here `delete-dups' destructively modifies a list that includes
`defun-declarations-alist' as its tail verbatim, not as a copy.
Attached patch should fix that.
Paul
* elisp-mode.el (elisp-completion-at-point): Fix to not alter
`defun-declarations-alist' by side effect.
[xxx.diff (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 03:01:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 23648 <at> debbugs.gnu.org (full text, mbox):
Paul Pogonyshev <pogonyshev <at> gmail.com> writes:
> I quite often get the following messages:
>
> Warning: Unknown defun property ‘compiler-macro’ in ...
>
> As far as I could trace it, the problem is indirectly caused by
> `define-inline'. While definition of `defun-declarations-alist' does
> contain `compiler-macro' in its init form, it can be removed later.
> E.g. when I evaluated the variable, it was not there anymore, only
> `gv-setter' was there.
>
> It seems this is done unintentionally by `elisp-completion-at-point':
>
> (`declare
> (list t (mapcar (lambda (x) (symbol-name (car x)))
> (delete-dups
> ;; FIXME: We should include some
> ;; docstring with each entry.
> (append
> macro-declarations-alist
> defun-declarations-alist)))))
>
> Here `delete-dups' destructively modifies a list that includes
> `defun-declarations-alist' as its tail verbatim, not as a copy.
> Attached patch should fix that.
I agree with analysis and patch here. Since this just appends another
nil, it should be safe for emacs-25, right?
>
> Paul
>
> * elisp-mode.el (elisp-completion-at-point): Fix to not alter
> `defun-declarations-alist' by side effect.
> - (append
> - macro-declarations-alist
> - defun-declarations-alist)))))
> + (append macro-declarations-alist
> + defun-declarations-alist
> + nil)))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 14:34:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 23648 <at> debbugs.gnu.org (full text, mbox):
> From: npostavs <at> users.sourceforge.net
> Date: Sun, 17 Jul 2016 23:00:33 -0400
> Cc: 23648 <at> debbugs.gnu.org
>
> I agree with analysis and patch here. Since this just appends another
> nil, it should be safe for emacs-25, right?
I'm not sure, actually. How probable is the situation where this
problem pops up? And when was the bug introduced?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 15:54:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 23648 <at> debbugs.gnu.org (full text, mbox):
On Mon, Jul 18, 2016 at 10:33 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: npostavs <at> users.sourceforge.net
>> Date: Sun, 17 Jul 2016 23:00:33 -0400
>> Cc: 23648 <at> debbugs.gnu.org
>>
>> I agree with analysis and patch here. Since this just appends another
>> nil, it should be safe for emacs-25, right?
>
> I'm not sure, actually. How probable is the situation where this
> problem pops up?
It happens with 100% probability when performing completion inside a
(declare ...) form. Starting from emacs -Q, put into *scratch*
(defun foo ()
(declare (indent 1))
nil)
Macroexpanding this gives:
(prog1
(defalias 'foo
#'(lambda nil nil))
(put 'foo 'lisp-indent-function '1))
Now move point to just after "indent" and type C-M-i (this gives
message "Sole completion"), macroexpanding now gives
(prog1
(defalias 'foo
#'(lambda nil nil))
"Warning: Unknown defun property `indent' in foo")
> And when was the bug introduced?
Code seems to have been that way since it was introduced in 24.4:
dd8791e9 "* lisp/emacs-lisp/lisp.el (lisp-completion-at-point):
Provide specialized
completion tables when completing error conditions and
`declare' arguments...."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 18:17:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 23648 <at> debbugs.gnu.org (full text, mbox):
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> Date: Mon, 18 Jul 2016 11:53:42 -0400
> Cc: Paul Pogonyshev <pogonyshev <at> gmail.com>, 23648 <at> debbugs.gnu.org
>
> > I'm not sure, actually. How probable is the situation where this
> > problem pops up?
>
> It happens with 100% probability when performing completion inside a
> (declare ...) form. Starting from emacs -Q, put into *scratch*
>
> (defun foo ()
> (declare (indent 1))
> nil)
>
> Macroexpanding this gives:
>
> (prog1
> (defalias 'foo
> #'(lambda nil nil))
> (put 'foo 'lisp-indent-function '1))
>
> Now move point to just after "indent" and type C-M-i (this gives
> message "Sole completion"), macroexpanding now gives
>
> (prog1
> (defalias 'foo
> #'(lambda nil nil))
> "Warning: Unknown defun property `indent' in foo")
Sorry, I'm not following: what do you mean by "macroexpanding" in this
context? When you wrote "when performing completion", I expected to
see some simple completion gesture that leads to an error, but it
sounds like I'm missing something.
> > And when was the bug introduced?
>
> Code seems to have been that way since it was introduced in 24.4:
> dd8791e9 "* lisp/emacs-lisp/lisp.el (lisp-completion-at-point):
> Provide specialized
> completion tables when completing error conditions and
> `declare' arguments...."
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 18:59:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 23648 <at> debbugs.gnu.org (full text, mbox):
On Mon, Jul 18, 2016 at 2:16 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
>> Date: Mon, 18 Jul 2016 11:53:42 -0400
>> Cc: Paul Pogonyshev <pogonyshev <at> gmail.com>, 23648 <at> debbugs.gnu.org
>>
>> > I'm not sure, actually. How probable is the situation where this
>> > problem pops up?
>>
>> It happens with 100% probability when performing completion inside a
>> (declare ...) form. Starting from emacs -Q, put into *scratch*
>>
>> (defun foo ()
>> (declare (indent 1))
>> nil)
>>
>> Macroexpanding this gives:
>>
>> (prog1
>> (defalias 'foo
>> #'(lambda nil nil))
>> (put 'foo 'lisp-indent-function '1))
>>
>> Now move point to just after "indent" and type C-M-i (this gives
>> message "Sole completion"), macroexpanding now gives
>>
>> (prog1
>> (defalias 'foo
>> #'(lambda nil nil))
>> "Warning: Unknown defun property `indent' in foo")
>
> Sorry, I'm not following: what do you mean by "macroexpanding" in this
> context?
Calling macroexpand on the defun form. The most convenient method for
testing is to put point at the closing bracket of the defun, and then
`M-x pp-macroexpand-last-sexp'.
> When you wrote "when performing completion", I expected to
> see some simple completion gesture that leads to an error, but it
> sounds like I'm missing something.
The simple completion gesture would be the C-M-i I mentioned, which
(silently) destroys the value of defun-declarations-alist. The
symptoms of the wrong value can be seen when defun is macroexpanded.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 19:10:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 23648 <at> debbugs.gnu.org (full text, mbox):
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> Date: Mon, 18 Jul 2016 14:58:20 -0400
> Cc: Paul Pogonyshev <pogonyshev <at> gmail.com>, 23648 <at> debbugs.gnu.org
>
> >> Now move point to just after "indent" and type C-M-i (this gives
> >> message "Sole completion"), macroexpanding now gives
> >>
> >> (prog1
> >> (defalias 'foo
> >> #'(lambda nil nil))
> >> "Warning: Unknown defun property `indent' in foo")
> >
> > Sorry, I'm not following: what do you mean by "macroexpanding" in this
> > context?
>
> Calling macroexpand on the defun form. The most convenient method for
> testing is to put point at the closing bracket of the defun, and then
> `M-x pp-macroexpand-last-sexp'.
>
> > When you wrote "when performing completion", I expected to
> > see some simple completion gesture that leads to an error, but it
> > sounds like I'm missing something.
>
> The simple completion gesture would be the C-M-i I mentioned, which
> (silently) destroys the value of defun-declarations-alist. The
> symptoms of the wrong value can be seen when defun is macroexpanded.
Sorry, I guess I'm too stupid to understand this advanced stuff. Or
maybe it's too late.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 19:19:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 23648 <at> debbugs.gnu.org (full text, mbox):
On 07/18/2016 06:00 AM, npostavs <at> users.sourceforge.net wrote:
>> Here `delete-dups' destructively modifies a list that includes
>> `defun-declarations-alist' as its tail verbatim, not as a copy.
>> Attached patch should fix that.
>
> I agree with analysis and patch here.
I like the patch as well. Maybe it would be better to use
cl-remove-duplicates with nconc instead (the use of nil is a little
non-obvious), but that would require having cl-lib loaded at runtime,
and elisp-mode depending on it.
In any case, the proposed patch looks safe.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Mon, 18 Jul 2016 21:30:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 23648 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> Sorry, I guess I'm too stupid to understand this advanced stuff. Or
> maybe it's too late.
I think the example uses macroexpand only to demonstrate what (obviously
ill) code you will get when you compile the mentioned form after
performing the completion as mentioned.
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Tue, 19 Jul 2016 02:42:01 GMT)
Full text and
rfc822 format available.
Message #32 received at 23648 <at> debbugs.gnu.org (full text, mbox):
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Cc: Noam Postavsky <npostavs <at> users.sourceforge.net>, 23648 <at> debbugs.gnu.org, pogonyshev <at> gmail.com
> Date: Mon, 18 Jul 2016 23:28:55 +0200
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > Sorry, I guess I'm too stupid to understand this advanced stuff. Or
> > maybe it's too late.
>
> I think the example uses macroexpand only to demonstrate what (obviously
> ill) code you will get when you compile the mentioned form after
> performing the completion as mentioned.
Thanks, but I'm still none the wiser about the questions I asked.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Thu, 21 Jul 2016 01:10:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 23648 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Michael Heerdegen <michael_heerdegen <at> web.de>
>> Cc: Noam Postavsky <npostavs <at> users.sourceforge.net>, 23648 <at> debbugs.gnu.org, pogonyshev <at> gmail.com
>> Date: Mon, 18 Jul 2016 23:28:55 +0200
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>> > Sorry, I guess I'm too stupid to understand this advanced stuff. Or
>> > maybe it's too late.
>>
>> I think the example uses macroexpand only to demonstrate what (obviously
>> ill) code you will get when you compile the mentioned form after
>> performing the completion as mentioned.
>
> Thanks, but I'm still none the wiser about the questions I asked.
Hmm, maybe it will be clearer like this:
Evaluate:
(macroexpand '(defun foo ()
(declare (indent 1))
nil)) ;=> (prog1 (defalias (quote foo) (function (lambda nil nil))) (function-put (quote foo) (quote lisp-indent-function) (quote 1)))
This gives the correct result (the (function-put...) part comes from the
(declare (indent 1))).
Now perform a completion on a declare clause, e.g., put cursor after
"ind" and hit C-M-i: (declare (ind)) completes to (declare (indent)).
Now evaluate the same expression as before:
(macroexpand '(defun foo ()
(declare (indent 1))
nil)) ;=> (prog1 (defalias (quote foo) (function (lambda nil nil))) "Warning: Unknown defun property ‘indent’ in foo")
This give the wrong result, the (declare (indent 1)) is giving the
"Warning:...". Emacs has unlearned the indent declaration. In fact it
unlearned all the declarations for defun except for gv-setter, you can
see this by looking at defun-declarations-alist's value.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Thu, 21 Jul 2016 14:24:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 23648 <at> debbugs.gnu.org (full text, mbox):
> From: npostavs <at> users.sourceforge.net
> Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 23648 <at> debbugs.gnu.org, pogonyshev <at> gmail.com
> Date: Wed, 20 Jul 2016 21:09:42 -0400
>
> > Thanks, but I'm still none the wiser about the questions I asked.
>
> Hmm, maybe it will be clearer like this:
>
> Evaluate:
>
> (macroexpand '(defun foo ()
> (declare (indent 1))
> nil)) ;=> (prog1 (defalias (quote foo) (function (lambda nil
> nil))) (function-put (quote foo) (quote lisp-indent-function) (quote 1)))
>
> This gives the correct result (the (function-put...) part comes from the
> (declare (indent 1))).
>
> Now perform a completion on a declare clause, e.g., put cursor after
> "ind" and hit C-M-i: (declare (ind)) completes to (declare (indent)).
>
> Now evaluate the same expression as before:
>
> (macroexpand '(defun foo ()
> (declare (indent 1))
> nil)) ;=> (prog1 (defalias (quote foo) (function (lambda nil
> nil))) "Warning: Unknown defun property ‘indent’ in foo")
>
> This give the wrong result, the (declare (indent 1)) is giving the
> "Warning:...". Emacs has unlearned the indent declaration. In fact it
> unlearned all the declarations for defun except for gv-setter, you can
> see this by looking at defun-declarations-alist's value.
Thanks, but I think we are mis-communicating. What I need is not a
demonstration of the bug in action; I already got that. What I asked
for is different:
> How probable is the situation where this problem pops up? And when
> was the bug introduced?
You already answered the second question. For the first, I expected
to see something done frequently by either users or Lisp programs,
which bumps into this bug. Evaluating macroexpand, twice, with
completion in-between, doesn't qualify in my book as a frequent user
action, I hope you will agree (even if you personally happen to use it
quite a lot).
So I'm still looking for the answer to the "how probable" question. I
need that to make up my mind about the urgency of the fix.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Thu, 21 Jul 2016 21:28:01 GMT)
Full text and
rfc822 format available.
Message #41 received at 23648 <at> debbugs.gnu.org (full text, mbox):
On Thu, Jul 21, 2016 at 10:22 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> Thanks, but I think we are mis-communicating. What I need is not a
> demonstration of the bug in action; I already got that. What I asked
> for is different:
>
>> How probable is the situation where this problem pops up? And when
>> was the bug introduced?
>
> You already answered the second question. For the first, I expected
> to see something done frequently by either users or Lisp programs,
> which bumps into this bug. Evaluating macroexpand, twice, with
> completion in-between, doesn't qualify in my book as a frequent user
> action, I hope you will agree (even if you personally happen to use it
> quite a lot).
>
> So I'm still looking for the answer to the "how probable" question. I
> need that to make up my mind about the urgency of the fix.
Ah, okay. The probability of a user hitting this depends on how likely
they are to perform completion inside a declare form. This depends on
the kind of code the user writes, so it's hard to put a number on it.
Also, if the user has a package like company enabled that performs
completion during idle time, then just moving point through a declare
form should be enough to trigger it, so in this case it might depend
also on the kind of code the user reads. If the user never opens an
elisp file with declare forms, then they certainly won't hit this.
Once the user has triggered the problem via completion, all
compilation of defuns (e.g. during package installation/upgrade) with
declare forms will be broken (as well as loading uncompiled defuns
with declare forms). Admittedly only gv-expander (along with
gv-setter, but that one doesn't get unlearned) is vital to correct
compilation, the rest (advertised-calling-convention obsolete
interactive-only pure side-effect-free compiler-macro doc-string
indent) are only optimizations or advisory in nature.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Sat, 23 Jul 2016 08:55:02 GMT)
Full text and
rfc822 format available.
Message #44 received at 23648 <at> debbugs.gnu.org (full text, mbox):
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> Date: Thu, 21 Jul 2016 17:27:49 -0400
> Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 23648 <at> debbugs.gnu.org,
> Paul Pogonyshev <pogonyshev <at> gmail.com>
>
> > So I'm still looking for the answer to the "how probable" question. I
> > need that to make up my mind about the urgency of the fix.
>
> Ah, okay. The probability of a user hitting this depends on how likely
> they are to perform completion inside a declare form. This depends on
> the kind of code the user writes, so it's hard to put a number on it.
> Also, if the user has a package like company enabled that performs
> completion during idle time, then just moving point through a declare
> form should be enough to trigger it, so in this case it might depend
> also on the kind of code the user reads. If the user never opens an
> elisp file with declare forms, then they certainly won't hit this.
>
> Once the user has triggered the problem via completion, all
> compilation of defuns (e.g. during package installation/upgrade) with
> declare forms will be broken (as well as loading uncompiled defuns
> with declare forms). Admittedly only gv-expander (along with
> gv-setter, but that one doesn't get unlearned) is vital to correct
> compilation, the rest (advertised-calling-convention obsolete
> interactive-only pure side-effect-free compiler-macro doc-string
> indent) are only optimizations or advisory in nature.
OK, let's push to emacs-25. Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Sat, 23 Jul 2016 14:19:02 GMT)
Full text and
rfc822 format available.
Message #47 received at 23648 <at> debbugs.gnu.org (full text, mbox):
tags 23648 fixed
close 23648 25.1
quit
Eli Zaretskii <eliz <at> gnu.org> writes:
> OK, let's push to emacs-25. Thanks.
Push as bc4c07fc.
Added tag(s) fixed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 23 Jul 2016 14:19:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 25.1, send any further explanations to
23648 <at> debbugs.gnu.org and Paul Pogonyshev <pogonyshev <at> gmail.com>
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sat, 23 Jul 2016 14:19:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Sun, 24 Jul 2016 17:09:02 GMT)
Full text and
rfc822 format available.
Message #54 received at 23648 <at> debbugs.gnu.org (full text, mbox):
Shouldn't it be also merged to master?
Paul
On 23 July 2016 at 16:18, <npostavs <at> users.sourceforge.net> wrote:
> tags 23648 fixed
> close 23648 25.1
> quit
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> OK, let's push to emacs-25. Thanks.
>
> Push as bc4c07fc.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23648
; Package
emacs
.
(Sun, 24 Jul 2016 17:32:01 GMT)
Full text and
rfc822 format available.
Message #57 received at 23648 <at> debbugs.gnu.org (full text, mbox):
> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> Date: Sun, 24 Jul 2016 19:07:59 +0200
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 23648 <at> debbugs.gnu.org, michael_heerdegen <at> web.de
>
> Shouldn't it be also merged to master?
It will be, when the next merge takes place.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 22 Aug 2016 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 306 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.