x/tools/gopls: understand that defined integer types may be slice indexes when suggesting completions #43375
Labels
FeatureRequest
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
help wanted
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, and with the current tip of gopls as well.
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
I used a variable of a defined integer type to index into a slice. Specifically, I tried to use autocompletion to fill in the variable in the index expression.
Here's some example code in a single-file package:
The
|
is where my cursor was when I invoked autocompletion.What did you expect to see?
I expected to see
nnn
andmmm
equally suggested as possible completions.If I selected
nnn
from the list, the completed code should beWhat did you see instead?
nnn
is ranked much lower thanmmm
-- it comes after some irrelevant entries from other packages (I filed #43374 for that).If I nevertheless scroll down to
nnn
and select it,nnn
is wrapped in an unnecessaryint
conversion:I noticed this in my usual environment of vim + govim but I can reproduce this with vscode as well. Here are some screenshots.
The text was updated successfully, but these errors were encountered: