diff options
| author | Gerd Moellmann | 2001-10-12 14:20:14 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-10-12 14:20:14 +0000 |
| commit | eadd64444e9336b40f5e2ea70aeaa587f3e53431 (patch) | |
| tree | 4cb9830c802ee1d0553ac82902e83f9a0c874f12 | |
| parent | 967d7793caa6e1b86dba45d7a7e204a4c82169c9 (diff) | |
| download | emacs-eadd64444e9336b40f5e2ea70aeaa587f3e53431.tar.gz emacs-eadd64444e9336b40f5e2ea70aeaa587f3e53431.zip | |
(byte-compile-check-lambda-list): New
function checking that lambda-list consists of non-constant
symbols, that &rest and &optional are followed by variable names,
that &rest VAR is the last element, and that variables aren't
doubled.
(byte-compile-lambda): Use it.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 29 |
2 files changed, 37 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a7a4f0565ca..cb077880569 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2001-10-12 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-check-lambda-list): New | ||
| 4 | function checking that lambda-list consists of non-constant | ||
| 5 | symbols, that &rest and &optional are followed by variable names, | ||
| 6 | that &rest VAR is the last element, and that variables aren't | ||
| 7 | doubled. | ||
| 8 | (byte-compile-lambda): Use it. | ||
| 9 | |||
| 1 | 2001-10-12 Eli Barzilay <eli@barzilay.org> | 10 | 2001-10-12 Eli Barzilay <eli@barzilay.org> |
| 2 | 11 | ||
| 3 | * calculator.el (calculator-eng-display): Don't call concat | 12 | * calculator.el (calculator-eng-display): Don't call concat |
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 332a7c79504..8813e3891b5 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | ;;; This version incorporates changes up to version 2.10 of the | 11 | ;;; This version incorporates changes up to version 2.10 of the |
| 12 | ;;; Zawinski-Furuseth compiler. | 12 | ;;; Zawinski-Furuseth compiler. |
| 13 | (defconst byte-compile-version "$Revision: 2.87 $") | 13 | (defconst byte-compile-version "$Revision: 2.88.1.1 $") |
| 14 | 14 | ||
| 15 | ;; This file is part of GNU Emacs. | 15 | ;; This file is part of GNU Emacs. |
| 16 | 16 | ||
| @@ -2133,12 +2133,37 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 2133 | (nth 3 function)))))) | 2133 | (nth 3 function)))))) |
| 2134 | 2134 | ||
| 2135 | 2135 | ||
| 2136 | (defun byte-compile-check-lambda-list (list) | ||
| 2137 | "Check lambda-list LIST for errors." | ||
| 2138 | (let (vars) | ||
| 2139 | (while list | ||
| 2140 | (let ((arg (car list))) | ||
| 2141 | (cond ((or (not (symbolp arg)) | ||
| 2142 | (keywordp arg) | ||
| 2143 | (memq arg '(t nil))) | ||
| 2144 | (error "Invalid lambda variable %s" arg)) | ||
| 2145 | ((eq arg '&rest) | ||
| 2146 | (unless (cdr list) | ||
| 2147 | (error "&rest without variable name")) | ||
| 2148 | (when (cddr list) | ||
| 2149 | (error "Garbage following &rest VAR in lambda-list"))) | ||
| 2150 | ((eq arg '&optional) | ||
| 2151 | (unless (cdr list) | ||
| 2152 | (error "Variable name missing after &optional"))) | ||
| 2153 | ((memq arg vars) | ||
| 2154 | (error "Repeated variable %s in lambda-list" arg)) | ||
| 2155 | (t | ||
| 2156 | (push arg vars)))) | ||
| 2157 | (setq list (cdr list))))) | ||
| 2158 | |||
| 2159 | |||
| 2136 | ;; Byte-compile a lambda-expression and return a valid function. | 2160 | ;; Byte-compile a lambda-expression and return a valid function. |
| 2137 | ;; The value is usually a compiled function but may be the original | 2161 | ;; The value is usually a compiled function but may be the original |
| 2138 | ;; lambda-expression. | 2162 | ;; lambda-expression. |
| 2139 | (defun byte-compile-lambda (fun) | 2163 | (defun byte-compile-lambda (fun) |
| 2140 | (unless (eq 'lambda (car-safe fun)) | 2164 | (unless (eq 'lambda (car-safe fun)) |
| 2141 | (error "Not a lambda list: %S" fun)) | 2165 | (error "Not a lambda list: %S" fun)) |
| 2166 | (byte-compile-check-lambda-list (nth 1 fun)) | ||
| 2142 | (let* ((arglist (nth 1 fun)) | 2167 | (let* ((arglist (nth 1 fun)) |
| 2143 | (byte-compile-bound-variables | 2168 | (byte-compile-bound-variables |
| 2144 | (nconc (and (memq 'free-vars byte-compile-warnings) | 2169 | (nconc (and (memq 'free-vars byte-compile-warnings) |
| @@ -3216,6 +3241,8 @@ If FORM is a lambda or a macro, byte-compile it as a function." | |||
| 3216 | 3241 | ||
| 3217 | (defun byte-compile-defun (form) | 3242 | (defun byte-compile-defun (form) |
| 3218 | ;; This is not used for file-level defuns with doc strings. | 3243 | ;; This is not used for file-level defuns with doc strings. |
| 3244 | (unless (symbolp (car form)) | ||
| 3245 | (error "defun name must be a symbol, not %s" (car form))) | ||
| 3219 | (byte-compile-two-args ; Use this to avoid byte-compile-fset's warning. | 3246 | (byte-compile-two-args ; Use this to avoid byte-compile-fset's warning. |
| 3220 | (list 'fset (list 'quote (nth 1 form)) | 3247 | (list 'fset (list 'quote (nth 1 form)) |
| 3221 | (byte-compile-byte-code-maker | 3248 | (byte-compile-byte-code-maker |