style warning from passing keyword as enum arguments of inlined foreign functions in sbcl with SPEED 3
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
CFFI |
New
|
Undecided
|
Unassigned |
Bug Description
(cffi:defcenum (foo) (:a 1))
(declaim (inline foo))
(cffi:defcfun foo :void (a foo))
(defun bar ()
(declare (optimize speed))
(foo :a))
; in: DEFUN BAR
; (FOO :A)
; --> BLOCK LET LET IF
; ==>
; #:VALUE2
;
; caught STYLE-WARNING:
; This is not a (UNSIGNED-BYTE 32):
; :A
; See also:
; The SBCL Manual, Node "Handling of Types"
;
the DEFCFUN expands to something similar to
(defun foo (a)
(let ((a (if (keywordp a)
a)))
(cffi:
and SBCL doesn't constant-fold KEYWORDP since the symbol could be uninterned from KEYWORD package, so it can't be sure :a won't be passed to the foreign function.
Possibly it should use SYMBOLP there instead since unrecognized non-keyword symbols are an error either way, and in the edge case of someone uninterning a keyword used in an enum, it should probably still be accepted.
actually, looking closer, DEFCENUM and FOREIGN-ENUM-VALUE accept non-keyword keys, so KEYWORDP is wrong there anyway