don't simplify (LET () ..) => (LOCALLY ...) in the simple evalutor
authorNikodemus Siivola <nikodemus@random-state.net>
Thu, 1 Dec 2011 19:05:43 +0000 (21:05 +0200)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 5 Dec 2011 10:15:52 +0000 (12:15 +0200)
  If LET is at toplevel its subforms are not.

  If LOCALLY is at toplevel its subforms are also at toplevel.

NEWS
src/code/eval.lisp
tests/eval.impure.lisp

diff --git a/NEWS b/NEWS
index 8c3eecb..a69f353 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,8 @@ changes relative to sbcl-1.0.54:
   * bug fix: bogus style-warnings for DEFMETHOD forms that both declared some
     required arguments ignored and performed assignments to others.
     (lp#898331)
+  * bug fix: *EVALUATOR-MODE* :COMPILE treated (LET () ...) identically
+    to (LOCALLY ...) leading to internally inconsistent toplevel-formness.
 
 changes in sbcl-1.0.54 relative to sbcl-1.0.53:
   * minor incompatible changes:
index 4687ebd..dc74c2c 100644 (file)
                                       else)
                                   lexenv)))
                ((let let*)
-                (destructuring-bind (definitions &rest body) (rest exp)
-                  (if (null definitions)
-                      (simple-eval-locally `(locally ,@body) lexenv)
-                      (%simple-eval exp lexenv))))
+                (%simple-eval exp lexenv))
                (t
                 (if (and (symbolp name)
                          (eq (info :function :kind name) :function))
index 6afd64c..0baf4e9 100644 (file)
     (with-input-from-string (s noise)
       (assert (equal "; in: DEFUN SOURCE-CONTEXT-TEST" (read-line s))))))
 
+(with-test (:name (eval :empty-let-is-not-toplevel))
+  (let ((sb-ext:*evaluator-mode* :compile))
+    (eval `(let ()
+             (defmacro empty-let-is-not-toplevel-x () :macro)
+             (defun empty-let-is-not-toplevel-fun ()
+               (empty-let-is-not-toplevel-x))))
+    (eval `(defun empty-let-is-not-toplevel-x () :fun))
+    (assert (eq :fun (empty-let-is-not-toplevel-fun))))
+  ;; While at it, test that we get the late binding under
+  ;; interpreter mode.
+  (let ((sb-ext:*evaluator-mode* :interpret))
+    (eval `(let ()
+             (defmacro empty-let-is-not-toplevel-x () :macro)
+             (defun empty-let-is-not-toplevel-fun ()
+               (empty-let-is-not-toplevel-x))))
+    (assert (eq :macro (empty-let-is-not-toplevel-fun)))
+    (eval `(defun empty-let-is-not-toplevel-x () :fun))
+    (assert (eq :fun (empty-let-is-not-toplevel-fun)))))
+
 ;;; success