From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.bugs Subject: bug#15715: 24.3; Sanity check of ARGLIST when calling `defun' Date: Fri, 25 Oct 2013 14:27:06 +0200 Message-ID: <87hac51qp1.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1382704103 4243 80.91.229.3 (25 Oct 2013 12:28:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Oct 2013 12:28:23 +0000 (UTC) To: 15715@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 25 14:28:27 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VZgV2-0002wm-U3 for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Oct 2013 14:28:21 +0200 Original-Received: from localhost ([::1]:59049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZgV2-0007jK-FT for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Oct 2013 08:28:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZgUs-0007j5-Hc for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 08:28:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZgUl-0003dL-7f for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 08:28:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZgUl-0003dG-4Q for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 08:28:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VZgUk-0002Q6-C4 for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 08:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Nicolas Richard Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Oct 2013 12:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15715 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13827040359239 (code B ref -1); Fri, 25 Oct 2013 12:28:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Oct 2013 12:27:15 +0000 Original-Received: from localhost ([127.0.0.1]:42979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VZgTy-0002Ow-M1 for submit@debbugs.gnu.org; Fri, 25 Oct 2013 08:27:15 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41237) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VZgTv-0002Of-2p for submit@debbugs.gnu.org; Fri, 25 Oct 2013 08:27:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZgTi-0003Ry-Hb for submit@debbugs.gnu.org; Fri, 25 Oct 2013 08:27:05 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:56412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZgTi-0003Ru-EX for submit@debbugs.gnu.org; Fri, 25 Oct 2013 08:26:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZgTc-0007Gq-9F for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 08:26:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZgTW-0003Q2-4S for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 08:26:52 -0400 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:3697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZgTV-0003Pl-RT for bug-gnu-emacs@gnu.org; Fri, 25 Oct 2013 08:26:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtQNAC9jalKkD4Nx/2dsb2JhbABZgz+qOoI0AZNmdIM9JDQBiFQBEg2YFY9ahzYBikKHb4YlgVyEFgOYCoEvhHiLYIMoOoEs Original-Received: from geodiff-mac3.ulb.ac.be (HELO geodiff-mac3) ([164.15.131.113]) by smtp.ulb.ac.be with ESMTP; 25 Oct 2013 14:26:31 +0200 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:79632 Archived-At: --=-=-= Content-Type: text/plain Hello, 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. This won't catch every missing "arglist" but that looks impossible anyway. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Sanity-check-for-ARGLIST-in-defun.patch Content-Description: Sanity check of ARGLIST when calling `defun' 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 -- 1.8.1.5 --=-=-= Content-Type: text/plain It was also suggested in that thread by P.J. Bourguignon to use alternate methods, but both required parts of cl (for "every" and "dolist"), hence I'm submitting this version (and checked that "make bootstrap" succeeds). Another version would be something along the lines of: (mapc (function (lambda (elt) (if (null (symbolp elt)) (error "Malformed arglist: %s" arglist)))) (if (listp arglist) arglist '(""))) but it doesn't look more efficient from my (very limited) test. -- Nico. --=-=-=--