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

Should error on ignored type parameter in left-hand side of type alias #38715

Closed
goretkin opened this issue Dec 5, 2020 · 5 comments
Closed

Comments

@goretkin
Copy link
Contributor

goretkin commented Dec 5, 2020

  | | |_| | | | (_| |  |  Version 1.6.0-DEV.1653 (2020-12-04)
 _/ |\__'_|_|_|\__'_|  |  Commit 0db72ee7d2* (1 day old master)
|__/                   |

julia> MyType{K, T} = Set{T}
Set

Not mentioned in https://docs.julialang.org/en/v1/manual/types/#UnionAll-Types

Sorry in advance if this is a duplicate issue.

@Seelengrab
Copy link
Contributor

Seelengrab commented Dec 5, 2020

Since they're equivalent, superfluos type parameters are no longer printed on 1.6. Makes types in errors and stacktraces much more compact. I think the relevant PR was #36107.

julia> Set === Set{T} where T
true

@vtjnash
Copy link
Member

vtjnash commented Dec 5, 2020

The LHS is syntax for

julia> MyType = Set{T} where {K, T}
Set

And the unused K gets dropped, so you end up with MyType === Set

@vtjnash vtjnash closed this as completed Dec 5, 2020
@goretkin
Copy link
Contributor Author

goretkin commented Dec 5, 2020

@Seelengrab I think you misunderstood my concern

@vtjnash Thanks for the explanation. I'm not readily finding another conversation about unused type parameters, and that seems to be the reason underlying the non-error on what I want to error. As a side note, I wish you would not close the issues so quickly. Perhaps we want to improve the documentation. Or we want to acknowledge there may be something going on, but still won't fix it, in which case we definitely want to document it. In any case, I know a closed issue doesn't mean there can't be a discussion, so:

Currently, MyType = Set{T} where {K, T} and MyType{K, T} = Set{T} lower slightly differently. Using a simpler example:

julia> Meta.@lower MyType{K} = Int64
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─      const MyType
│        K = Core.TypeVar(:K)
│   %3 = Core.UnionAll(K, Int64)
│        MyType = %3
└──      return %3
))))

julia> Meta.@lower MyType = Int64 where {K}
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─      K = Core.TypeVar(:K)
│   %2 = Core.UnionAll(K, Int64)
│        MyType = %2
└──      return %2
))))

so even if Int64 where {K} does not error, that doesn't seem to force MyType{K} = Int64 to not error as well.

@vtjnash
Copy link
Member

vtjnash commented Dec 5, 2020

Closing issues helps others focus on other work. It's an aspect of triage and email management. We almost never lock them, since continued discussion and PR are welcome.

Yes, more precisely, there's a const decl also, but that didn't seem relevant to your question. To which, what is your question?

@goretkin goretkin changed the title Error on ignored type parameter in left-hand side of type alias Should error on ignored type parameter in left-hand side of type alias Dec 5, 2020
@goretkin
Copy link
Contributor Author

goretkin commented Dec 5, 2020

The question is: Can we raise an error on MyType{K, T} = Set{T}?

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

3 participants