From 724b51e6acb1fd0040de3751c9e4566e7a87ced3 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Sat, 7 Jun 2003 13:49:11 +0000 Subject: [PATCH] 0.8.0.43: Fix bug 63, by propagating symbol macros into the walker's variable environment ... no, I don't claim to have understood the walker fully; ... test for correct behaviour in sb-cltl2's MACROEXPAND-ALL. --- BUGS | 11 ----------- NEWS | 2 ++ contrib/sb-cltl2/.cvsignore | 1 + contrib/sb-cltl2/tests.lisp | 11 +++++++++++ src/pcl/walk.lisp | 19 ++++++++++++------- version.lisp-expr | 2 +- 6 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 contrib/sb-cltl2/.cvsignore diff --git a/BUGS b/BUGS index 1d1a83d..910d617 100644 --- a/BUGS +++ b/BUGS @@ -257,17 +257,6 @@ WORKAROUND: then requesting a BACKTRACE at the debugger prompt gives no information about where in the user program the problem occurred. -63: - Paul Werkowski wrote on cmucl-imp@cons.org 2000-11-15 - I am looking into this problem that showed up on the cmucl-help - list. It seems to me that the "implementation specific environment - hacking functions" found in pcl/walker.lisp are completely messed - up. The good thing is that they appear to be barely used within - PCL and the munged environment object is passed to cmucl only - in calls to macroexpand-1, which is probably why this case fails. - SBCL uses essentially the same code, so if the environment hacking - is screwed up, it affects us too. - 64: Using the pretty-printer from the command prompt gives funny results, apparently because the pretty-printer doesn't know diff --git a/NEWS b/NEWS index 773ddf2..fb5f80e 100644 --- a/NEWS +++ b/NEWS @@ -1805,6 +1805,8 @@ changes in sbcl-0.8.1 relative to sbcl-0.8.0: SB-EXT:DEFCONSTANT-UNEQL if it is being asked to redefine a constant to a non-EQL value; CONTINUE and ABORT restarts respectively change and preserve the value. + * fixed bug 63: the code walker, part of the implementation of CLOS, + is better at handling symbol macros. * fixed some bugs revealed by Paul Dietz' test suite: ** NIL is now allowed as a structure slot name. ** arbitrary numbers, not just reals, are allowed in certain diff --git a/contrib/sb-cltl2/.cvsignore b/contrib/sb-cltl2/.cvsignore new file mode 100644 index 0000000..e805886 --- /dev/null +++ b/contrib/sb-cltl2/.cvsignore @@ -0,0 +1 @@ +test-passed diff --git a/contrib/sb-cltl2/tests.lisp b/contrib/sb-cltl2/tests.lisp index c649297..19d5f05 100644 --- a/contrib/sb-cltl2/tests.lisp +++ b/contrib/sb-cltl2/tests.lisp @@ -45,3 +45,14 @@ (foo 1)))))) (remove-duplicates *expansions*)) (1)) + +(defun smv (env) + (multiple-value-bind (expansion macro-p) + (macroexpand 'srlt env) + (when macro-p (eval expansion)))) +(defmacro testr (&environment env) + `',(getf (smv env) nil)) + +(deftest macroexpand-all.4 + (macroexpand-all '(symbol-macrolet ((srlt '(nil zool))) (testr))) + (symbol-macrolet ((srlt '(nil zool))) 'zool)) diff --git a/src/pcl/walk.lisp b/src/pcl/walk.lisp index e37c4f1..ac68857 100644 --- a/src/pcl/walk.lisp +++ b/src/pcl/walk.lisp @@ -153,6 +153,9 @@ (let ((lexenv (sb!kernel::coerce-to-lexenv env))) (sb!c::make-lexenv :default lexenv + :vars (when (eql (caar macros) *key-to-walker-environment*) + (copy-tree (remove :lexical-var (fourth (cadar macros)) + :key #'cadr))) :funs (append (mapcar (lambda (f) (cons (car f) (sb!c::make-functional :lexenv lexenv))) @@ -236,14 +239,14 @@ (defun walker-environment-bind-1 (env &key (walk-function nil wfnp) (walk-form nil wfop) (declarations nil decp) - (lexical-variables nil lexp)) - (let ((lock (environment-macro env *key-to-walker-environment*))) + (lexical-vars nil lexp)) + (let ((lock (env-lock env))) (list (list *key-to-walker-environment* - (list (if wfnp walk-function (car lock)) - (if wfop walk-form (cadr lock)) - (if decp declarations (caddr lock)) - (if lexp lexical-variables (cadddr lock))))))) + (list (if wfnp walk-function (car lock)) + (if wfop walk-form (cadr lock)) + (if decp declarations (caddr lock)) + (if lexp lexical-vars (cadddr lock))))))) (defun env-walk-function (env) (car (env-lock env))) @@ -397,6 +400,8 @@ ;;; SBCL-only special forms (define-walker-template sb!ext:truly-the (nil quote eval)) +;;; FIXME: maybe we don't need this one any more, given that +;;; NAMED-LAMBDA now expands into (FUNCTION (NAMED-LAMBDA ...))? (define-walker-template named-lambda walk-named-lambda) (defvar *walk-form-expand-macros-p* nil) @@ -845,7 +850,7 @@ (body (cddr form))) (walker-environment-bind (new-env old-env - :lexical-variables + :lexical-vars (append (mapcar (lambda (binding) `(,(car binding) sb!sys:macro . ,(cadr binding))) diff --git a/version.lisp-expr b/version.lisp-expr index 2cffca4..ba26d22 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.0.42" +"0.8.0.43" -- 1.7.10.4