-
-
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
multiple type aliases causing "$T (alias for $T)" (type alias that is not a type alias) #39492
Comments
I see that this has already been fixed! julia> VERSION
v"1.7.0-DEV.429"
julia> struct MyType{A, B} end
julia> const MyTypeA1{B} = MyType{1, B}
MyTypeA1{B} where B (alias for MyType{1, B} where B)
julia> const MyTypeB2{A} = MyType{A, 2}
MyTypeB2{A} where A (alias for MyType{A, 2} where A)
julia> MyType{3,4}
MyType{3, 4}
julia> MyType{1,4}
MyTypeA1{4} (alias for MyType{1, 4})
julia> MyType{3,2}
MyTypeB2{3} (alias for MyType{3, 2})
julia> MyType{1,2}
MyType{1, 2} though the "most specific" alias is not printed: julia> const MyTypeAInt64B2 = MyType{Int64, 2}
MyType{Int64, 2}
julia> Base.make_typealiases(MyType{Int64,2})[1]
2-element Vector{Core.SimpleVector}:
svec(:(Main.MyTypeAInt64B2), svec(), MyType{Int64, 2}, (1, 0))
svec(:(Main.MyTypeB2), svec(Int64), MyType{Int64, 2}, (1, -1)) And I still don't understand why I am perceiving different behavior for |
Fixed by #39366 |
Thanks for the reference and fix. In case you missed it, I proposed yet a different behavior, where the "most specific" alias is printed. |
The code to look at for that is |
A possible solution is to add an additional condition to check there aren't multiple aliases:
julia/base/show.jl
Line 794 in 11de85a
At least in this case, it would avoid printing the non-alias type alias.
curiosity:
I tried to trigger the analogous issue by defining
but
I am not sure why
MyType
andArray
behave differently here:To make the analogy even closer:
Finally, I think it would be nice to still print the alias, and to choose the "most specific" one:
in other words, currently
the solution I propose above:
the "most specific" alias:
notes to self:
difference between
make_typealiases
andmake_typealias
#36107 (comment)The text was updated successfully, but these errors were encountered: