aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el23
1 files changed, 10 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index d7140ad9e63..ee530f95d09 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -4943,8 +4943,6 @@ binding slots have been popped."
4943 (push (nth 1 (nth 1 form)) byte-compile-global-not-obsolete-vars)) 4943 (push (nth 1 (nth 1 form)) byte-compile-global-not-obsolete-vars))
4944 (byte-compile-normal-call form)) 4944 (byte-compile-normal-call form))
4945 4945
4946(defconst byte-compile-tmp-var (make-symbol "def-tmp-var"))
4947
4948(defun byte-compile-defvar (form) 4946(defun byte-compile-defvar (form)
4949 ;; This is not used for file-level defvar/consts. 4947 ;; This is not used for file-level defvar/consts.
4950 (when (and (symbolp (nth 1 form)) 4948 (when (and (symbolp (nth 1 form))
@@ -4977,18 +4975,17 @@ binding slots have been popped."
4977 string 4975 string
4978 "third arg to `%s %s' is not a string: %s" 4976 "third arg to `%s %s' is not a string: %s"
4979 fun var string)) 4977 fun var string))
4978 ;; Delegate the actual work to the function version of the
4979 ;; special form, named with a "-1" suffix.
4980 (byte-compile-form-do-effect 4980 (byte-compile-form-do-effect
4981 (if (cddr form) ; `value' provided 4981 (cond
4982 ;; Quote with `quote' to prevent byte-compiling the body, 4982 ((eq fun 'defconst) `(defconst-1 ',var ,@(nthcdr 2 form)))
4983 ;; which would lead to an inf-loop. 4983 ((not (cddr form)) `',var) ; A simple (defvar foo) just returns foo.
4984 `(funcall '(lambda (,byte-compile-tmp-var) 4984 (t `(defvar-1 ',var
4985 (,fun ,var ,byte-compile-tmp-var ,@(nthcdr 3 form))) 4985 ;; Don't eval `value' if `defvar' wouldn't eval it either.
4986 ,value) 4986 ,(if (macroexp-const-p value) value
4987 (if (eq fun 'defconst) 4987 `(if (boundp ',var) nil ,value))
4988 ;; This will signal an appropriate error at runtime. 4988 ,@(nthcdr 3 form)))))))
4989 `(eval ',form)
4990 ;; A simple (defvar foo) just returns foo.
4991 `',var)))))
4992 4989
4993(defun byte-compile-autoload (form) 4990(defun byte-compile-autoload (form)
4994 (and (macroexp-const-p (nth 1 form)) 4991 (and (macroexp-const-p (nth 1 form))