Description
gopls version: v0.12.4 (go1.20.3)
gopls flags:
update flags: proxy
extension version: 0.39.1
go version: 1.20.3
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Thu, 27 Jul 2023 03:27:43 GMT
restart history:
Tue, 25 Jul 2023 20:01:41 GMT: activation (enabled: true)
Tue, 25 Jul 2023 20:08:52 GMT: config change (enabled: true)
Tue, 25 Jul 2023 20:09:30 GMT: config change (enabled: true)
Tue, 25 Jul 2023 20:09:41 GMT: config change (enabled: true)
Tue, 25 Jul 2023 20:11:07 GMT: config change (enabled: true)
This is a followup or additional issue related to #61614 using the same minimal example I am unable to find references (cmd/ctrl+click in VSCode and other editors) for the generic fields.
What did you do?
If I cmd+click on a usage of the field, like 'element', then it correctly takes to the definition, but if I then cmd+click on the definition of the field, it does not show it's references. Instead it shows the message "No type definition found for 'elements'", (which is correct I guess) since I have that configured as the fallback action in vscode. For non generic fields, like 'name', it shows the other references as expected.
type builder[S ~[]F, F ~string] struct {
name string // <-- cmd+click here correctly shows references
elements S // <-- [Definition] - cmd+click here does not show references and runs alternate gotoLocation command
elemData map[F][]ElemData[F]
// other fields...
}
type ElemData struct {
Name F
// other fields...
}
type BuilderImpl[S ~[]F, F ~string] struct{ builder[S, F] }
func NewBuilderImpl[S ~[]F, F ~string](name string) *BuilderImpl[S, F] {
return &BuilderImpl[S,F]{
builder[S, F]{
name: name,
elements: S{}, // <-- [Usage] - cmd+click here takes me to [Definition]
elemData: map[F][]ElemData[F]{},
}
}
}
Editor and settings
"editor.gotoLocation.alternativeReferenceCommand": "editor.action.goToTypeDefinition"
"editor.gotoLocation.alternativeImplementationCommand": "editor.action.revealDefinition",
"editor.gotoLocation.alternativeTypeDefinitionCommand": "editor.action.goToImplementation",
"editor.gotoLocation.alternativeDefinitionCommand": "editor.action.goToReferences",
"editor.gotoLocation.alternativeDeclarationCommand": "editor.action.referenceSearch.trigger",
"editor.gotoLocation.multipleTypeDefinitions": "peek",
"editor.gotoLocation.multipleReferences": "peek",
"editor.gotoLocation.multipleDefinitions": "peek",
"editor.gotoLocation.multipleDeclarations": "peek",
"editor.gotoLocation.multipleImplementations": "peek",
// gopls settings, but nothing relevant to this issue
"gopls": {
"ui.semanticTokens": true,
"ui.noSemanticString": false,
"ui.completion.usePlaceholders": false,
"ui.diagnostic.analyses": {
"infertypeargs": false
},
"ui.documentation.linksInHover": false,
"ui.navigation.importShortcut": "Definition"
},
Logs
This is the only relevant log message I'm getting
[Error - 3:02:13 PM] Request textDocument/typeDefinition failed.
Message: no type definition for elements
Code: 0
Activity
hyangah commentedon Jul 27, 2023
I could still reproduce this with
gopls@v0.13.0-pre.3
(go1.21rc3
)findleyr commentedon Jul 28, 2023
Thanks. This used to work in v0.11.0, I think. It looks like the new references logic dropped the 'equalOrigin' logic, unfortunately.
[-]x/tools/gopls: unable to find references for stuct fields that use type param composite lits[/-][+]x/tools/gopls: unable to find references for struct fields that use type param composite lits[/+]gopherbot commentedon Jul 28, 2023
Change https://go.dev/cl/513780 mentions this issue:
gopls/internal/lsp/source: reinstance equalOrigin for references check
5 remaining items