Cannot find type for specializer #:G0
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
(unwind-protect
(progn (defclass #1=#.(gensym) () ())
(setf (find-class '#1#) nil))
On SBCL 1.4.4 evaluating this causes a warning to be emitted:
; file: /tmp/slime9rrJ50
; in: DEFMETHOD INITIALIZE-INSTANCE
; (CLOSER-
; :BEFORE
; ((PROTEST/
; --> DEFMETHOD PROGN EVAL-WHEN
; ==>
; (SB-PCL:
; ((PROTEST/
;
; caught STYLE-WARNING:
; Cannot find type for specializer #:G0 when executing
; SB-PCL:
; STANDARD-
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
The macroexpander of DEFMETHOD is to blame, but this could be considered just an unfortunate side-effect of *EVALUATOR-MODE* being set to :COMPILE, which makes the entire form a single lambda. As such, the defmethod expander warns before the DEFCLASS is executed. Some potential fixes:
- get the macro to inject the WARN call into the :COMPILE-TOPLEVEL effects of its expansion so that it will only warn from COMPILE-FILE
- remove the warning generation from the macro, but put a compiler-macro on LOAD-DEFMETHOD that warns if any of the classes named in its 4th argument - which should always have the form (LIST (FIND-CLASS 'thing) ...) - aren't known.
This is similar to using vacuous transforms as we do to detect misshapen FORMAT strings.
- just remove the warning entirely. this is really taking the low road
- don't set *EVALUATOR-MODE* to :COMPILE
- turn this warning into a deferrable warning (patch attached)