From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 25 08:27:15 2013 Received: (at submit) by debbugs.gnu.org; 25 Oct 2013 12:27:15 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 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 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 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 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 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 From: Nicolas Richard To: bug-gnu-emacs@gnu.org Subject: 24.3; Sanity check of ARGLIST when calling `defun' Date: Fri, 25 Oct 2013 14:27:06 +0200 Message-ID: <87hac51qp1.fsf@yahoo.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= 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. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 10 07:01:33 2014 Received: (at control) by debbugs.gnu.org; 10 Feb 2014 12:01:33 +0000 Received: from localhost ([127.0.0.1]:39278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCpYK-0000KA-I7 for submit@debbugs.gnu.org; Mon, 10 Feb 2014 07:01:32 -0500 Received: from mxin.ulb.ac.be ([164.15.128.112]:23578) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCpYH-0000Jz-Sz for control@debbugs.gnu.org; Mon, 10 Feb 2014 07:01:30 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am4FAJm++FKkD4Xx/2dsb2JhbABZkHWeTgGVOnSCRXgkNAGIUAEUmSWPaJZiAYk0h3KHKIQiBJgrhjGLcIMuOw Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 10 Feb 2014 13:01:28 +0100 Date: Mon, 10 Feb 2014 13:01:28 +0100 Message-Id: <87zjlz18iv.fsf@yahoo.fr> To: control@debbugs.gnu.org From: Nicolas Richard Subject: control message for bug #15715 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) tags 15715 patch From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 23 23:00:58 2016 Received: (at 15715) by debbugs.gnu.org; 24 Feb 2016 04:00:58 +0000 Received: from localhost ([127.0.0.1]:42094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYQdG-0002iG-0z for submit@debbugs.gnu.org; Tue, 23 Feb 2016 23:00:58 -0500 Received: from hermes.netfonds.no ([80.91.224.195]:60498) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aYQdE-0002gO-4u for 15715@debbugs.gnu.org; Tue, 23 Feb 2016 23:00:56 -0500 Received: from cpe-60-225-211-161.nsw.bigpond.net.au ([60.225.211.161] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aYQcp-000804-Sq; Wed, 24 Feb 2016 05:00:32 +0100 From: Lars Ingebrigtsen To: Nicolas Richard Subject: Re: bug#15715: 24.3; Sanity check of ARGLIST when calling `defun' References: <87hac51qp1.fsf@yahoo.fr> Date: Wed, 24 Feb 2016 15:00:27 +1100 In-Reply-To: <87hac51qp1.fsf@yahoo.fr> (Nicolas Richard's message of "Fri, 25 Oct 2013 14:27:06 +0200") Message-ID: <87d1rmkbac.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-MailScanner-ID: 1aYQcp-000804-Sq X-Netfonds-MailScanner: Found to be clean X-Netfonds-MailScanner-From: larsi@gnus.org MailScanner-NULL-Check: 1456891232.96178@85FmXn9ZjPdwOgekxrEsNg X-Spam-Status: No X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15715 Cc: 15715@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Nicolas Richard 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 10 20:48:45 2016 Received: (at 15715-done) by debbugs.gnu.org; 11 Dec 2016 01:48:45 +0000 Received: from localhost ([127.0.0.1]:37361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFtFt-0001jc-Fg for submit@debbugs.gnu.org; Sat, 10 Dec 2016 20:48:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58133) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFtFr-0001jP-SK for 15715-done@debbugs.gnu.org; Sat, 10 Dec 2016 20:48:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cFtFl-0005l3-JX for 15715-done@debbugs.gnu.org; Sat, 10 Dec 2016 20:48:38 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cFtFl-0005kz-GZ for 15715-done@debbugs.gnu.org; Sat, 10 Dec 2016 20:48:37 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1cFtFj-0005UE-SL; Sat, 10 Dec 2016 20:48:35 -0500 From: Glenn Morris To: 15715-done@debbugs.gnu.org Subject: Re: bug#15715: 24.3; Sanity check of ARGLIST when calling `defun' References: <87hac51qp1.fsf@yahoo.fr> X-Spook: UOP assassinate Saddam Hussein 64 Vauxhall Cross halcon X-Ran: KdlumgZx|l@;+O)'#4>aNxcDn+_c)aO:Q*vhkb:N1A*n~{J (Nicolas Richard's message of "Fri, 25 Oct 2013 14:27:06 +0200") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.0 (--------) X-Debbugs-Envelope-To: 15715-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.0 (--------) Version: 26.1 Thanks; applied as 0107336. From unknown Mon Aug 18 02:31:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 08 Jan 2017 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator