From ba8e883fa30f1267c27751c1ee9df25a5dde4c0c Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 10 Dec 2016 18:58:24 -0800 Subject: [PATCH] Do not allow nil to be defined as a function * lisp/emacs-lisp/byte-run.el (defun): * src/data.c (Ffset): Do not allow "nil". (Bug#25110) --- lisp/emacs-lisp/byte-run.el | 1 + src/data.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 69b4f41fef6..9d2a048f365 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -240,6 +240,7 @@ The return value is undefined. ;; from ;; (defun foo (arg) (toto)). (declare (doc-string 3) (indent 2)) + (or name (error "Cannot define '%s' as a function" name)) (if (null (and (listp arglist) (null (delq t (mapcar #'symbolp arglist))))) diff --git a/src/data.c b/src/data.c index 09d94f57a8e..52cfe4ae4a3 100644 --- a/src/data.c +++ b/src/data.c @@ -733,6 +733,9 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0, { register Lisp_Object function; CHECK_SYMBOL (symbol); + /* Perhaps not quite the right error signal, but seems good enough. */ + if (NILP (symbol)) + xsignal1 (Qsetting_constant, symbol); function = XSYMBOL (symbol)->function; -- 2.39.2