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: gopls doesn't report errors when a return statement contains undeclared variable #45075

ShoshinNikita opened this issue Mar 17, 2021 · 4 comments


Copy link

@ShoshinNikita ShoshinNikita commented Mar 17, 2021

gopls version: v0.6.7

The bug was introduced in golang/tools@144d5ce. The minimal reproducible example:

package main

func foo() int {
	return x, nil // No errors, expected 'wrong number of return values (want 1, got 2)' and 'undeclared name: x'

func bar() {
	return 5 // No errors, expected 'no result values expected'

func main() {

If we add var x string before the return statement, all errors will appear.

@gopherbot gopherbot added this to the Unreleased milestone Mar 17, 2021
Copy link

@stamblerre stamblerre commented Mar 17, 2021

Thank you for this report, but unfortunately, I'm not able to reproduce the issue. Can you please share your gopls logs? Information on how to capture them can be found here.

/cc @heschik

Copy link

@findleyr findleyr commented Mar 17, 2021

I can reproduce, and will take a look.

Copy link

@gopherbot gopherbot commented Mar 17, 2021

Change mentions this issue: internal/lsp/cache: tolerate analysis panics better

Copy link

@gopherbot gopherbot commented Mar 17, 2021

Change mentions this issue: internal/lsp/cache: tolerate analysis panics better

gopherbot pushed a commit to golang/tools that referenced this issue Mar 17, 2021
Panics in type error analyzers shouldn't block diagnostics.

Fixes golang/go#45075.

Change-Id: I897f0949551ab65276371f7ec8140ccb689e5a7b
Trust: Heschi Kreinick <>
Run-TryBot: Heschi Kreinick <>
gopls-CI: kokoro <>
TryBot-Result: Go Bot <>
Reviewed-by: Robert Findley <>
Reviewed-by: Rebecca Stambler <>
(cherry picked from commit 9b614f5)
Trust: Rebecca Stambler <>
Run-TryBot: Rebecca Stambler <>
@stamblerre stamblerre removed this from the gopls/v0.6.9 milestone Mar 17, 2021
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 1, 2021
This is a patch release to fix golang/go#45092.

This is a patch release to fix golang/go#45075.

New analyzers

The unusedwrite and nilness analyzers are now available, but they
are disabled by default. Note that enabling them permanently may
significantly increase memory usage. You can configure analyzers
through the analyses setting.  Improved hover with time.Duration

Hover for any constant of type time.Duration is shown both in
nanoseconds and as a human-readable string.


A full list of all issues fixed can be found in the gopls/v0.6.7
milestone. To report a new problem, please file a new issue at
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants