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: infertypeargs no longer produces diagnostics #63821

Carsten-Leue opened this issue Oct 28, 2023 · 2 comments

x/tools/gopls: infertypeargs no longer produces diagnostics #63821

Carsten-Leue opened this issue Oct 28, 2023 · 2 comments
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.


Copy link

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.21.3 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Build info v0.14.0 h1:SaFctK7aL3S21p7r/K4+XU+mEyjobk7rIe9B+KiER5s= h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y= h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= h1:1baVNneD/IRxmu8JQdBuki78zUqBtZxq8smZXQj0X2Y= h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= h1:885/39rn2IDn/hUUfUzxMWAowSMB/K+bc3kaOJfc5bo= h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= h1:YGD4H+SuIOOqsyoLOpZDWcieM28W47/zRO7f+9V3nvo= h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM= h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.21.3

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.83.1
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.39.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    • Checking configured tools....
      GOBIN: undefined
      gopath: C:\Users\CarstenLeue\go
      GOROOT: c:\Program Files\Go
      PATH: C:\Program Files\ImageMagick-7.1.1-Q16-HDRI;c:\Program Files\Eclipse Adoptium\jre-\bin;C:\Python312\Scripts;C:\Python312;;;;c:\Program Files\Eclipse Adoptium\jre-\bin;C:\Python311\Scripts;C:\Python311;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;c:\Program Files\Eclipse Adoptium\jre-\bin;c:\Program Files\Eclipse Adoptium\jre-\bin;c:\Program Files\Eclipse Adoptium\jre-\bin;C:\Python310\Scripts;C:\Python310;C:\Program Files\Yubico\Yubico PIV Tool\bin;c:\Program Files\Eclipse Adoptium\jre-\bin;C:\Python37\Scripts;C:\Python37;C:\Python36\Scripts;C:\Python36;C:\Python38\Scripts;C:\Python38;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0;C:\windows\System32\OpenSSH;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\nodejs;C:\Program Files (x86)\OpenSSL\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files (x86)\Intel\WiFi\bin;C:\Program Files (x86)\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\Git LFS;C:\Program Files (x86)\gnuplot\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\OpenJDK\jdk-17.0.1\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\nodejs;C:\Program Files (x86)\Go\bin;C:\Program Files\gnuplot\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git LFS;C:\Program Files\dotnet;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\gnupg\bin;C:\Program Files\OpenSSH-Win64;C:\Program Files\gs\gs9.56.1\bin;C:\tools\groovy-3.0.14\bin;c:\Program Files (x86)\Yarn\bin;C:\tools\groovy-3.0.14\bin;C:\Program Files\gs\gs10.00.0\bin;C:\Program Files\OpenSSL\bin;C:\Program Files (x86)\Gpg4win..\GnuPG\bin;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.9.5\bin;c:\Program Files\Go\bin;c:\Program Files\PowerShell\7;C:\Program Files\GitHub CLI;C:\Program Files\OpenJDK\jdk-21.0.1\bin;C:\Program Files\nodejs;C:\Users\CarstenLeue.cargo\bin;C:\Users\CarstenLeue.cargo\bin;C:\Users\CarstenLeue\AppData\Local\Microsoft\WindowsApps;C:\ProgramData\chocolatey\lib\msys2;C:\tools\msys64;C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\CarstenLeue\Documents\vcpkg;C:\Users\CarstenLeue\AppData\Local\Programs\Fiddler;C:\Users\CarstenLeue\AppData\Local\GitHubDesktop\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\IBM\Cloud\bin;C:\Users\CarstenLeue\AppData\Local\Yarn\bin;C:\Users\CarstenLeue\AppData\Local\Box\Box Edit;C:\Users\CarstenLeue\AppData\Roaming\npm;C:\Program Files\Git\cmd;c:\Program Files\IBM\Cloud\bin;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\OpenSSL-Win64\bin;C:\Program Files\Tesseract-OCR;C:\Users\CarstenLeue\AppData\Local\Yarn\bin;C:\Users\CarstenLeue.local\bin;C:\Users\CarstenLeue\AppData\Local\Programs\Microsoft VS Code\bin;C:\ghcup\bin;c:\Users\CarstenLeue\AppData\Local\Box\Box Edit;C:\Users\CarstenLeue\go\bin;C:\Users\CarstenLeue\AppData\Roaming\npm

    go: c:\Program Files\Go\bin\go.exe: go version go1.21.3 windows/amd64

    gotests: C:\Users\CarstenLeue\go\bin\gotests.exe (version: v1.6.0 built with go: go1.21.0)
    gomodifytags: C:\Users\CarstenLeue\go\bin\gomodifytags.exe (version: v1.16.0 built with go: go1.21.0)
    impl: C:\Users\CarstenLeue\go\bin\impl.exe (version: v1.2.0 built with go: go1.21.0)
    goplay: C:\Users\CarstenLeue\go\bin\goplay.exe (version: v1.0.0 built with go: go1.21.0)
    dlv: C:\Users\CarstenLeue\go\bin\dlv.exe (version: v1.21.1 built with go: go1.21.3)
    staticcheck: C:\Users\CarstenLeue\go\bin\staticcheck.exe (version: v0.4.6 built with go: go1.21.3)
    gopls: C:\Users\CarstenLeue\go\bin\gopls.exe (version: v0.14.0 built with go: go1.21.3)

