Coerce signals an error when the output is a not-finalized sequence class

Bug #815155 reported by Jan Moringen on 2011-07-23
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Since SBCL implements user-extensible sequences, user-defined sequence classes can be used as output type of `coerce'. In this case `sb-mop:class-prototype' is used to obtain an instance that can be passed to `sequence:make-sequence-like'. However, `sb-mop:class-prototype' signals an error if the class in question is not finalized.

To reproduce, define a sequence class, for example like this:

(cl:defpackage :coerce-problem
  (:use :cl))
(cl:in-package :coerce-problem)

(defclass my-sequence (standard-object
  ((length :initarg :length)))

(defmethod sequence:make-sequence-like
    ((sequence my-sequence) (length integer)
     &rest args
     &key &allow-other-keys)
  (declare (ignore args))
  (make-instance 'my-sequence :length length))

;; Not relevant when reproducing the error, but required to make
;; MY-SEQUENCE a minimal sequence:

(defmethod sequence:length ((sequence my-sequence))
  (slot-value sequence 'length))

(defmethod sequence:elt ((sequence my-sequence)
    (index integer))

(defmethod (setf sequence:elt) ((new-value t)
    (sequence my-sequence)
    (index integer))

(defmethod sequence:adjust-sequence ((sequence my-sequence)
         (length integer)
         &rest args
         &key &allow-other-keys)
  (declare (ignore args))
  (setf (slot-value sequence 'length) length)

Then try

(coerce '(1 2 3) 'my-sequence)

What happens: an error is signaled.
Expected: an instance of `my-sequence' is returned (After finalizing the class, this happens)

sbcl --version
SBCL 1.0.48

uname -a
Linux azurit 2.6.35-30-generic #53-Ubuntu SMP Sun Jun 5 04:00:23 UTC 2011 x86_64 GNU/Linux


Jan Moringen (scymtym) wrote :

Jan Moringen <email address hidden> writes:

> However, `sb-mop:class-prototype' signals an error if the class in
> question is not finalized.

 status fixcommitted
 importance low
 tag coerce sequences

Thank you for the report; I've pushed a fix to sourceforge git.



Changed in sbcl:
importance: Undecided → Low
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers