'cl:string is too hairy for sequence functions' error in no hairy situations.

Bug #1467305 reported by CHIBA Masaomi
6
This bug affects 1 person
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::my-string-type

(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::TYPEXPAND-ALL etc.

((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-uses-sb-rotate-byte :generic-sequences :cl-unicode :newline-is-linefeed
 :has-vt :has-bell :has-escape :has-linefeed :has-return :has-backspace
 :has-tab :has-page :has-rubout :declare-types :esrap.can-handle-left-recursion
 :esrap.multiple-transforms :esrap.function-terminals
 :esrap.expression-start-terminals mopp::have-mop :cl-json-clos :cl-json
 :arc-compat :asdf-system-connections :5am :kmr-mop :rune-is-character
 :named-readtables :hunchentoot :sbcl-debug-print-variable-alist :cl-fad
 :bordeaux-threads cffi-features:flat-namespace cffi-features:x86-64
 cffi-features:unix :cffi cffi-sys::flat-namespace :cl-ppcre :flexi-streams
 :chunga :split-sequence :closer-mop :thread-support chipz-system:gray-streams
 :swank :quicklisp :sb-bsd-sockets-addrinfo :asdf-package-system :asdf3.1
 :asdf3 :asdf2 :asdf :os-unix :non-base-chars-exist-p :asdf-unicode
 :alien-callbacks :ansi-cl :ash-right-vops :c-stack-is-control-stack
 :common-lisp :compare-and-swap-vops :complex-float-vops :cycle-counter :elf
 :float-eql-vops :gencgc :ieee-floating-point :inline-constants
 :integer-eql-vop :interleaved-raw-slots :largefile :linkage-table :linux
 :little-endian :memory-barrier-vops :multiply-high-vops :os-provides-blksize-t
 :os-provides-dladdr :os-provides-dlopen :os-provides-getprotoby-r
 :os-provides-poll :os-provides-putwc :os-provides-suseconds-t
 :package-local-nicknames :precise-arg-count-error :raw-instance-init-vops
 :sb-after-xc-core :sb-core-compression :sb-doc :sb-eval :sb-futex :sb-ldb
 :sb-package-locks :sb-simd-pack :sb-source-locations :sb-test :sb-thread
 :sb-unicode :sb-xref-for-internals :sbcl :stack-allocatable-closures
 :stack-allocatable-fixed-objects :stack-allocatable-lists
 :stack-allocatable-vectors :stack-grows-downward-not-upward :symbol-info-vops
 :unix :unwind-to-frame-and-call-vop :x86-64)

description: updated
Revision history for this message
Douglas Katzman (dougk) wrote :

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.