'cl:string is too hairy for sequence functions' error in no hairy situations.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
New
|
Undecided
|
Unassigned |
Bug Description
* What I do and what happens:
(deftype my-string-type (&rest args)
`(cl:string ,@args))
(concatenate 'my-string-type "foo" "bar")
;=> "foobar"
(concatenate '(my-string-type 6) "foo" "bar")
;=> "foobar"
(setf (find-class 'my-string-type)
(find-class 'cl:string))
; warning: redefining DEFTYPE type to be a class: cl-user:
(make-sequence 'my-string-type 3 :initial-element #\.)
;error :string is too hairy for sequence functions.
(concatenate 'my-string-type "foo" "bar")
;error :string is too hairy for sequence functions.
(concatenate '(my-string-type 6) "foo" "bar")
;error :string is too hairy for sequence functions.
* What I expected to happen:
;; after (setf (find-class 'my-string-type) ..)
(concatenate 'my-string-class "foo" "bar")
;=> "foobar"
(concatenate '(my-string-class 6) "foo" "bar")
;=> "foobar"
* Analysis:
CL:MAKE-SEQUENCE adjusted-type'ed type-specifier with SB-EXT:TYPEXPAND, but it should be expanded recursively with SB-EXT:
((eq expanded-type 'string) '(vector character))
==>
((eq (typexpand-all expanded-type) 'string) '(vector character))
etc.
Environment:
SBCL 1.2.12
uname -a:
Linux t 4.1.0-rc6-t #1 SMP PREEMPT Wed Jun 3 06:48:43 JST 2015 x86_64 GNU/Linux
*features*:
(:sbcl-
:has-vt :has-bell :has-escape :has-linefeed :has-return :has-backspace
:has-tab :has-page :has-rubout :declare-types :esrap.
:esrap.
:esrap.
:arc-compat :asdf-system-
:named-readtables :hunchentoot :sbcl-debug-
:bordeaux-threads cffi-features:
cffi-features:unix :cffi cffi-sys:
:chunga :split-sequence :closer-mop :thread-support chipz-system:
:swank :quicklisp :sb-bsd-
:asdf3 :asdf2 :asdf :os-unix :non-base-
:alien-callbacks :ansi-cl :ash-right-vops :c-stack-
:common-lisp :compare-
:float-eql-vops :gencgc :ieee-floating-
:integer-eql-vop :interleaved-
:little-endian :memory-
:os-provides-
:os-provides-poll :os-provides-putwc :os-provides-
:package-
:sb-after-xc-core :sb-core-
:sb-package-locks :sb-simd-pack :sb-source-
:sb-unicode :sb-xref-
:stack-
:stack-
:unix :unwind-
description: | updated |
Well, a few things:
You're already getting into undefined behavior territory as indicated by the warning - MY-STRING can not be both a DEFTYPE and a pseudonym for the class named STRING. It's possibly a defect in the system internals that the FIND-CLASS operation didn't totally eradicate the DEFTYPE; or not - nothing is really spelled out here. Either that, or the FIND-CLASS should *not* do what it's doing, which is trying to copy the "system internal" translation of a build-in-class.
The reason this kind of works on other Lisps and not on SBCL is that SBCL has an extensible sequence protocol, so after the FIND-CLASS, it really wants MY-STRING to be using the extended sequence protocol, and not just a random class.
Additionally I also suspect that things are not generally expected to work with (SETF (FIND-CLASS SYM) NEW) where NEW is _any_ built-in-class whatsoever, STRING just being one example.