From 13bf1193b6c3429a5881a5d604daea33a187a5b2 Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Thu, 15 Aug 2013 18:40:51 +0400 Subject: [PATCH] Warn when defining a setf-function together with a setf-expander. Patch by Douglas Katzman. --- NEWS | 3 +++ src/compiler/info-functions.lisp | 7 ++++--- tests/compiler.impure.lisp | 20 +++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 9a8a4e9..7327aaa 100644 --- 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. diff --git a/src/compiler/info-functions.lisp b/src/compiler/info-functions.lisp index ea876b7..d763505 100644 --- a/src/compiler/info-functions.lisp +++ b/src/compiler/info-functions.lisp @@ -85,9 +85,10 @@ ;;; 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" diff --git a/tests/compiler.impure.lisp b/tests/compiler.impure.lisp index a11df47..adc6a75 100644 --- a/tests/compiler.impure.lisp +++ b/tests/compiler.impure.lisp @@ -1416,11 +1416,21 @@ (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)))) ;;;; tests not in the problem domain, but of the consistency of the ;;;; compiler machinery itself -- 1.7.10.4