Ugly style-warning from defmethod close

Bug #839937 reported by Svante v. Erichsen on 2011-09-02
This bug affects 1 person
Affects Status Importance Assigned to Milestone

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)
CL-USER> (defmethod close ((stream my-stream) &key abort)
           (close stream :abort abort))
   Generic function CLOSE clobbers an earlier FTYPE proclamation
   the same name with (FUNCTION (T &KEY (:ABORT T)) *).

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


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.

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.)

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  Edit
Everyone can see this information.

Other bug subscribers