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: downrank slice as second "append()" param #40535

Closed
muirdm opened this issue Aug 2, 2020 · 1 comment
Closed

x/tools/gopls: downrank slice as second "append()" param #40535

muirdm opened this issue Aug 2, 2020 · 1 comment
Labels
FeatureRequest 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 Aug 2, 2020

type foo struct { i int }
var bar []foo
bar = append(bar, <>)

Currently in the above example gopls prefers "bar" at "<>", but it's rare that you append a slice to itself. I think we should adjust scoring so that the literal candidate "foo{}" is ranked above "bar".

We could add a special case to downrank the first append param as the second append param, but I'm not sure the best way to do it. If we just check types.Object equality, we will incorrectly dowrank in the following case:

type foo struct { i []int }
var a, b foo
a.i = append(a.i, <>)

At "<>" we would downrank "b.i" in addition to "a.i". To avoid this we would need to use objectpath or AST/text equality check.

@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 Aug 2, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 2, 2020
@stamblerre stamblerre removed this from the Unreleased milestone Aug 4, 2020
@gopherbot
Copy link

Change https://golang.org/cl/247519 mentions this issue: internal/lsp/source: improve completion in append()

@stamblerre stamblerre added this to the gopls/v.0.5.0 milestone Aug 15, 2020
@golang golang locked and limited conversation to collaborators Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest 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