1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; While most of SBCL is derived from the CMU CL system, the test
5 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; This software is in the public domain and is provided with
9 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
10 ;;;; more information.
14 ;;; Check for fbound external symbols in public packages that have no
15 ;;; argument list information. (This used to be possible when we got
16 ;;; carried away with byte compilation, since the byte compiler can't
17 ;;; record argument list information. Now that there's no byte
18 ;;; compiler, that can't happen, but it still shouldn't hurt to check
19 ;;; in case the argument information goes astray some other way.)
20 (defvar *public-package-names*
21 '("SB-ALIEN" "SB-C-CALL" "SB-DEBUG" "SB-EXT" "SB-GRAY" "SB-MP"
22 "SB-PROFILE" "SB-PCL" "COMMON-LISP"))
23 (defun has-arglist-info-p (function)
24 (declare (type function function))
25 ;; The Lisp-level type FUNCTION can conceal a multitude of sins..
26 (case (sb-kernel:get-type function)
27 ((#.sb-vm:function-header-type #.sb-vm:closure-function-header-type)
28 (sb-kernel:%function-arglist function))
29 (#.sb-vm:closure-header-type (has-arglist-info-p
30 (sb-kernel:%closure-function
32 ;; in code/describe.lisp, ll. 227 (%describe-function), we use a scheme
33 ;; like above, and it seems to work. -- MNA 2001-06-12
35 ;; (There might be other cases with arglist info also.
36 ;; FUNCTION-HEADER-TYPE and CLOSURE-HEADER-TYPE just
37 ;; happen to be the two case that I had my nose rubbed in when
38 ;; debugging a GC problem caused by applying %FUNCTION-ARGLIST to
39 ;; a closure. -- WHN 2001-06-05)
41 (defun check-ext-symbols-arglist (package)
42 (format t "~% looking at package: ~A" package)
43 (do-external-symbols (ext-sym package)
44 (when (fboundp ext-sym)
45 (let ((fun (symbol-function ext-sym)))
46 (cond ((macro-function ext-sym)
47 ;; FIXME: Macro functions should have their argument list
48 ;; information checked separately. Just feeding them into
49 ;; the ordinary-function logic below doesn't work right,
50 ;; though, and I haven't figured out what does work
51 ;; right. For now we just punt.
54 ((sb-int:info :function :accessor-for ext-sym)
56 ((typep fun 'generic-function)
57 (sb-pcl::generic-function-pretty-arglist fun))
59 (let ((fun (symbol-function ext-sym)))
60 (unless (has-arglist-info-p fun)
61 (error "Function ~A has no arg-list information available."
63 (dolist (public-package *public-package-names*)
64 (when (find-package public-package)
65 (check-ext-symbols-arglist public-package)))
68 ;;; FIXME: It would probably be good to require here that every
69 ;;; external symbol either has a doc string or has some good excuse
70 ;;; (like being an accessor for a structure which has a doc string).