From: Nikodemus Siivola Date: Sat, 15 Sep 2012 11:21:22 +0000 (+0300) Subject: fix CAS on DEFCAS-defined places when the form is a macro X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=76db27f585eda84ab93411dd61b32677355f8cc4;p=sbcl.git fix CAS on DEFCAS-defined places when the form is a macro --- diff --git a/NEWS b/NEWS index ce74270..6fc3407 100644 --- 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) diff --git a/src/code/cas.lisp b/src/code/cas.lisp index 63ff0d9..84f4c43 100644 --- a/src/code/cas.lisp +++ b/src/code/cas.lisp @@ -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)) diff --git a/tests/compare-and-swap.impure.lisp b/tests/compare-and-swap.impure.lisp index da4e2c9..6ec6547 100644 --- a/tests/compare-and-swap.impure.lisp +++ b/tests/compare-and-swap.impure.lisp @@ -412,3 +412,16 @@ (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)))))