emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#15715: closed (24.3; Sanity check of ARGLIST when


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#15715: closed (24.3; Sanity check of ARGLIST when calling `defun')
Date: Sun, 11 Dec 2016 01:49:02 +0000

Your message dated Sat, 10 Dec 2016 20:48:35 -0500
with message-id <address@hidden>
and subject line Re: bug#15715: 24.3; Sanity check of ARGLIST when calling 
`defun'
has caused the debbugs.gnu.org bug report #15715,
regarding 24.3; Sanity check of ARGLIST when calling `defun'
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
15715: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15715
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 24.3; Sanity check of ARGLIST when calling `defun' Date: Fri, 25 Oct 2013 14:27:06 +0200
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.

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

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.

--- End Message ---
--- Begin Message --- Subject: Re: bug#15715: 24.3; Sanity check of ARGLIST when calling `defun' Date: Sat, 10 Dec 2016 20:48:35 -0500 User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
Version: 26.1

Thanks; applied as 0107336.


--- End Message ---

reply via email to

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