go env
Workspace Folder (go-test-generics): c:\Users\CarstenLeue\Documents\go-test-generics
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\CarstenLeue\AppData\Local\go-build
set GOENV=C:\Users\CarstenLeue\AppData\Roaming\go\env
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOMODCACHE=C:\Users\CarstenLeue\go\pkg\mod
set GOOS=windows
set GOPATH=C:\Users\CarstenLeue\go
set GOROOT=c:\Program Files\Go
set GOTOOLDIR=c:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set GOMOD=c:\Users\CarstenLeue\Documents\go-test-generics\go.mod
set CGO_CFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=c:\temp\Local\Temp\go-build3166563808=/tmp/go-build -gno-record-gcc-switches

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

    "go.testEnvVars": {
        "LIBVIRT_URI": ""
    "go.diagnostic.vulncheck": "Imports",
    "gopls": {
        "ui.semanticTokens": true,
    "go.inlayHints.rangeVariableTypes": true,
    "go.formatTool": "goimports",
    "go.toolsManagement.autoUpdate": true,

Describe the bug

With the following file:

package main

import (

func test[A, B any](a A, b B) {
	fmt.Printf("a: %v, b: %v", a, b)

func test1[A, B any](b B) func(a A) {
	return func(a A) {
		fmt.Printf("a: %v, b: %v", a, b)

func main() {
	test[string, int]("test", 1)
	test1[string, int](1)("test")

I would have expected to see:

a. both type parameters on the invocation of test are not needed
b. the second type parameter on the invocation of test1 is not needed

Steps to reproduce the behavior:

  1. Open the go code above in the editor
  2. Make sure infertypeargs is enabled (should be enabled by default)
  3. unexpected behaviour: no indication of the unneeded types

Screenshots or recordings

This is what I am seeing in vscode:


I would have expected to see the unneeded types greyed out

Copy link

hyangah commented Oct 30, 2023

@findleyr @adonovan Is this analyzer intended to be used for general diagnostics? This is one of the convenience analyzers. From #61559 I am not sure if this is intended to be used for general diagnostics reporting. On the other hand, I think reporting through general diagnostics can be an effective way to guide users to discover the refactoring capability.

Minimal repro:

package main

func f[T any](T) {}

func main() {

If users select a range (even the entire code) and trigger code action (e.g. clicking the bulb in vscode), gopls provides "Simplify Type Arguments" option. Otherwise, I don't think users will find this feature.

Copy link

@hyangah we lost the diagnostic when I reimplemented code actions not to rely on diagnostics. I think this is a real regression, notably because of the lost "Unnecessary" diagnostic tag.

I'll partially revert my change.

@findleyr findleyr changed the title infertypeargs does not seem to have any effect x/tools/gopls: infertypeargs no longer produces diagnostics Oct 30, 2023
@findleyr findleyr transferred this issue from golang/vscode-go Oct 30, 2023
@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 Oct 30, 2023
@gopherbot gopherbot added this to the Unreleased milestone Oct 30, 2023
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.15.0 Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
None yet

No branches or pull requests

4 participants