Closed
Description
The following code:
type Foo{K}
end
Foo(K::Type) = Foo{K}()
immutable B{T}
p::T
end
function run_this{K}(foo::Foo{K})
# deepcopy(foo)
result = map(i -> deepcopy(foo), 1:2)
end
run_this(Foo(B))
gives an error:
ERROR: TypeError: _collect: in typeassert, expected Foo{B}, got Foo{B}
in _collect(::UnitRange{Int64}, ::Base.Generator{UnitRange{Int64},##1#2{Foo{B}}}, ::Base.EltypeUnknown, ::Base.HasShape) at ./array.jl:379
in run_this(::Foo{B}) at ./REPL[4]:3
Reproducible on Julia 0.5.0 as well as today's nightly build, though not on Julia 0.4.7.
Any of the following actions remove the error:
- unwrapping code from a function
- uncommenting line
deepcopy(foo)
(all further calls tomap(...)
start working too) - adding type parameter to
B
in the last line, e.g.run_this(Foo(B{Int}))
Activity