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

x/tools/gopls: no type inference for builtin args in composite literals #43240

Closed
muirdm opened this issue Dec 17, 2020 · 2 comments
Closed

x/tools/gopls: no type inference for builtin args in composite literals #43240

muirdm opened this issue Dec 17, 2020 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@muirdm
Copy link

muirdm commented Dec 17, 2020

We aren't giving proper completions in this case:

var foo []int
struct { i []int }{
  i: append(nil, <>), // want "foo..."
}

I presume the composite literal is messing up the "append" param type inference.

Note that we also don't infer the type in this case:

var foo []int
append([]int{}, <>) // want "foo..."

In the first example we need to infer based on the struct field type, and in the second example we need to infer based on the first "append" param type.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 17, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 17, 2020
@muirdm
Copy link
Author

muirdm commented May 4, 2021

The first example is not valid because you can't pass untyped nil to append().

@gopherbot
Copy link

Change https://golang.org/cl/316849 mentions this issue: lsp/completion: improve append() param type inference

@golang golang locked and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants