fix CAS on DEFCAS-defined places when the form is a macro
authorNikodemus Siivola <nikodemus@random-state.net>
Sat, 15 Sep 2012 11:21:22 +0000 (14:21 +0300)
committerNikodemus Siivola <nikodemus@random-state.net>
Sat, 15 Sep 2012 11:27:06 +0000 (14:27 +0300)
NEWS
src/code/cas.lisp
tests/compare-and-swap.impure.lisp

diff --git a/NEWS b/NEWS
index ce74270..6fc3407 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ changes relative to sbcl-1.0.58:
     (lp#1023438, thanks to Robert Uhl)
   * bug fix: SB-EXT:GET-CAS-EXPANSION returned a bogus read-form when given
     a SYMBOL-VALUE form with a constant symbol argument.
+  * bug fix: SB-EXT:GET-CAS-EXPANSION signaled an error when a macro expanding
+    into a DEFCAS defined place was used as the place.
   * documentation: a section on random number generation has been added to the
     manual. (lp#656839)
 
index 63ff0d9..84f4c43 100644 (file)
@@ -93,7 +93,7 @@ EXPERIMENTAL: Interface subject to change."
           (cond
             ;; CAS expander.
             (info
-             (funcall info place environment))
+             (funcall info expanded environment))
 
             ;; Structure accessor
             ((setf info (info :function :structure-accessor name))
index da4e2c9..6ec6547 100644 (file)
       (assert (eq :bar
                   (eval `(let (,@(mapcar 'list vars vals))
                       ,read-form)))))))
+(let ((foo (cons :foo nil)))
+  (defun cas-foo (old new)
+    (cas (cdr foo) old new)))
+
+(defcas foo () cas-foo)
+
+(with-test (:name :cas-and-macroexpansion)
+  (assert (not (cas (foo) nil t)))
+  (assert (eq t (cas (foo) t nil)))
+  (symbol-macrolet ((bar (foo)))
+    (assert (not (cas bar nil :ok)))
+    (assert (eq :ok (cas bar :ok nil)))
+    (assert (not (cas bar nil t)))))