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

inheritance of contradictory parametric type constraints #29848

Closed
WschW opened this issue Oct 30, 2018 · 2 comments
Closed

inheritance of contradictory parametric type constraints #29848

WschW opened this issue Oct 30, 2018 · 2 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@WschW
Copy link

WschW commented Oct 30, 2018

Abstract and concrete parametric types can inherit from other parametric types with contradictory type constraints for example:

julia> abstract type A{T<:Int} end

julia> abstract type B{T<:Array} <: A{T} end

julia> struct C{T} <: B{T}
                f::T
              end

None of these types can ever be used

julia> B{Array}
ERROR: TypeError: in A, in T, expected T<:Int64, got Type{Array}
Stacktrace:
 [1] top-level scope at none:0

julia> B{Int}
ERROR: TypeError: in B, in T, expected T<:Array, got Type{Int64}
Stacktrace:
 [1] top-level scope at none:0

julia> C(3)
ERROR: TypeError: in B, in T, expected T<:Array, got Type{Int64}
Stacktrace:
 [1] C(::Int64) at ./REPL[3]:2
 [2] top-level scope at none:0

julia> c([3])
ERROR: UndefVarError: c not defined
Stacktrace:
 [1] top-level scope at none:0

julia> versioninfo()
Julia Version 1.0.1
Commit 0d713926f8 (2018-09-29 19:05 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
@JeffBezanson
Copy link
Member

Mostly a duplicate of #9441. (#24179 also slightly related)

@JeffBezanson
Copy link
Member

Closing as duplicate of #9441.

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