Warn when defining a setf-function together with a setf-expander.
authorStas Boukarev <stassats@gmail.com>
Thu, 15 Aug 2013 14:40:51 +0000 (18:40 +0400)
committerStas Boukarev <stassats@gmail.com>
Thu, 15 Aug 2013 14:40:51 +0000 (18:40 +0400)
Patch by Douglas Katzman.

NEWS
src/compiler/info-functions.lisp
tests/compiler.impure.lisp

diff --git a/NEWS b/NEWS
index 9a8a4e9..7327aaa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ changes relative to sbcl-1.1.10
   * bug fix: (funcall (function X junk)) didn't causes an error when X had a
     compiler macro.
     Patch by Douglas Katzman.
+  * bug fix: signal a warning when defining a setf-function when a
+    setf-expander is already present.
+    Patch by Douglas Katzman.
 
 changes in sbcl-1.1.10 relative to sbcl-1.1.9:
   * enhancement: ASDF has been updated to 3.0.2.
index ea876b7..d763505 100644 (file)
 ;;; can't assume that they aren't just naming a function (SETF FOO)
 ;;; for the heck of it. NAME is already known to be well-formed.
 (defun note-if-setf-fun-and-macro (name)
-  (when (consp name)
-    (when (or (info :setf :inverse name)
-              (info :setf :expander name))
+  (when (and (consp name)
+             (eq (car name) 'setf))
+    (when (or (info :setf :inverse (second name))
+              (info :setf :expander (second name)))
       (compiler-style-warn
        "defining as a SETF function a name that already has a SETF macro:~
        ~%  ~S"
index a11df47..adc6a75 100644 (file)
 (with-test (:name funcall-compiler-macro)
   (assert
    (handler-case
-       (compile nil
-                `(lambda ()
-                   (funcall (function test-function-983 junk) 1)))
-     (sb-c:compiler-error () t)
-     (:no-error () nil))))
+       (and (compile nil
+                     `(lambda ()
+                        (funcall (function test-function-983 junk) 1)))
+            nil)
+     (sb-c:compiler-error () t))))
+
+(defsetf test-984 %test-984)
+
+(with-test (:name :setf-function-with-setf-expander)
+  (assert
+   (handler-case
+       (and
+        (defun (setf test-984) ())
+        nil)
+     (style-warning () t))))
 \f
 ;;;; tests not in the problem domain, but of the consistency of the
 ;;;; compiler machinery itself