Comment 4 for bug 309115

Revision history for this message
3b (00003b) wrote :

some more possible examples with various warnings/style warnings in 1.2.6 (and 1.2.1)

(declaim (inline foo))
(defun foo (pointer)
  (flet ((pointer-address (ptr)
           (declare (type system-area-pointer ptr))
           (sb-sys:sap-int ptr)))
    (if (sb-sys:system-area-pointer-p pointer)
        (pointer-address pointer)
        pointer)))

(defun bar ()
  (unwind-protect
       (foo 0)))

* ; in: DEFUN BAR
; (FOO 0)
; --> BLOCK FLET BLOCK
; ==>
; (SB-SYS:SAP-INT PTR)
;
; caught STYLE-WARNING:
; Lisp error during constant folding:
; The value 0 is not of type SYSTEM-AREA-POINTER.

(DEFUN foo1 ()
  (let ((type :float))
    (the (unsigned-byte) (IF (KEYWORDP TYPE)
                             123
                             TYPE))))
; in: DEFUN FOO1
; (THE (UNSIGNED-BYTE)
; (IF (KEYWORDP TYPE)
; 123
; TYPE))
;
; caught WARNING:
; Derived type of TYPE is
; (VALUES (MEMBER :FLOAT) &OPTIONAL),
; conflicting with its asserted type
; UNSIGNED-BYTE.
; See also:
; The SBCL Manual, Node "Handling of Types"

(DEFUN foo2 ()
  (let ((type :float))
    (let ((t2 (IF (KEYWORDP TYPE)
                  123
                  TYPE)))
      (declare (unsigned-byte t2) (ignore t2)))))
; in: DEFUN FOO2
; (IF (KEYWORDP TYPE)
; 123
; TYPE)
; ==>
; TYPE
;
; caught STYLE-WARNING:
; This is not a UNSIGNED-BYTE:
; :FLOAT
; See also:
; The SBCL Manual, Node "Handling of Types"