Subject: Re: bug#29345: 27.0.50; Error message for cl-destructuring-bind could be improved

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 14 Jul 2019 21:41:59 +0200

Philipp Stephani <[email-masked]> writes:

> $ emacs -Q -batch -l cl-lib -eval '(cl-destructuring-bind (a b) (list 1))'
> Wrong number of arguments: nil, 1
>
> It would be nice if the first error data item weren't nil, but
> e.g. `(cl-destructuring-bind (a b))` so that the error is obvious.

What about

Wrong number of arguments: (a b), 1

The following patch achieves that, but since it was explicitly 'cl-none
before (which is the magic value that gives you nil in that error
message), I'm not sure whether this has any negative effects?  Probably
not, because there's this:

(defvar cl--bind-block) ;Name of surrounding block, only use for `signal' data.

Any opinions?

diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 4347b4b71b..8b9224bd1b 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -695,8 +695,11 @@ cl-destructuring-bind
   "Bind the variables in ARGS to the result of EXPR and execute BODY."
   (declare (indent 2)
            (debug (&define cl-macro-list1 def-form cl-declarations def-body)))
-  (let* ((cl--bind-lets nil) (cl--bind-forms nil)
-	 (cl--bind-defs nil) (cl--bind-block 'cl-none) (cl--bind-enquote nil))
+  (let* ((cl--bind-lets nil)
+         (cl--bind-forms nil)
+	 (cl--bind-defs nil)
+         (cl--bind-block args)
+         (cl--bind-enquote nil))
     (cl--do-arglist (or args '(&aux)) expr)
     (macroexp-let* (nreverse cl--bind-lets)
                    (macroexp-progn (append (nreverse cl--bind-forms) body)))))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no