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 some build errors #56943

Open
ShoshinNikita opened this issue Nov 25, 2022 · 1 comment
Open

x/tools/gopls: gopls doesn't report some build errors #56943

ShoshinNikita opened this issue Nov 25, 2022 · 1 comment
Labels
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

@ShoshinNikita
Copy link

  • gopls version: v0.10.1 and master (f718365)
  • go version: go1.19.2

gopls doesn't take into account private interface methods from std or third-party packages. It results in the absence of some build errors. For example, consider the following code:

-- main.go --
package main

import (
	"go/ast"
	"go/token"
)

func main() {
	var a int               // expected error: "a declared but not used"
	var _ ast.Expr = node{} // expected error: "cannot use node{} ... (missing exprNode method)"
}

type node struct{}

func (node) Pos() token.Pos { return 0 }
func (node) End() token.Pos { return 0 }

I expect to get 2 errors, but gopls reports only one:

$ go build main.go

# command-line-arguments
./main.go:9:6: a declared but not used
./main.go:10:19: cannot use node{} (value of type node) as type ast.Expr in variable declaration:
        node does not implement ast.Expr (missing exprNode method)

$ gopls check main.go

/tmp/main.go:9:6-7: a declared but not used
@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 Nov 25, 2022
@gopherbot gopherbot added this to the Unreleased milestone Nov 25, 2022
@findleyr
Copy link
Contributor

Thanks, this is a problem with "parse exported" mode. We're working on replacing this with export data for the v0.11.0 milestone.

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.11.0 Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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