Exception when applying vec on the empty list

5 views
Skip to first unread message

FabienT

unread,
Aug 6, 2008, 2:51:07 AM8/6/08
to Clojure
As of version 986, below the trace of the REPL interaction :

user=> ( vec ( list ) )
java.lang.Exception: Unable to convert: class
clojure.lang.PersistentList$EmptyList to Object[]
java.lang.Exception: Unable to convert: class
clojure.lang.PersistentList$EmptyList to Object[]
at clojure.lang.RT.toArray(RT.java:1023)
at clojure.to_array__61.invoke(boot.clj:221)
at clojure.vec__68.invoke(boot.clj:232)
at user.eval__2117.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:3847)
at clojure.lang.Repl.main(Repl.java:75)

No problem on empty sets and maps though :

user=> ( vec #{ } )
[]
user=> ( vec { } )
[]

FabienT

unread,
Aug 6, 2008, 6:31:14 AM8/6/08
to Clojure
Below the trace of the interaction with the Repl version 986.

user=> ( vec ( list ) )
java.lang.Exception: Unable to convert: class
clojure.lang.PersistentList$EmptyList to Object[]
java.lang.Exception: Unable to convert: class
clojure.lang.PersistentList$EmptyList to Object[]
at clojure.lang.RT.toArray(RT.java:1023)
at clojure.to_array__61.invoke(boot.clj:221)
at clojure.vec__68.invoke(boot.clj:232)
at user.eval__2114.invoke(Unknown Source)

Rich Hickey

unread,
Aug 6, 2008, 10:22:43 AM8/6/08
to Clojure


On Aug 6, 2:51 am, FabienT <f...@infologic.fr> wrote:
> As of version 986, below the trace of the REPL interaction :
>
> user=> ( vec ( list ) )
> java.lang.Exception: Unable to convert: class
> clojure.lang.PersistentList$EmptyList to Object[]
> java.lang.Exception: Unable to convert: class
> clojure.lang.PersistentList$EmptyList to Object[]

> No problem on empty sets and maps though :
>
> user=> ( vec #{ } )
> []
> user=> ( vec { } )
> []

I've made empty lists implement java.util.Collection, which fixes this
and other issues related to them no longer being sequences.

Thanks for the report

Rich
Reply all
Reply to author
Forward
0 new messages