unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: 15715@debbugs.gnu.org
Subject: bug#15715: 24.3; Sanity check of ARGLIST when calling `defun'
Date: Wed, 24 Feb 2016 15:00:27 +1100	[thread overview]
Message-ID: <87d1rmkbac.fsf@gnus.org> (raw)
In-Reply-To: <87hac51qp1.fsf@yahoo.fr> (Nicolas Richard's message of "Fri, 25 Oct 2013 14:27:06 +0200")

Nicolas Richard <theonewiththeevillook@yahoo.fr> 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	other threads:[~2016-02-24  4:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25 12:27 bug#15715: 24.3; Sanity check of ARGLIST when calling `defun' Nicolas Richard
2016-02-24  4:00 ` Lars Ingebrigtsen [this message]
2016-12-11  1:48 ` Glenn Morris

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=87d1rmkbac.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=15715@debbugs.gnu.org \
    --cc=theonewiththeevillook@yahoo.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).