With gopls at tip, and go either at 1.15.1 or at tip, internal/lsp/testdata/semantic/a.go causes several analyzers to panic.
a.go contains code that will not build, and some analyzers panic on a type assertion where the types look like []interface{}.(string).
gopls will run analyzers on code that does not build, so it can test proposed fixes,
that is, in cache/analysis.go:325:
data.err = errors.Errorf("analysis skipped due to errors in package: %v", pkg.GetErrors())
return data
}
the test cannot be replaced by if len(pgk.GetErrors()) > 0, because then the tests for proposed fixes fail.
Most of the tests for analyzers won't run on files that don't build (nor will the tests in internal/lsp/source) so one could argue that these analyzers, at least, aren't intended to work on such code. Choices seem to be:
Put up with panic messages from gopls (bad user experience)
Fix the analyzers one by one (whack-a-mole)
For code that does not build, only run the analyzers that propose fixes (contributions welcome)
Do a more careful job at analysis.go:325 in deciding whether to run analyzers (contributions welcome)
Fix a.go so it doesn't trigger panics (push the problem off into the future)
The text was updated successfully, but these errors were encountered:
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 27, 2020
Presently ifaceassert.go panics if given asserts whose
types reduce to
[]interface{}.(string)
which is illegal Go. Its tests won't even run on such code, but
gopls will happily invoke it. This CL adds a test for nil.
See golang/go#42857
Change-Id: I2791f4bd0b58559e65e6590822ac8f4123989273
Reviewed-on: https://go-review.googlesource.com/c/tools/+/273766
Reviewed-by: Michael Matloob <matloob@golang.org>
Trust: Peter Weinberger <pjw@google.com>
With gopls at tip, and go either at 1.15.1 or at tip, internal/lsp/testdata/semantic/a.go causes several analyzers to panic.
a.go contains code that will not build, and some analyzers panic on a type assertion where the types look like []interface{}.(string).
gopls will run analyzers on code that does not build, so it can test proposed fixes,
that is, in cache/analysis.go:325:
the test cannot be replaced by if len(pgk.GetErrors()) > 0, because then the tests for proposed fixes fail.
Most of the tests for analyzers won't run on files that don't build (nor will the tests in internal/lsp/source) so one could argue that these analyzers, at least, aren't intended to work on such code. Choices seem to be:
The text was updated successfully, but these errors were encountered: