From: Philippe Schnoebelen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 71379@debbugs.gnu.org
Subject: bug#71379: 29.3; Elisp compiler: warnings for formats given insufficiently many arguments
Date: Wed, 5 Jun 2024 15:16:16 +0200 [thread overview]
Message-ID: <a61902b8-a9b7-4d1e-a0ba-e8922bcbc0c2@lmf.cnrs.fr> (raw)
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'
next reply other threads:[~2024-06-05 13:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 13:16 Philippe Schnoebelen via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-06-05 16:56 ` bug#71379: 29.3; Elisp compiler: warnings for formats given insufficiently many arguments Mattias Engdegård
2024-06-05 17:48 ` Eli Zaretskii
2024-06-05 19:20 ` Mattias Engdegård
2024-06-06 4:38 ` Eli Zaretskii
2024-06-06 8:49 ` Mattias Engdegård
2024-06-06 23:22 ` Stefan Kangas
2024-06-07 6:21 ` Eli Zaretskii
2024-06-07 13:55 ` Andrea Corallo
2024-06-07 15:50 ` Eli Zaretskii
2024-06-08 18:15 ` Andrea Corallo
2024-06-08 18:18 ` Mattias Engdegård
2024-06-08 18:32 ` Eli Zaretskii
2024-06-09 13:57 ` Mattias Engdegård
2024-06-10 8:11 ` Andrea Corallo
2024-06-10 14:27 ` Mattias Engdegård
2024-06-10 21:14 ` Andrea Corallo
2024-06-11 14:30 ` Mattias Engdegård
2024-06-07 9:32 ` Mattias Engdegård
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a61902b8-a9b7-4d1e-a0ba-e8922bcbc0c2@lmf.cnrs.fr \
--to=bug-gnu-emacs@gnu.org \
--cc=71379@debbugs.gnu.org \
--cc=phs@lmf.cnrs.fr \
/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 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).