wrong default value for ensure-generic-function's :generic-function-class argument

Bug #309074 reported by Nikodemus Siivola
2
Affects Status Importance Assigned to Milestone
SBCL
Confirmed
Low
Unassigned

Bug Description

    (reported by Bruno Haible)
  ANSI CL is silent on this, but the MOP's specification of ENSURE-GENERIC-FUNCTION says:
   "The remaining arguments are the complete set of keyword arguments
    received by ENSURE-GENERIC-FUNCTION."
  and the spec of ENSURE-GENERIC-FUNCTION-USING-CLASS:
   ":GENERIC-FUNCTION-CLASS - a class metaobject or a class name. If it is not
    supplied, it defaults to the class named STANDARD-GENERIC-FUNCTION."
  This is not the case in SBCL. Test case:
   (defclass my-generic-function (standard-generic-function)
     ()
     (:metaclass sb-pcl:funcallable-standard-class))
   (setf (fdefinition 'foo1)
         (make-instance 'my-generic-function :name 'foo1))
   (ensure-generic-function 'foo1
     :generic-function-class (find-class 'standard-generic-function))
   (class-of #'foo1)
   ; => #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
   (setf (fdefinition 'foo2)
         (make-instance 'my-generic-function :name 'foo2))
   (ensure-generic-function 'foo2)
   (class-of #'foo2)
  Expected: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
  Got: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS MY-GENERIC-FUNCTION>

As of 1.0.23 this test case behaves a bit differently, getting instead
  Cannot CHANGE-CLASS objects into GENERIC-FUNCTION metaobjects.
     [Condition of type SB-PCL::METAOBJECT-INITIALIZATION-VIOLATION]
  See also:
    The Art of the Metaobject Protocol, GENERIC-FUNCTION [:initialization]
on both ENSURE-GENERIC-FUNCTION calls. Need to figure out if this is righ, and if it is, if it
is possible to still provoke the original problem.

provoke a sim

Tags: pcl
description: updated
Changed in sbcl:
importance: Undecided → Low
status: New → Confirmed
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.