julia lang - TypeError typeassert for custom typealias -


i fail understand following behaviour

a = [1,2,3] a::vector  # works  d = dict(0=>a) typealias dictvector{k,v} dict{k, vector{v}} d::dictvector  # fails 

the error following

typeerror: typeassert: expected dict{k,array{v,1}}, got   dict{int64,array{int64,1}}   in include_string(::string, ::string) @ loading.jl:441   in eval(::module, ::any) @ boot.jl:234   in (::atom.##65#68)() @ eval.jl:40   in withpath(::atom.##65#68, ::void) @ utils.jl:30   in withpath(::function, ::void) @ eval.jl:46   in macro expansion @ eval.jl:109 [inlined]   in (::atom.##64#67{dict{string,any}})() @ task.jl:60 

however vector typealias vector{t} array{t,1} decisive difference between 2 cases?

any clarification highly appriciated

you're right should work. looks bug in old type system in 0.5. it's fixed in upcoming 0.6 release.

here's possible workaround 0.5:

julia> typealias dictvector{k,v<:vector} dict{k,v} dict{k,v<:array{t,1}}  julia> d::dictvector dict{int64,array{int64,1}} 1 entry:   0 => [1,2,3]  julia> isa(d, dictvector) true 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -