Ugly style-warning from defmethod close

Bug #839937 reported by Svante v. Erichsen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Triaged
Medium
Unassigned

Bug Description

I get an ugly style-warning whenever I load a (defmethod close
((stream whatever-stream) &key abort) ...). It complains that an
earlier ftype proclamation is clobbered (see below). Affected systems
are for example chunga and flexi-streams.

I believe that it comes from the fact that the "original" close
/function/ is replaced by a generic function in gray-streams.lisp, but
its inferred ftype is not removed. This might be fixed by giving an
appropriate ftype declamation in gray-streams.lisp.

Minimal test:

CL-USER> (defclass my-stream (stream)
           (foo))
#<STANDARD-CLASS MY-STREAM>
CL-USER> (defmethod close ((stream my-stream) &key abort)
           (close stream :abort abort))
STYLE-WARNING:
   Generic function CLOSE clobbers an earlier FTYPE proclamation
   (FUNCTION (STREAM &KEY (:ABORT T)) (VALUES (MEMBER T) &OPTIONAL)) for
   the same name with (FUNCTION (T &KEY (:ABORT T)) *).
#<STANDARD-METHOD SB-GRAY::PCL-CLOSE (MY-STREAM) {C222699}>
CL-USER>

sbcl --version: SBCL 1.0.51

uname -a: Linux alraune 2.6.34-tuxonice-r6alraune #3 SMP Mon Jan 3
00:16:24 CET 2011 i686 Pentium(R) Dual-Core CPU T4200 @ 2.00GHz
GenuineIntel GNU/Linux

*features*: (:QUICKLISP :SB-BSD-SOCKETS-ADDRINFO :ASDF2 :ASDF :ASDF-UNIX :ANSI-CL
 :COMMON-LISP :SBCL :SB-DOC :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL
 :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT :X86 :UNIX :ELF :LINUX :SB-THREAD
 :LARGEFILE :GENCGC :STACK-GROWS-DOWNWARD-NOT-UPWARD :C-STACK-IS-CONTROL-STACK
 :COMPARE-AND-SWAP-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP :RAW-INSTANCE-INIT-VOPS
 :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-VECTORS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-FIXED-OBJECTS :ALIEN-CALLBACKS
 :CYCLE-COUNTER :INLINE-CONSTANTS :MEMORY-BARRIER-VOPS :MULTIPLY-HIGH-VOPS
 :LINKAGE-TABLE :OS-PROVIDES-DLOPEN :OS-PROVIDES-DLADDR :OS-PROVIDES-PUTWC
 :OS-PROVIDES-BLKSIZE-T :OS-PROVIDES-SUSECONDS-T :OS-PROVIDES-GETPROTOBY-R
 :OS-PROVIDES-POLL)

Revision history for this message
Svante v. Erichsen (serichsen) wrote :

Actually, an ftype declamation would probably just trigger the style warning earlier (at sbcl loading, not library loading time). I guess that setf of fdefinition should set the inferred ftype as well.

Revision history for this message
Svante v. Erichsen (serichsen) wrote :

One thing I have found is *setf-fdefinition-hook*. I have not yet found how one could copy the inferred ftype, but as a first fix, it might be sufficient to push a (lambda (function-name new-value) (declare (ignore new-value)) (clear-info :function :type function-name)) to *setf-fdefinition-hook*.

(Sorry for the ramblings; this is just my first peek into SBCL internals.)

Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

For whoever looks into this:

I finally realized how to make proclamations for generic functions enforceable.

Option 1: effective methods get the assertion code.

Option 2: generics with proclaimed types get an additional trampoline whose job is to enforce those proclamations.

Changed in sbcl:
importance: Undecided → Medium
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.