]> git.eshelyaron.com Git - emacs.git/commitdiff
Execute top level forms in the right lex/dyn scope.
authorAndrea Corallo <akrl@sdf.org>
Tue, 2 Jun 2020 10:08:50 +0000 (11:08 +0100)
committerAndrea Corallo <akrl@sdf.org>
Sun, 21 Jun 2020 22:03:23 +0000 (00:03 +0200)
* lisp/emacs-lisp/bytecomp.el (byte-to-native-top-level): Add
'lexical' slot.
(byte-compile-output-file-form): Update for new slot.
(byte-compile-file-form-defmumble): Capture scope.

* lisp/emacs-lisp/comp.el (comp-emit-for-top-level): Specify
execution scope.

lisp/emacs-lisp/bytecomp.el
lisp/emacs-lisp/comp.el

index 9e39b8f78ac0312026af18c73e58d594133d13b3..c7d2344dbd2cc38f8b65232f7da457bac84a6cc7 100644 (file)
@@ -585,7 +585,7 @@ Each element is (INDEX . VALUE)")
   name c-name byte-func)
 (cl-defstruct byte-to-native-top-level
   "All other top-level forms."
-  form)
+  form lexical)
 
 (defvar byte-native-compiling nil
   "Non nil while native compiling.")
@@ -2248,7 +2248,7 @@ Call from the source buffer."
   ;; it here.
   (when byte-native-compiling
     ;; Spill output for the native compiler here
-    (push (make-byte-to-native-top-level :form form)
+    (push (make-byte-to-native-top-level :form form :lexical lexical-binding)
           byte-to-native-top-level-forms))
   (let ((print-escape-newlines t)
         (print-length nil)
@@ -2707,7 +2707,8 @@ not to take responsibility for the actual compilation of the code."
               ;; Spill output for the native compiler here.
               (push (if macro
                         (make-byte-to-native-top-level
-                         :form `(defalias ',name '(macro . ,code) nil))
+                         :form `(defalias ',name '(macro . ,code) nil)
+                         :lexical lexical-binding)
                       (make-byte-to-native-func-def :name name
                                                     :byte-func code))
                     byte-to-native-top-level-forms))
index e7bd0690727b40aac2bcf56b0ed7284f11fff750..928fa516ed578733c0808fd2bf2b207115846c6c 100644 (file)
@@ -1373,11 +1373,13 @@ the annotation emission."
 (cl-defmethod comp-emit-for-top-level ((form byte-to-native-top-level)
                                        for-late-load)
   (unless for-late-load
-    (let ((form (byte-to-native-top-level-form form)))
-      (comp-emit (comp-call 'eval
-                            (let ((comp-curr-allocation-class 'd-impure))
-                              (make-comp-mvar :constant form))
-                            (make-comp-mvar :constant t))))))
+    (comp-emit
+     (comp-call 'eval
+                (let ((comp-curr-allocation-class 'd-impure))
+                  (make-comp-mvar :constant
+                                  (byte-to-native-top-level-form form)))
+                (make-comp-mvar :constant
+                                (byte-to-native-top-level-lexical form))))))
 
 (defun comp-emit-lambda-for-top-level (func)
   "Emit the creation of subrs for lambda FUNC.