Skip to content

typealias bug ?  #6721

Closed
Closed
@Jutho

Description

Since this did not get answered on the user forum, I expect nobody knows and this is a potential bug.
Starting with the following definitions

abstract Vartype
type VT1<:Vartype
end

abstract Graph{T<:Vartype}
abstract Subgraph{T<:Vartype} <: Graph{T}
type Vertex{T<:Vartype} <: Subgraph{T}
end
type Block{T<:Vartype,N} <: Subgraph{T}
end

abstract GraphObject{T<:Vartype}
type SubgraphObject{T<:Vartype,S<:Subgraph{T}} <: GraphObject{T}
end

typealias VertexObject{T<:Vartype} SubgraphObject{T,Vertex{T}}
typealias BlockObject{T<:Vartype,N} SubgraphObject{T,Block{T,N}}
typealias VertexBlockObject{T<:Vartype} Union(VertexObject{T},BlockObject{T})

O1=SubgraphObject{VT1,Vertex{VT1}}()
O2=SubgraphObject{VT1,Block{VT1,3}}()

I did expect all of the following to be true, but nevertheless got the results in the comment

isa(O1,VertexObject) # false
isa(O1,VertexObject{VT1}) # true
isa(O1,VertexBlockObject) # false
isa(O1,VertexBlockObject{VT1}) # true

isa(O2,BlockObject) # false
isa(O2,BlockObject{VT1}) # false
isa(O2,BlockObject{VT1,3}) # true
isa(O2,VertexBlockObject) # false
isa(O2,VertexBlockObject{VT1}) # false

I don't see how this is different to isa(randn(3,3),StridedMatOrVec), which returns true with or without full specification of the argument.

Is this a bug or expected behaviour?

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviortypes and dispatchTypes, subtyping and method dispatch

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions