[Top][All Lists]

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

bug#15715: 24.3; Sanity check of ARGLIST when calling `defun'

From: Lars Ingebrigtsen
Subject: bug#15715: 24.3; Sanity check of ARGLIST when calling `defun'
Date: Wed, 24 Feb 2016 15:00:27 +1100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Nicolas Richard <address@hidden> writes:

> As suggested here http://permalink.gmane.org/gmane.emacs.help/94196 I
> attach a patch to make (defun ...) check that the arglist is an actual
> list of symbols when defining a function, and otherwise signal an error.
> Without this, code like (defun test-foobar ...) succeeds although the
> function is doomed to fail at runtime.

I think this is a good idea (catching errors early is always nice), but
it might break a lot of code out there in the wild.  People defining
functions in their .emacs that they never actually call, for instance.
So I think this change sounds kinda dangerous.

What do all y'all think?

> This won't catch every missing "arglist" but that looks impossible
> anyway.
> diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
> index 0bb0495..d671892 100644
> --- a/lisp/emacs-lisp/byte-run.el
> +++ b/lisp/emacs-lisp/byte-run.el
> @@ -180,6 +180,10 @@ The return value is undefined.
>    ;; from
>    ;;    (defun foo (arg) (toto)).
>    (declare (doc-string 3))
> +  (if (null
> +       (and (listp arglist)
> +            (null (delq t (mapcar #'symbolp arglist)))))
> +      (error "Malformed arglist: %s" arglist))
>    (let ((decls (cond
>                  ((eq (car-safe docstring) 'declare)
>                   (prog1 (cdr docstring) (setq docstring nil)))
> @@ -209,7 +213,7 @@ The return value is undefined.
>                      nil)
>                     (t (message "Warning: Unknown defun property `%S' in %S"
>                                 (car x) name)))))
> -                   decls))
> +            decls))
>            (def (list 'defalias
>                       (list 'quote name)
>                       (list 'function

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

reply via email to

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