bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#71379: 29.3; Elisp compiler: warnings for formats given insufficient


From: Philippe Schnoebelen
Subject: bug#71379: 29.3; Elisp compiler: warnings for formats given insufficiently many arguments
Date: Wed, 5 Jun 2024 15:16:16 +0200

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'





reply via email to

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