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
x/tools/gopls: incorrect placeholders for aliased types #33500
Comments
Thanks for filing this issue! This is lower priority for us, so while I will try to fix this when I get a chance, if anyone else is interested in contributing a fix for this, please go ahead! |
Hi @stamblerre , I'm interested to look into this issue. I think the problem is related to types.TypeString() function in this line completion_format.go Am I in the right direction? Thanks. |
@wangfenjin: The placeholders for a function are actually determined in the |
Hi @stamblerre , After some investment, I find it's a placeholder for struct field which determined by structFieldSnippet, which in turn relies on types.TypeString(). I think I should fix this in golang/go package. |
Hi @stamblerre , Seems it's intended to return the underlining type for alias, please refer to types/decl.go. I verified this issue will be fixed by changing the Do you have any suggestions? |
Ah I see, thanks for investigating this. Looks like there's no way for us to to get back the alias information from the |
Change https://golang.org/cl/201677 mentions this issue: |
Change https://golang.org/cl/208497 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
I declared a function type struct field. The function has a parameter and return value with a type that is an exported alias of a type in an internal package my code doesn't have access to. For example:
I then declare type literals for
mockAppender
in VSCode with thegopls.usePlaceholders
option enabled.What did you expect to see?
When I type a struct literal for the above type and add the
appendMessages
field, I expect the generated placeholder to reference types my code has access to, specifically:What did you see instead?
A placeholder that referenced types from a package my code cannot import that is type that
ipv4.Message
aliases. Specifically:The text was updated successfully, but these errors were encountered: