Clojure

transient blows up when passed a vector created by subvec

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Backlog
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
    None
  • Approval:
    Vetted

Description

Subvectors created with subvec from a PersistentVector cannot be made transient:

user=> (transient (subvec [1 2 3 4] 2))
ClassCastException clojure.lang.APersistentVector$SubVector cannot be cast to clojure.lang.IEditableCollection  clojure.core/transient (core.clj:2864)

Activity

Hide
Stuart Sierra added a comment -

Confirmed. APersistentVector$SubVector does not implement IEditableCollection.

The current implementation of TransientVector depends on implementation details of PersistentVector, so it is not a trivial fix. The simplest fix might be to implement IEditableCollection.asTransient in SubVector by creating a new PersistentVector, but I do not know the performance implications.

Show
Stuart Sierra added a comment - Confirmed. APersistentVector$SubVector does not implement IEditableCollection. The current implementation of TransientVector depends on implementation details of PersistentVector, so it is not a trivial fix. The simplest fix might be to implement IEditableCollection.asTransient in SubVector by creating a new PersistentVector, but I do not know the performance implications.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated: