-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Wrong type-parameter bounds inside a type alias #56691
Comments
reproduced on master. |
Those look correct to me. You only have one UnionAll variable, so it should only accept one application, though if that application is a UnionAll variable, then the result can accept another one again |
isn't the TypeError a problem? |
How is it acceptable that a more specialized version of
Moreover,
|
Julia does not enforce type constraints applied to type aliases when making new type aliases from them |
More problematic examples: julia> const TypeofMyT{T, C<:Vector{T}} = Type{C}
Type{C} where {T, C<:Vector{T}}
julia> TypeofMyT{Integer, <:Vector{<:Real}}
Type{<:Vector{<:Real}} which should have been julia> Vector{Integer} <: Vector{<:Real}
true
julia> Vector{<:Real} <: Vector{Integer}
false
julia> TypeofMyT{Integer, <:Vector{<:Real}} <: TypeofMyT
false julia> const MyT{T, C<:Vector{T}} = C
Vector (alias for Array{T, 1} where T) It is already concerning that the compiler automatically converts julia> MyT{<:Any, Vector{Float64}}
ERROR: too many parameters for type Array Just because there's a reason for such behavior does not automatically justify it. If you allow the user to rename a type legally with additional type parameters, you should support full feature and consistent type inference for all of these parameters or forbid such construction altogether. Calling this behavior "correct," IMHO, does not seem a convincing solution. |
What about this?
The type constraints seem to propagate properly in this scenario, no? |
MWE (tested on Julia 1.11.1):
The text was updated successfully, but these errors were encountered: