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

Closed
ShoshinNikita opened this issue Mar 17, 2021 · 4 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@ShoshinNikita
Copy link

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 Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 17, 2021
@gopherbot gopherbot added this to the Unreleased milestone Mar 17, 2021
@stamblerre
Copy link
Contributor

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

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 17, 2021
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.6.8 Mar 17, 2021
@findleyr
Copy link
Contributor

I can reproduce, and will take a look.

@gopherbot
Copy link

Change https://golang.org/cl/302533 mentions this issue: internal/lsp/cache: tolerate analysis panics better

@gopherbot
Copy link

Change https://golang.org/cl/302689 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
Reviewed-on: https://go-review.googlesource.com/c/tools/+/302533
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
(cherry picked from commit 9b614f5)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/302689
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
@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
0.6.9
This is a patch release to fix golang/go#45092.

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

0.6.7
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.

Fixes

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
https://golang.org/issues/new.
@golang golang locked and limited conversation to collaborators Mar 17, 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants