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

TypeConstructor errors confusing #7523

Closed
amckinlay opened this issue Jul 4, 2014 · 3 comments
Closed

TypeConstructor errors confusing #7523

amckinlay opened this issue Jul 4, 2014 · 3 comments

Comments

@amckinlay
Copy link
Contributor

julia> foo{T}(x::T) = None
foo (generic function with 1 method)

julia> foo{Int}
ERROR: type: instantiate_type: expected TypeConstructor, got Function

yet you can't seem to test whether a type is a type constructor

julia> type Foo{T}; x::T; end

julia> isa(Foo, TypeConstructor)
false

julia> Foo{Int}
Foo{Int64} (constructor with 2 methods)
@amckinlay
Copy link
Contributor Author

Also,

julia> type Foo{T}; x::T; end

julia> typealias Baz{T} Foo{T}
Foo{T}

julia> typeof(Baz)
TypeConstructor

julia> typeof(Foo)
DataType

julia> Baz == Foo
true

julia> methods(Baz)
ERROR: no method methods(Type{Foo{T}})

julia> methods(Foo)
# 1 method for generic function "Foo":
Foo{T}(x::T)

julia> typealias Bar Foo{Int}
Foo{Int64} (constructor with 2 methods)

julia> typeof(Bar)
DataType

julia> methods(Bar)
# 2 methods for generic function "Foo":
Foo(x::Int64)
Foo(x)
  1. Why does the type of a parametric type alias singleton not match the type of the parametric type singleton it represents, yet == says they're the same?
  2. Why do you lose access to the parametric constructors when referencing a parametric type through a parametric type alias? You don't lose constructors when the type alias represents a concrete type.

@JeffBezanson
Copy link
Member

These issues and more are to be resolved in the future. Until then I advise stepping back and looking at the bigger picture.

@JeffBezanson
Copy link
Member

See existing issues such as #2552, #6721

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants