8000 Slots of custom slots are unbound on class redefinition · Issue #692 · armedbear/abcl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Slots of custom slots are unbound on class redefinition #692
Open
@lockie

Description

@lockie

Hey! I've stumbled upon a problem on defining custom slot initargs using metaclass and then redefining the class. Let me illustrate with an example:

(ql:quickload :closer-mop)

(defclass custom-slot (c2mop:standard-direct-slot-definition)
  ((custom-arg
    :accessor custom-arg
    :initarg :custom-arg
    :initform nil)))

(defclass custom-metaclass (c2mop:standard-class) ())

(defmethod c2mop:validate-superclass ((class custom-metaclass)
                                      (super c2mop:standard-class))
  t)

(defmethod c2mop:direct-slot-definition-class ((class custom-metaclass)
                                               &rest initargs)
  (declare (ignore class initargs))
  (find-class 'custom-slot))

(defmethod shared-initialize ((class custom-metaclass) slots &rest rest)
  (declare (ignorable rest))
  (unless (eq slots t)
    (dolist (slot (c2mop:class-direct-slots class))
      (format t "s-i custom-arg = ~a~%" (custom-arg slot))))
  (call-next-method))

(defclass my-class ()
  ((my-slot
    :accessor my-slot
    :initform 42
    :type fixnum
    :custom-arg 'bar))
  (:metaclass custom-metaclass))

(defclass my-class ()
  ((my-slot
    :accessor my-slot
    :initform 42
    :type fixnum
    :custom-arg 'buzz))
  (:metaclass custom-metaclass))

(print (my-slot (make-instance 'my-class)))

This example works correctly with SBCL, CCL, ECL, Allegro CL and CLISP, but fails in ABCL saying

#<THREAD "interpreter" native {2F6A2561}>: Debugger invoked on condition of type UNBOUND-SLOT
  The slot CUSTOM-ARG is unbound in the object #<CUSTOM-SLOT {27D76870}>.

(this happens when SHARED-INITIALIZE is called because of class redefinition).

Does my modest knowledge of MOP fail me, or is it a bug in ABCL?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0