Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in typeassert for type parameters #19041

Closed
dfdx opened this issue Oct 20, 2016 · 2 comments
Closed

Error in typeassert for type parameters #19041

dfdx opened this issue Oct 20, 2016 · 2 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@dfdx
Copy link
Contributor

dfdx commented Oct 20, 2016

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 to map(...) start working too)
  • adding type parameter to B in the last line, e.g. run_this(Foo(B{Int}))
@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label Oct 20, 2016
@JeffBezanson
Copy link
Member

closed by #18457 - but worth checking your original code to make sure it's fixed.

@dfdx
Copy link
Contributor Author

dfdx commented Jan 16, 2017

The original code currently has too many broken dependencies to run on 0.6, but I will make a note for myself to check it next time I come across it. Thanks and great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

2 participants