I'm getting an error called with 1 args to fill 0 format field(s) error when byte-compiling cider-repl-history.el with Emacs 24.4 and 24.5. No such error is reported for Emacs 25.1.

Line 422 of cider-repl-history.el is a cl-assert. The docstring for cl-assert says:

Other args STRING and ARGS... are arguments to be passed to `error'.

In this case we are passing in a STRING, but no ARGS. I suspect this is a resolved bug, but I'm can't find anything by searching the bug archive.

How is this best handled? We have byte-compile-error-on-warn set to t.

  • I think you'll see the problem if you macroexpand that cl-assert call under 24.5. – npostavs Jul 22 '17 at 12:32
  • I must be missing something. Byte-compiling (cl-assert (overlayp "foo") t "not an overlay") on Emacs is just fine. The result of macroexpand-all on that form is: (progn (or (overlayp "foo") (error "not an overlay")) nil), which seems just fine. – Tianxiang Xiong Jul 22 '17 at 20:39
  • Oh...I think I got it. If the form evaluates to something non-constant, and show-args is t, we get (error string ,@sargs ,@args) in Emacs 24. Lovely. – Tianxiang Xiong Jul 22 '17 at 20:51

cl-assert has a signature like:

(form &optional show-args string &rest args)

We should not set show-args to t unless we want the args to form to be format args to string. This can be seen in the definition of cl-assert under Emacs 24 and in the definition of cl--assertion-failed under Emacs 25.


(defvar obj nil)

(macroexpand-all '(cl-assert (overlayp obj) t "not overlay"))
;; => (progn
;;     (or
;;      (overlayp obj)
;;      (error "not overlay" obj))      ;; `error' called with 1 args to fill 0 format field(s)
;;     nil)

The args to form are only given to string if they do not all expand to constants. E.g.

(macroexpand-all '(cl-assert (overlayp "foo") t "not overlay"))    
;; => (progn
;;     (or
;;      (overlayp "foo")
;;      (error "not an overlay"))       ;; OK
;;     nil)

The byte-compiler doesn't complain in Emacs 25 like in Emacs 24, but we should be setting show-args to nil in any case.

Thanks to @npostavs for the hint.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.