aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/bytecomp.el4
-rw-r--r--lisp/emacs-lisp/cconv.el29
2 files changed, 17 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 1f868d2217c..af74c0699b9 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2557,9 +2557,7 @@ list that represents a doc string reference.
2557 ;; macroexpand-all. 2557 ;; macroexpand-all.
2558 ;; (if (memq byte-optimize '(t source)) 2558 ;; (if (memq byte-optimize '(t source))
2559 ;; (setq form (byte-optimize-form form for-effect))) 2559 ;; (setq form (byte-optimize-form form for-effect)))
2560 (cond 2560 (cconv-closure-convert form))
2561 (lexical-binding (cconv-closure-convert form))
2562 (t form)))
2563 2561
2564;; byte-hunk-handlers cannot call this! 2562;; byte-hunk-handlers cannot call this!
2565(defun byte-compile-toplevel-file-form (top-level-form) 2563(defun byte-compile-toplevel-file-form (top-level-form)
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index b12f1db677e..eca1123899c 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -664,18 +664,19 @@ FORM is the parent form that binds this var."
664 ;; Push it before recursing, so cconv-freevars-alist contains entries in 664 ;; Push it before recursing, so cconv-freevars-alist contains entries in
665 ;; the order they'll be used by closure-convert-rec. 665 ;; the order they'll be used by closure-convert-rec.
666 (push freevars cconv-freevars-alist) 666 (push freevars cconv-freevars-alist)
667 (dolist (arg args) 667 (when lexical-binding
668 (cond 668 (dolist (arg args)
669 ((byte-compile-not-lexical-var-p arg) 669 (cond
670 (byte-compile-warn-x 670 ((byte-compile-not-lexical-var-p arg)
671 arg 671 (byte-compile-warn-x
672 "Lexical argument shadows the dynamic variable %S" 672 arg
673 arg)) 673 "Lexical argument shadows the dynamic variable %S"
674 ((eq ?& (aref (symbol-name arg) 0)) nil) ;Ignore &rest, &optional, ... 674 arg))
675 (t (let ((varstruct (list arg nil nil nil nil))) 675 ((eq ?& (aref (symbol-name arg) 0)) nil) ;Ignore &rest, &optional, ...
676 (cl-pushnew arg byte-compile-lexical-variables) 676 (t (let ((varstruct (list arg nil nil nil nil)))
677 (push (cons (list arg) (cdr varstruct)) newvars) 677 (cl-pushnew arg byte-compile-lexical-variables)
678 (push varstruct newenv))))) 678 (push (cons (list arg) (cdr varstruct)) newvars)
679 (push varstruct newenv))))))
679 (dolist (form body) ;Analyze body forms. 680 (dolist (form body) ;Analyze body forms.
680 (cconv-analyze-form form newenv)) 681 (cconv-analyze-form form newenv))
681 ;; Summarize resulting data about arguments. 682 ;; Summarize resulting data about arguments.
@@ -724,7 +725,7 @@ This function does not return anything but instead fills the
724 725
725 (cconv-analyze-form value (if (eq letsym 'let*) env orig-env))) 726 (cconv-analyze-form value (if (eq letsym 'let*) env orig-env)))
726 727
727 (unless (byte-compile-not-lexical-var-p var) 728 (unless (or (byte-compile-not-lexical-var-p var) (not lexical-binding))
728 (cl-pushnew var byte-compile-lexical-variables) 729 (cl-pushnew var byte-compile-lexical-variables)
729 (let ((varstruct (list var nil nil nil nil))) 730 (let ((varstruct (list var nil nil nil nil)))
730 (push (cons binder (cdr varstruct)) newvars) 731 (push (cons binder (cdr varstruct)) newvars)
@@ -769,6 +770,8 @@ This function does not return anything but instead fills the
769 770
770 (`(condition-case ,var ,protected-form . ,handlers) 771 (`(condition-case ,var ,protected-form . ,handlers)
771 (cconv-analyze-form protected-form env) 772 (cconv-analyze-form protected-form env)
773 (unless lexical-binding
774 (setq var nil))
772 (when (and var (symbolp var) (byte-compile-not-lexical-var-p var)) 775 (when (and var (symbolp var) (byte-compile-not-lexical-var-p var))
773 (byte-compile-warn-x 776 (byte-compile-warn-x
774 var "Lexical variable shadows the dynamic variable %S" var)) 777 var "Lexical variable shadows the dynamic variable %S" var))