From: Stas Boukarev Date: Mon, 4 Feb 2013 11:21:22 +0000 (+0400) Subject: Fix (documentation #'function t) X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=2e52fa0553c5a256f482ee14e30608acf55e5f48;p=sbcl.git Fix (documentation #'function t) (defun test () "xx" nil) (setf (documentation 'test 'function) "test") (list (documentation #'test t) (documentation 'test 'function))) returned ("xx" "test"). --- diff --git a/NEWS b/NEWS index e0fea8f..2ac0eb7 100644 --- a/NEWS +++ b/NEWS @@ -23,13 +23,16 @@ changes relative to sbcl-1.1.4: SB-DEBUG:BACKTRACE-AS-LIST. ** SB-DEBUG:*SHOW-ENTRY-POINT-DETAILS** has been deprecated, as the same information is available in less intrusive form as frame annotations. - * enhancement: SB-POSIX now supports provides MAP-ANON. + * enhancement: SB-POSIX now provides MAP-ANON. * bug fix: no more unused variable style warnings from RESTART-CASE macroexpansion (lp#1113859) * bug fix: deleting a package removes it from implementation-package lists of other packages. * bug fix: SB-SPROF:WITH-PROFILING is now usable in the Slime REPL on Darwin. This does not fix the occasional "interrupt already pending" issue, though. + * bug fix: (setf (documentation 'x 'function)) and + (setf (documentation #'x t)) set documentation in different places. + (regression since 1.0.43.63) changes in sbcl-1.1.4 relative to sbcl-1.1.3: * optimization: LOOP expressions using "of-type character" have slightly diff --git a/src/pcl/documentation.lisp b/src/pcl/documentation.lisp index e992894..7521653 100644 --- a/src/pcl/documentation.lisp +++ b/src/pcl/documentation.lisp @@ -18,6 +18,35 @@ (setf (slot-value x '%documentation) new-value) (setf (%fun-doc x) new-value))) +(defun real-function-name (name) + ;; Resolve the actual name of the function named by NAME + ;; e.g. (setf (name-function 'x) #'car) + ;; (real-function-name 'x) => CAR + (cond ((not (fboundp name)) + nil) + ((and (symbolp name) + (special-operator-p name)) + (%fun-name (fdefinition name))) + ((and (symbolp name) + (macro-function name)) + (let ((name (%fun-name (macro-function name)))) + (and (consp name) + (eq (car name) 'macro-function) + (cadr name)))) + (t + (sb-impl::fun-name (fdefinition name))))) + +(defun set-function-name-documentation (name documentation) + (cond ((not (legal-fun-name-p name)) + nil) + ((not (equal (real-function-name name) name)) + (setf (random-documentation name 'function) documentation)) + (t + (setf (fun-doc (or (and (symbolp name) + (macro-function name)) + (fdefinition name))) + documentation)))) + ;;; functions, macros, and special forms (defmethod documentation ((x function) (doc-type (eql 't))) (fun-doc x)) @@ -62,16 +91,14 @@ (setf (fun-doc x) new-value)) (defmethod (setf documentation) (new-value (x list) (doc-type (eql 'function))) - (when (legal-fun-name-p x) - (setf (random-documentation x 'function) new-value))) + (set-function-name-documentation x new-value)) (defmethod (setf documentation) (new-value (x list) (doc-type (eql 'compiler-macro))) (awhen (compiler-macro-function x) (setf (documentation it t) new-value))) (defmethod (setf documentation) (new-value (x symbol) (doc-type (eql 'function))) - (when (legal-fun-name-p x) - (setf (random-documentation x 'function) new-value))) + (set-function-name-documentation x new-value)) (defmethod (setf documentation) (new-value (x symbol) (doc-type (eql 'compiler-macro))) (awhen (compiler-macro-function x) diff --git a/tests/interface.impure.lisp b/tests/interface.impure.lisp index 31cb517..4391278 100644 --- a/tests/interface.impure.lisp +++ b/tests/interface.impure.lisp @@ -297,5 +297,20 @@ (assert (or (member :big-endian *features*) (member :little-endian *features*)))) + +(with-test (:name :function-documentation-mismatch) + (defun test () + "X" + nil) + (setf (symbol-function 'test2) #'test) + (setf (documentation 'test 'function) "Y") + (assert (equal (documentation #'test t) + (documentation 'test 'function))) + (setf (documentation 'test2 'function) "Z") + (assert (not + (equal (documentation 'test 'function) + (documentation 'test2 'function))))) + + ;;;; success