GNU bug report logs -
#71379
29.3; Elisp compiler: warnings for formats given insufficiently many arguments
Previous Next
Reported by: Philippe Schnoebelen <phs <at> lmf.cnrs.fr>
Date: Wed, 5 Jun 2024 13:17:02 UTC
Severity: normal
Found in version 29.3
Done: Mattias Engdegård <mattias.engdegard <at> gmail.com>
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 71379 in the body.
You can then email your comments to 71379 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#71379
; Package
emacs
.
(Wed, 05 Jun 2024 13:17:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Philippe Schnoebelen <phs <at> lmf.cnrs.fr>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 05 Jun 2024 13:17:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
The following example code has been put in my ~/foo.el
(defun check-value (v)
;; Let's demonstrate different treament of formats by elisp compiler
(cond (v
(print (format "Congratulations! v=%S is non-NIL."))
;; oops, we forgot to pass v in `format's &rest args
t)
(t ;; otherwise
(user-error "Try again. v=%S is null")
;; same error, here when calling `user-error'
nil)))
When I byte-compile it with M-x byte-compile-file I get the following
warning message:
In check-value:
foo.el:4:18: Warning: ‘format’ called with 0 args to fill 1 format
field(s)
which is very useful.
But why don't I get a similar error message for my call to user-error ?
It would be useful too.
Note that when I evaluate (check-value nil) I get an error with the
following *Backtrace*, showing that my call to
`user-error' fails for exactly the same reason that evaluating
`(check-value t)' fails.
Debugger entered--Lisp error: (error "Not enough arguments for format
string")
format-message("Try again. v=%S is null")
apply(format-message "Try again. v=%S is null" nil)
user-error("Try again. v=%S is null")
(if v (print (format "Congratulations! v=%S is non-NIL."))
(user-error "Try again. v=%S is null"))
check-value(nil)
(progn (check-value nil))
eval((progn (check-value nil)) t)
elisp--eval-last-sexp(t)
eval-last-sexp(t)
eval-print-last-sexp(nil)
funcall-interactively(eval-print-last-sexp nil)
call-interactively(eval-print-last-sexp nil nil)
I thought you'd like to know.
Thanks for your time and dedication in developing GNU Emacs !
--philippe
In GNU Emacs 29.3 (build 1, aarch64-apple-darwin21.6.0, NS
appkit-2113.60 Version 12.6.6 (Build 21G646)) of
2024-03-24 built on armbob.lan
Windowing system distributor 'Apple', version 10.3.2487
System Description: macOS 14.5
Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules
'CFLAGS=-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT' --with-x-toolkit=no'
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Wed, 05 Jun 2024 16:59:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 71379 <at> debbugs.gnu.org (full text, mbox):
I stumbled on this report by accident:
> But why don't I get a similar error message for my call to user-error ?
That's a clear oversight, thank you for reporting it. Will fix.
Should be trivial enough for master (and I have made a full bootstrap) but I'm asking Eli for confirmation just in case.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Wed, 05 Jun 2024 17:49:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 71379 <at> debbugs.gnu.org (full text, mbox):
> From: Mattias Engdegård <mattias.engdegard <at> gmail.com>
> Date: Wed, 5 Jun 2024 18:56:52 +0200
> Cc: 71379 <at> debbugs.gnu.org,
> Eli Zaretskii <eliz <at> gnu.org>
>
> I stumbled on this report by accident:
>
> > But why don't I get a similar error message for my call to user-error ?
>
> That's a clear oversight, thank you for reporting it. Will fix.
>
> Should be trivial enough for master (and I have made a full bootstrap) but I'm asking Eli for confirmation just in case.
Thanks, I'd like to see the changes before making up my mind about
that. The problem is definitely not serious, so the fix should be
safe enough to qualify.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Wed, 05 Jun 2024 19:23:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 71379 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
5 juni 2024 kl. 19.48 skrev Eli Zaretskii <eliz <at> gnu.org>:
> Thanks, I'd like to see the changes before making up my mind about
> that. The problem is definitely not serious, so the fix should be
> safe enough to qualify.
Sorry, meant to attach the patch.
[0001-Format-string-warnings-for-more-functions-bug-71379.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Thu, 06 Jun 2024 05:23:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 71379 <at> debbugs.gnu.org (full text, mbox):
> From: Mattias Engdegård <mattias.engdegard <at> gmail.com>
> Date: Wed, 5 Jun 2024 21:20:53 +0200
> Cc: schnoebelen.ph <at> gmail.com,
> 71379 <at> debbugs.gnu.org
>
> 5 juni 2024 kl. 19.48 skrev Eli Zaretskii <eliz <at> gnu.org>:
>
> > Thanks, I'd like to see the changes before making up my mind about
> > that. The problem is definitely not serious, so the fix should be
> > safe enough to qualify.
>
> Sorry, meant to attach the patch.
On second thought, this is still fine to go in now, but I wonder
whether we should move these to the places where the corresponding
functions are defined, and leave in bytecomp.c only those which are
primitives defined in C? That would mean 'warn' and 'user-error'
should be moved to their respective Lisp files. WDYT?
Reply sent
to
Mattias Engdegård <mattias.engdegard <at> gmail.com>
:
You have taken responsibility.
(Thu, 06 Jun 2024 08:51:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Philippe Schnoebelen <phs <at> lmf.cnrs.fr>
:
bug acknowledged by developer.
(Thu, 06 Jun 2024 08:51:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 71379-done <at> debbugs.gnu.org (full text, mbox):
6 juni 2024 kl. 06.38 skrev Eli Zaretskii <eliz <at> gnu.org>:
> On second thought, this is still fine to go in now, but I wonder
> whether we should move these to the places where the corresponding
> functions are defined, and leave in bytecomp.c only those which are
> primitives defined in C? That would mean 'warn' and 'user-error'
> should be moved to their respective Lisp files.
Indeed it's a question I always ask myself every so often, and sometimes we distribute properties to definitions.
However, in this case it seems better to keep them in one place: it's only a small handful of functions, and this way the properties are kept local to the byte-compiler.
Thank you, the change is now on master. Closing.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Thu, 06 Jun 2024 23:33:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 71379 <at> debbugs.gnu.org (full text, mbox):
Mattias Engdegård <mattias.engdegard <at> gmail.com> writes:
> 6 juni 2024 kl. 06.38 skrev Eli Zaretskii <eliz <at> gnu.org>:
>
>> On second thought, this is still fine to go in now, but I wonder
>> whether we should move these to the places where the corresponding
>> functions are defined, and leave in bytecomp.c only those which are
>> primitives defined in C? That would mean 'warn' and 'user-error'
>> should be moved to their respective Lisp files.
>
> Indeed it's a question I always ask myself every so often, and sometimes we distribute properties to definitions.
> However, in this case it seems better to keep them in one place: it's only a small handful of functions, and this way the properties are kept local to the byte-compiler.
No strong opinion, but I think this cuts both ways: keeping it local to
the definition of the functions themselves makes it clear to anyone
looking there for inspiration how to add such warnings to their own
`format` functions.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Fri, 07 Jun 2024 06:39:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 71379 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Fri, 7 Jun 2024 01:22:49 +0200
> Cc: 71379 <at> debbugs.gnu.org, philippe schnoebelen <schnoebelen.ph <at> gmail.com>
>
> Mattias Engdegård <mattias.engdegard <at> gmail.com> writes:
>
> > 6 juni 2024 kl. 06.38 skrev Eli Zaretskii <eliz <at> gnu.org>:
> >
> >> On second thought, this is still fine to go in now, but I wonder
> >> whether we should move these to the places where the corresponding
> >> functions are defined, and leave in bytecomp.c only those which are
> >> primitives defined in C? That would mean 'warn' and 'user-error'
> >> should be moved to their respective Lisp files.
> >
> > Indeed it's a question I always ask myself every so often, and sometimes we distribute properties to definitions.
> > However, in this case it seems better to keep them in one place: it's only a small handful of functions, and this way the properties are kept local to the byte-compiler.
>
> No strong opinion, but I think this cuts both ways: keeping it local to
> the definition of the functions themselves makes it clear to anyone
> looking there for inspiration how to add such warnings to their own
> `format` functions.
Indeed. In addition, some functions marked with this property already
do that in their own files. Which was why I asked that question in
the first place.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Fri, 07 Jun 2024 09:35:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 71379 <at> debbugs.gnu.org (full text, mbox):
7 juni 2024 kl. 01.22 skrev Stefan Kangas <stefankangas <at> gmail.com>:
> No strong opinion, but I think this cuts both ways: keeping it local to
> the definition of the functions themselves makes it clear to anyone
> looking there for inspiration how to add such warnings to their own
> `format` functions.
Yes, it's a matter of judgement which has to be reconsidered from time to time. I see no reason for doing anything about this right now, but this may change in the future. The reasons for not distributing function properties can be quite strong as well.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Fri, 07 Jun 2024 14:11:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 71379 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Stefan Kangas <stefankangas <at> gmail.com>
>> Date: Fri, 7 Jun 2024 01:22:49 +0200
>> Cc: 71379 <at> debbugs.gnu.org, philippe schnoebelen <schnoebelen.ph <at> gmail.com>
>>
>> Mattias Engdegård <mattias.engdegard <at> gmail.com> writes:
>>
>> > 6 juni 2024 kl. 06.38 skrev Eli Zaretskii <eliz <at> gnu.org>:
>> >
>> >> On second thought, this is still fine to go in now, but I wonder
>> >> whether we should move these to the places where the corresponding
>> >> functions are defined, and leave in bytecomp.c only those which are
>> >> primitives defined in C? That would mean 'warn' and 'user-error'
>> >> should be moved to their respective Lisp files.
>> >
>> > Indeed it's a question I always ask myself every so often, and
>> > sometimes we distribute properties to definitions.
>> > However, in this case it seems better to keep them in one place:
>> > it's only a small handful of functions, and this way the
>> > properties are kept local to the byte-compiler.
>>
>> No strong opinion, but I think this cuts both ways: keeping it local to
>> the definition of the functions themselves makes it clear to anyone
>> looking there for inspiration how to add such warnings to their own
>> `format` functions.
>
> Indeed. In addition, some functions marked with this property already
> do that in their own files. Which was why I asked that question in
> the first place.
Agreed. Maybe in the future even worth having a declare for it? We
have them already for things like ex 'important-return-value'.
Andrea
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Fri, 07 Jun 2024 15:51:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 71379 <at> debbugs.gnu.org (full text, mbox):
> From: Andrea Corallo <acorallo <at> gnu.org>
> Cc: Stefan Kangas <stefankangas <at> gmail.com>, 71379 <at> debbugs.gnu.org,
> schnoebelen.ph <at> gmail.com, mattias.engdegard <at> gmail.com
> Date: Fri, 07 Jun 2024 09:55:08 -0400
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> No strong opinion, but I think this cuts both ways: keeping it local to
> >> the definition of the functions themselves makes it clear to anyone
> >> looking there for inspiration how to add such warnings to their own
> >> `format` functions.
> >
> > Indeed. In addition, some functions marked with this property already
> > do that in their own files. Which was why I asked that question in
> > the first place.
>
> Agreed. Maybe in the future even worth having a declare for it? We
> have them already for things like ex 'important-return-value'.
Yes, could be a good idea.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Sat, 08 Jun 2024 18:16:02 GMT)
Full text and
rfc822 format available.
Message #40 received at 71379 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Andrea Corallo <acorallo <at> gnu.org>
>> Cc: Stefan Kangas <stefankangas <at> gmail.com>, 71379 <at> debbugs.gnu.org,
>> schnoebelen.ph <at> gmail.com, mattias.engdegard <at> gmail.com
>> Date: Fri, 07 Jun 2024 09:55:08 -0400
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>> >> No strong opinion, but I think this cuts both ways: keeping it local to
>> >> the definition of the functions themselves makes it clear to anyone
>> >> looking there for inspiration how to add such warnings to their own
>> >> `format` functions.
>> >
>> > Indeed. In addition, some functions marked with this property already
>> > do that in their own files. Which was why I asked that question in
>> > the first place.
>>
>> Agreed. Maybe in the future even worth having a declare for it? We
>> have them already for things like ex 'important-return-value'.
>
> Yes, could be a good idea.
Okay, will do after we branch emacs30.
Andrea
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Sat, 08 Jun 2024 18:20:02 GMT)
Full text and
rfc822 format available.
Message #43 received at 71379 <at> debbugs.gnu.org (full text, mbox):
8 juni 2024 kl. 20.15 skrev Andrea Corallo <acorallo <at> gnu.org>:
>>> Agreed. Maybe in the future even worth having a declare for it? We
>>> have them already for things like ex 'important-return-value'.
>>
>> Yes, could be a good idea.
>
> Okay, will do after we branch emacs30.
Again, I'm not very fond of the idea (or I would have done it long ago myself).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Sat, 08 Jun 2024 18:33:01 GMT)
Full text and
rfc822 format available.
Message #46 received at 71379 <at> debbugs.gnu.org (full text, mbox):
> From: Mattias Engdegård <mattias.engdegard <at> gmail.com>
> Date: Sat, 8 Jun 2024 20:18:09 +0200
> Cc: Eli Zaretskii <eliz <at> gnu.org>,
> stefankangas <at> gmail.com,
> 71379 <at> debbugs.gnu.org,
> schnoebelen.ph <at> gmail.com
>
> 8 juni 2024 kl. 20.15 skrev Andrea Corallo <acorallo <at> gnu.org>:
>
> >>> Agreed. Maybe in the future even worth having a declare for it? We
> >>> have them already for things like ex 'important-return-value'.
> >>
> >> Yes, could be a good idea.
> >
> > Okay, will do after we branch emacs30.
>
> Again, I'm not very fond of the idea (or I would have done it long ago myself).
Why not? Without a rationale, how can we discuss this?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Sun, 09 Jun 2024 15:26:01 GMT)
Full text and
rfc822 format available.
Message #49 received at 71379 <at> debbugs.gnu.org (full text, mbox):
8 juni 2024 kl. 20.32 skrev Eli Zaretskii <eliz <at> gnu.org>:
> Why not?
As I said, I think the drawbacks outweigh the advantages right now.
It's much easier to keep track of the functions that are subject to the warning when they are gathered in a single place, and there is an advantage in keeping the mechanism local.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Mon, 10 Jun 2024 08:15:01 GMT)
Full text and
rfc822 format available.
Message #52 received at 71379 <at> debbugs.gnu.org (full text, mbox):
Mattias Engdegård <mattias.engdegard <at> gmail.com> writes:
> 8 juni 2024 kl. 20.32 skrev Eli Zaretskii <eliz <at> gnu.org>:
>
>> Why not?
>
> As I said, I think the drawbacks outweigh the advantages right now.
> It's much easier to keep track of the functions that are subject to the warning when they are gathered in a single place, and there is an advantage in keeping the mechanism local.
But this is not local only already, see 'info-xref-output' and
'info-xref-output-error'. There might be other occurencies outside
emacs.git as well.
Andrea
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Mon, 10 Jun 2024 15:26:02 GMT)
Full text and
rfc822 format available.
Message #55 received at 71379 <at> debbugs.gnu.org (full text, mbox):
10 juni 2024 kl. 10.11 skrev Andrea Corallo <acorallo <at> gnu.org>:
> But this is not local only already, see 'info-xref-output' and
> 'info-xref-output-error'.
Very much aware of that, and don't think it's worth doing anything about.
> There might be other occurencies outside
> emacs.git as well.
Already checked that as well, and there were almost none -- all I could find was a single occurrence in one package. Not that we really care since it's an internal and undocumented interface.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Tue, 11 Jun 2024 16:25:02 GMT)
Full text and
rfc822 format available.
Message #58 received at 71379 <at> debbugs.gnu.org (full text, mbox):
10 juni 2024 kl. 23.14 skrev Andrea Corallo <acorallo <at> gnu.org>:
> You can indeed have your opinions, but again this shows that the
> mechanism is not local only already, and that it's already in use
> outside as there was probably need for it.
No it doesn't.
I don't know what is special about this warning, enough for you to argue strongly about it, but maybe you don't either -- once we take a strong position about something, even by accident, it's difficult to stop, and to admit that it's perhaps not that important after all.
So let's give it a rest. I will keep revisiting this again, as I have many times before, and of course so may you. If we do something, let's make sure we know why, not just because we have made up our minds about it.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71379
; Package
emacs
.
(Tue, 11 Jun 2024 20:25:02 GMT)
Full text and
rfc822 format available.
Message #61 received at 71379 <at> debbugs.gnu.org (full text, mbox):
Mattias Engdegård <mattias.engdegard <at> gmail.com> writes:
> 10 juni 2024 kl. 10.11 skrev Andrea Corallo <acorallo <at> gnu.org>:
>
>> But this is not local only already, see 'info-xref-output' and
>> 'info-xref-output-error'.
>
> Very much aware of that, and don't think it's worth doing anything about.
>
>> There might be other occurencies outside
>> emacs.git as well.
>
> Already checked that as well, and there were almost none -- all I
> could find was a single occurrence in one package. Not that we really
> care since it's an internal and undocumented interface.
You can indeed have your opinions, but again this shows that the
mechanism is not local only already, and that it's already in use
outside as there was probably need for it.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 10 Jul 2024 11:24:21 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 37 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.