Coerce signals an error when the output is a not-finalized sequence class
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
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:
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:
((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:
(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-
:ASDF :ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB :SB-PACKAGE-LOCKS
:SB-UNICODE :SB-EVAL :SB-SOURCE-
:ELF :LINUX :SB-THREAD :LARGEFILE :GENCGC :STACK-
:C-STACK-
:UNWIND-
:STACK-
:STACK-
:CYCLE-COUNTER :COMPLEX-FLOAT-VOPS :FLOAT-EQL-VOPS :INLINE-CONSTANTS
:MEMORY-
:OS-PROVIDES-PUTWC :OS-PROVIDES-
:OS-PROVIDES-POLL)
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
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