0.9.5.29:
authorChristophe Rhodes <csr21@cam.ac.uk>
Fri, 7 Oct 2005 04:57:09 +0000 (04:57 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Fri, 7 Oct 2005 04:57:09 +0000 (04:57 +0000)
Fix bug reported by Matthew D Swank on comp.lang.lisp
... macroexpand-1 shouldn't expand a global symbol macro
if there's a local binding in the environment.
... (setf wasn't getting this wrong, because it was converting
immediately to setq, but push was, because it calls
get-setf-expansion)

NEWS
src/code/macroexpand.lisp
tests/macroexpand.impure.lisp [new file with mode: 0644]
version.lisp-expr

diff --git a/NEWS b/NEWS
index 968c8ed..c666ace 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ changes in sbcl-0.9.6 relative to sbcl-0.9.5:
     (thanks to Svein Ove Aas)
   * bug fix: Unicode symbols are correctly printed in LDB backtraces
     (thanks to David Lichteblau)
+  * bug fix: local bindings shadow global symbol macros for
+    macroexpansion.  (reported by Matthew D Swank on comp.lang.lisp)
   * optimization: non-open coded uses of numeric comparison operators
     (e.g. >) no longer cons when called with more than one parameter
     on platforms supporting dynamic-extent allocation.
index 9a94350..ca38c6c 100644 (file)
@@ -58,6 +58,8 @@
            (cond ((and (consp local-def)
                        (eq (car local-def) 'macro))
                   (values (cdr local-def) t))
+                 (local-def
+                  (values form nil))
                  ((eq (info :variable :kind form) :macro)
                   (values (info :variable :macro-expansion form) t))
                  (t
diff --git a/tests/macroexpand.impure.lisp b/tests/macroexpand.impure.lisp
new file mode 100644 (file)
index 0000000..6f5863d
--- /dev/null
@@ -0,0 +1,29 @@
+;;;; This file is for macroexpander tests which have side effects
+
+;;;; This software is part of the SBCL system. See the README file for
+;;;; more information.
+;;;;
+;;;; While most of SBCL is derived from the CMU CL system, the test
+;;;; files (like this one) were written from scratch after the fork
+;;;; from CMU CL.
+;;;;
+;;;; This software is in the public domain and is provided with
+;;;; absolutely no warranty. See the COPYING and CREDITS files for
+;;;; more information.
+
+;;; From Matthew Swank on cll 2005-10-06
+
+(defmacro defglobal (name &optional value)
+  (let ((internal (gensym)))
+    `(progn
+       (defparameter ,internal ,value)
+       (define-symbol-macro ,name ,internal))))
+
+(defglobal glob)
+
+(assert (= (let ((glob 4)) glob)))
+(assert (null glob))
+(assert (equal (let ((glob nil)) (setf glob (cons 'foo glob)) glob) '(foo)))
+(assert (null glob))
+(assert (equal (let ((glob nil)) (push 'foo glob) glob) '(foo)))
+(assert (null glob))
index f1d8d07..2541d65 100644 (file)
@@ -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.9.5.27"
+"0.9.5.29"