Steel Bank Common Lisp

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

Reported by Jan Moringen on 2011-07-23
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

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
         sequence)
  ((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))
  nil)

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

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

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

*features*
(:ASDF-SYSTEM-CONNECTIONS :QUICKLISP :SB-BSD-SOCKETS-ADDRINFO :ASDF-UNIX :ASDF2
 :ASDF :ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS
 :SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS :IEEE-FLOATING-POINT :X86-64 :UNIX
 :ELF :LINUX :SB-THREAD :LARGEFILE :GENCGC :STACK-GROWS-DOWNWARD-NOT-UPWARD
 :C-STACK-IS-CONTROL-STACK :LINKAGE-TABLE :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 :COMPLEX-FLOAT-VOPS :FLOAT-EQL-VOPS :INLINE-CONSTANTS
 :MEMORY-BARRIER-VOPS :OS-PROVIDES-DLOPEN :OS-PROVIDES-DLADDR
 :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T :OS-PROVIDES-GETPROTOBY-R
 :OS-PROVIDES-POLL)

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
 done

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

Best,

Christophe

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