Repository navigation
Open
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version devel +8e0be05ec7 Sun Jan 19 14:04:09 2020 +0000 linux/amd64 $ go list -m golang.org/x/tools golang.org/x/tools v0.0.0-20200121200311-d456b1cd8c86 $ go list -m golang.org/x/tools/gopls golang.org/x/tools/gopls v0.1.8-0.20200121200311-d456b1cd8c86
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/myitcv/.cache/go-build" GOENV="/home/myitcv/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/myitcv/gostuff" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/myitcv/gos" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/myitcv/.vim/plugged/govim/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build878422207=/tmp/go-build -gno-record-gcc-switches"
What did you do?
The diagnostic for the following file is misleading:
package main
func main() {
_ = func(format string, args ...interface) error {
return nil
}
}
We get:
PublishDiagnostics callback: &protocol.PublishDiagnosticsParams{
URI: "file:///home/myitcv/gostuff/src/github.com/myitcv/playground/main.go",
Version: 36,
Diagnostics: {
{
Range: protocol.Range{
Start: protocol.Position{Line:3, Character:5},
End: protocol.Position{Line:3, Character:5},
},
Severity: 1,
Code: nil,
Source: "syntax",
Message: "expected expression",
Tags: nil,
RelatedInformation: nil,
},
},
}
Contrast what we get from the compiler:
./main.go:4:43: syntax error: unexpected ), expecting {
./main.go:5:3: syntax error: unexpected return, expecting comma or )
./main.go:7:1: syntax error: non-declaration statement outside function body
What did you expect to see?
A better diagnostic.
What did you see instead?
Per above
Marking as gopls/v1.0.0 because this isn't critical for v0.3.0.
cc @stamblerre
FYI @leitzler
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Activity
heschi commentedon Jan 24, 2020
This would be coming from
go/parseror something, no? I don't think gopls can do anything to improve it.stamblerre commentedon Mar 12, 2020
Yes, this is is coming from go/parser. A minimal repro can be found here: https://play.golang.org/p/ca24wvyr5Wl. This seems like an instance where go/parser's errors should be updated to match the compiler's. I'll change the issue title to reflect this.
[-]x/tools/gopls: misleading diagnostic for badly formed func literal[/-][+]go/parser: bad error message for a badly formed func literal[/+]toothrot commentedon Mar 12, 2020
/cc @griesemer
gopherbot commentedon Oct 6, 2020
Change https://golang.org/cl/259817 mentions this issue:
go/parser: Improve error message to user when interface parsing fails