0.8.0.6:
[sbcl.git] / tests / walk.impure.lisp
index 6ce7968..693000b 100644 (file)
 (defun take-it-out-for-a-test-walk-1 (form)
   (let ((copy-of-form (copy-tree form))
        (result (walk-form form nil
-                 #'(lambda (x y env)
-                     (format t "~&Form: ~S ~3T Context: ~A" x y)
-                     (when (symbolp x)
-                       (let ((lexical (variable-lexical-p x env))
-                             (special (variable-special-p x env)))
-                         (when lexical
-                           (format t ";~3T")
-                           (format t "lexically bound"))
-                         (when special
-                           (format t ";~3T")
-                           (format t "declared special"))
-                         (when (boundp x)
-                           (format t ";~3T")
-                           (format t "bound: ~S " (eval x)))))
-                     x))))
+                 (lambda (x y env)
+                   (format t "~&Form: ~S ~3T Context: ~A" x y)
+                   (when (symbolp x)
+                     (let ((lexical (var-lexical-p x env))
+                           (special (var-special-p x env)))
+                       (when lexical
+                         (format t ";~3T")
+                         (format t "lexically bound"))
+                       (when special
+                         (format t ";~3T")
+                         (format t "declared special"))
+                       (when (boundp x)
+                         (format t ";~3T")
+                         (format t "bound: ~S " (eval x)))))
+                   x))))
     (cond ((not (equal result copy-of-form))
           (format t "~%Warning: Result not EQUAL to copy of start."))
          ((not (eq result form))
@@ -153,11 +153,24 @@ Form: 'INNER   Context: EVAL
   (FOO 1))"))
 
 
-;;; A slightly more complex MACROLET case. In the body of the macro X
-;;; should not be lexically bound. In the body of the macrolet form itself
-;;; X should be bound. Note that THIS CASE WILL CAUSE AN ERROR when it
-;;; tries to macroexpand the call to FOO.
-
+;;; The original PCL documentation for this test said
+;;;   A slightly more complex MACROLET case. In the body of the macro
+;;;   X should not be lexically bound. In the body of the macrolet
+;;;   form itself X should be bound. Note that THIS CASE WILL CAUSE AN
+;;;   ERROR when it tries to macroexpand the call to FOO.
+;;;
+;;; This test is commented out in SBCL because ANSI says, in the
+;;; definition of the special operator MACROLET,
+;;;    The macro-expansion functions defined by MACROLET are defined
+;;;    in the lexical environment in which the MACROLET form appears.
+;;;    Declarations and MACROLET and SYMBOL-MACROLET definitions affect
+;;;    the local macro definitions in a MACROLET, but the consequences
+;;;    are undefined if the local macro definitions reference any
+;;;    local variable or function bindings that are visible in that
+;;;    lexical environment. 
+;;; Since the behavior is undefined, anything we do conforms.:-|
+;;; This is of course less than ideal; see bug 124.
+#+nil
 (multiple-value-bind (res cond)
     (ignore-errors
       (take-it-out-for-a-test-walk
@@ -922,14 +935,14 @@ Form: NIL   Context: EVAL; bound: NIL
          (with-output-to-string (*standard-output*)
            (let ((the-lexical-variables ()))
              (walk-form '(let ((a 1) (b 2))
-                          #'(lambda (x) (list a b x y)))
+                          (lambda (x) (list a b x y)))
                         ()
-                        #'(lambda (form context env)
-                            (declare (ignore context))
-                            (when (and (symbolp form)
-                                       (variable-lexical-p form env))
-                              (push form the-lexical-variables))
-                            form))
+                        (lambda (form context env)
+                         (declare (ignore context))
+                         (when (and (symbolp form)
+                                    (var-lexical-p form env))
+                           (push form the-lexical-variables))
+                         form))
              (or (and (= (length the-lexical-variables) 3)
                       (member 'a the-lexical-variables)
                       (member 'b the-lexical-variables)
@@ -937,4 +950,8 @@ Form: NIL   Context: EVAL; bound: NIL
                  (error "Walker didn't do lexical variables of a closure properly."))))
          ""))
 \f
+;; old PCL hung up on it
+(defmethod #:foo ()
+  (defun #:bar ()))
+\f
 (quit :unix-status 104)