fix bug in SYMBOL-VALUE CAS expansion for constant arguments
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 10 Sep 2012 22:08:25 +0000 (01:08 +0300)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 10 Sep 2012 22:52:16 +0000 (01:52 +0300)
NEWS
src/code/late-cas.lisp
tests/compare-and-swap.impure.lisp

diff --git a/NEWS b/NEWS
index a858d46..ce74270 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ changes relative to sbcl-1.0.58:
   * bug fix: SB-BSD-SOCKETS:SOCKET-RECEIVE with a UDP socket now works
     correctly when the received datagram is larger than the provided buffer.
     (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.
   * documentation: a section on random number generation has been added to the
     manual. (lp#656839)
 
index dd912dc..0ae2ca3 100644 (file)
@@ -28,7 +28,7 @@
                           ',cname ,old (the ,(info :variable :type cname) ,new))
                         slow)
                     slow))
-              `(symbol-global-value ,tmp)))))
+              `(symbol-global-value ,(or tmp `',cname))))))
 
 (define-cas-expander svref (vector index)
   (with-unique-names (v i old new)
index f51559f..da4e2c9 100644 (file)
     (assert (eq t (cas (thing b) nil :oops)))
     (assert (eq t (thing a)))
     (assert (eq t (thing b)))))
+
+;;; SYMBOL-VALUE with a constant argument used to return a bogus read-form
+(with-test (:name :symbol-value-cas-expansion)
+  (multiple-value-bind (vars vals old new cas-form read-form)
+      (get-cas-expansion `(symbol-value t))
+    (assert (not vars))
+    (assert (not vals))
+    (assert (eq t (eval read-form))))
+  (multiple-value-bind (vars vals old new cas-form read-form)
+      (get-cas-expansion `(symbol-value *))
+    (let ((* :foo))
+      (assert (eq :foo
+                  (eval `(let (,@(mapcar 'list vars vals))
+                      ,read-form)))))
+    (let ((* :bar))
+      (assert (eq :bar
+                  (eval `(let (,@(mapcar 'list vars vals))
+                      ,read-form)))))))