gcontext extensions and broken code
Christophe Rhodes <[email protected]> Thu, 29 May 2003 13:50:49 +0100
| Newsgroups | gmane.lisp.clx.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Does anyone know what COPY-GCONTEXT-COMPONENTS is meant to do? SBCL's shiny new type inferencer has correctly detected that the code implementing it currently invokes undefined behaviour for non-null *GCONTEXT-EXTENSIONS*: (defun copy-gcontext-components (src dst &rest keys) (declare (type gcontext src dst) (dynamic-extent keys)) ... (multiple-value-bind (extension index) (find key *gcontext-extensions* :key #'gcontext-extension-name) (if extension (funcall (gcontext-extension-copy-function extension) src dst (svref (gcontext-local-state src) (index+ index *gcontext-data-length*))) (x-type-error key 'gcontext-key))) ...) Since FIND always returns one value, INDEX is always bound to NIL; then INDEX+ acts on something that's declared to be a positive fixnum (loosely). The actual warning from SBCL says: ; (XLIB::INDEX+ XLIB::INDEX XLIB::*GCONTEXT-DATA-LENGTH*) ; --> THE VALUES PROG1 LET + ; ==> ; (THE XLIB:ARRAY-INDEX XLIB::INDEX) ; ; caught WARNING: ; Asserted type (UNSIGNED-BYTE 29) conflicts with derived type ; (VALUES NULL &OPTIONAL). which I think is reasonable. Any ideas what the correct code would look like? Cheers, Christophe -- http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757 (set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b))) (defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)