Some of the analyzers that are on by default in gopls produce many distracting
warnings. These are 'composites' and 'simplifycompositelit'.
This CL changes code to remove the 160 or so warnings.
An alternative would be to remove these from the default set of gopls analyzers.
Change-Id: Id5724a5aef260939dedd21a37e28f3d05bfa023d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/443635
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This eliminates a race between a successful Accept call and a
concurrent Close call, which previously could have shut down the
'run' goroutine before Accept sent to the newConns channel, causing
Accept to deadlock.
In fact, it eliminates the long-running 'run' goroutine entirely
(replacing it with a time.Timer), and in the process avoids leaking
O(N) closed connections when only the very first one is long-lived.
It also eliminates a potential double-Close bug: if the run method had
called l.wrapped.Close due to an idle timeout, a subsequent call to
Close would invoke l.wrapped.Close again. The io.Closer method
explicitly documents doubled Close calls as undefined behavior, and
many Closer implementations (especially test fakes) panic or deadlock
in that case.
It also eliminates a timer leak if the Listener rapidly oscillates
between active and idle: previously the implementation used
time.After, but it now uses an explicit time.Timer which can be
stopped (and garbage-collected) when the listener becomes active.
Idleness is now tracked based on the connection's Close method rather
than Read: we have no guarantee in general that a caller will ever
actually invoke Read (if, for example, they Close the connection as
soon as it is dialed), but we can reasonably expect a caller to at
least try to ensure that Close is always called.
We now also verify, using a finalizer on a best-effort basis, that the
Close method on each connection is called. We use the finalizer to
verify the Close call — rather than to close the connection implicitly
— because closing the connection in a finalizer would delay the start
of the idle timer by an arbitrary and unbounded duration after the
last connection is actually no longer in use.
Fixesgolang/go#46047.
Fixesgolang/go#51435.
For golang/go#46520.
For golang/go#49387.
Change-Id: If173a3ed7a44aff14734b72c8340122e8d020f26
Reviewed-on: https://go-review.googlesource.com/c/tools/+/388597
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
With the suffixes I end up a little lost in the “box” noise while I'm
reading — the channel ops alone suffice to make the storage mechanism
clear.
(To me, the mechanism of storing a value in a 1-buffered channel is
conceptually similar to storing it in a pointer, atomic.Pointer, or
similar — and we don't generally name those with a suffix either.)
For golang/go#46047.
For golang/go#46520.
For golang/go#49387.
Change-Id: I7f58a9ac532f597fe49ed70606d89bd8cbe33b55
Reviewed-on: https://go-review.googlesource.com/c/tools/+/443355
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Otherwise, the Await method on the corresponding AsyncCall will never
unblock, leading to a deadlock (detected by the test changes in
CL 388597).
For golang/go#46047
For golang/go#46520
For golang/go#49387
Change-Id: I7954f80786059772ddd7f8c98d8752d56d074919
Reviewed-on: https://go-review.googlesource.com/c/tools/+/388775
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(*Server).run calls Wait on all of its connections before returning,
but does not call Close explicitly. If Close is necessary to
release resources (as is often the case for a net.Conn),
the server ends up leaking resources.
For golang/go#46047
Change-Id: I4ad048c4f5e5d3f14f992eee6388acd42398c26b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/388599
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
On darwin/cgo use readdir_r instead of syscall.ReadDirent() since the
later is simulated and slow (see: golang/go#30933).
Unlike CL 392094, this uses CGO instead of "//go:linkname" and assembly.
goos: darwin
goarch: arm64
FastWalk-10 68.9ms ±11% 20.7ms ± 2% -69.89% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
FastWalk-10 1.49MB ± 0% 1.51MB ± 0% +1.06% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
FastWalk-10 32.2k ± 0% 30.7k ± 0% -4.61% (p=0.016 n=5+4)
Fixesgolang/go#51356
Change-Id: Ia3afd06c8f14bd2036b2a1ea6e3cafbef81d3530
Reviewed-on: https://go-review.googlesource.com/c/tools/+/436780
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
The LSP protocol doesn't require edits to be sorted,
but some clients such as govim were relying on it,
as we learned when I recently removed the sort.
This change restores the sort behavior.
See also govim/govim#1171
Change-Id: I589b6cfde933ea6907859bf40acd33c1a7fcde02
Reviewed-on: https://go-review.googlesource.com/c/tools/+/442256
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Read the entire API directory, so that we don't need to edit mkstdlib.go
when regenerating zstdlib.go for new go versions.
Joint with Dylan Le.
Co-Authored-By: dle8@u.rochester.edu.
Change-Id: If5c71bfcfd2104f923df10cf21d16b5280fed025
Reviewed-on: https://go-review.googlesource.com/c/tools/+/438504
Reviewed-by: Dylan Le <dungtuanle@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
LineEdits has similar consistency preconditions to ApplyEdits.
Previously they were assumed, and bad input would create bad
output or crashes; now it uses the same validation logic
as ApplyEdits. Since it reports an error, computation of a
unified diff can also fail if the edits are inconsistent.
The ToUnified([]Edit) function now returns an error. For
convenience we also provide a wrapper (Unified) that cannot
fail since it calls Strings and ToUnified consistently.
LineEdits itself is now private.
Change-Id: I3780827f501d7d5c9665ec8be5656331c0dcda8e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/440175
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Spans are logically part of gopls, but could not be moved
into the gopls module because of a number of depenencies
from packagestest, analysis, and internal/diff.
Those edges are now broken.
Change-Id: Icba5ebec6b27974f832a1186120a4b87d5f87103
Reviewed-on: https://go-review.googlesource.com/c/tools/+/440176
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Previously, a diff of non-ASCII strings would incur
three complete copies of the buffers; this changes
reduces it to one.
Also:
- add diff.Bytes function, to avoid unnecessary conversions.
- remove unused diff.Lines and LineEdits functions from API.
- remove TODO to use []bytes everywhere.
We tried it in CL 439277 and didn't like it.
- Document that the diff is textual, even when given []byte.
Change-Id: I2da3257cc3d12c569218a2d7ce182452e8647a96
Reviewed-on: https://go-review.googlesource.com/c/tools/+/439835
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Apply now checks that its edits are valid
(not out of bounds or overlapping),
and reports an error if not.
It also sorts them, if necessary, using (start, end)
as the key, to ensure that insertions (end=start)
are ordered before deletions at the same point
(but without changing the relative order of insertions).
Two other implementations of the diff.Apply algorithm
have been eliminated. (One of them failed to sort edits,
requiring the protocol sender to do so; that burden
is now gone.)
Change-Id: Ia76e485e6869db4a165835c3312fd14bc7d43db2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/439278
Auto-Submit: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
The span package is properly part of gopls, and we'd like to move
it into that module. However, the packagestest package unfortunately
depends on span.Span as an alternative notation for Ranges.
This change decouples span.Span from packagestest.Range using a
new (unexported for now) rangeSetter interface, which Span implements.
Neither package depends on the other.
Technically this is a breaking API change:
all the Range methods have gone away, as have the Span, URI,
and Point types and their methods, which were accessible via
Range.Span(). However, clients would not be able to access
these internal types, and I think it is highly unlikely that
anyone depends on it. Nonethless this is a cautionary tale about
the risks from one innocuous-looking type alias declaration.
Change-Id: I8acb03f4acb1f798f304b03648445e37a44f9c45
Reviewed-on: https://go-review.googlesource.com/c/tools/+/439715
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
diff.TextEdit (now called simply Edit) no longer has a Span,
and no longer depends on the span package, which is really
part of gopls. Instead, it records only start/end byte
offsets within an (implied) file.
The diff algorithms have been simplified to avoid the need to
map offsets to line/column numbers (e.g. using a token.File).
All the conditions actually needed by the logic can be derived
by local string operations on the source text.
This change will allow us to move the span package into the
gopls module.
I was expecting that gopls would want to define its own
Span-augmented TextEdit type but, surprisingly, diff.Edit
is quite convenient to use throughout the entire repo:
in all places in gopls that manipulate Edits, the implied
file is obvious. In most cases, less conversion boilerplate
is required than before.
API Notes:
- diff.TextEdit -> Edit (it needn't be text)
- diff.ApplyEdits -> Apply
- source.protocolEditsFromSource is now private
Change-Id: I4d7cef078dfbd189b4aef477f845db320af6c5f6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/436781
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Computing the difference between two strings is logically an
infallible operation. This change makes the code reflect that. The
actual failures were unreachable given consistent inputs, but that was
hard to see from the complexity of the logic surrounding span.Span.
(The problem only occurs when converting offsets beyond the end of the
file to Spans, but the code preserves the integrity of offsets.)
gopls' "old" hooks.ComputeEdits impl (based on sergi/go-diff) now
reports a bug and returns a single diff for the entire file if it
panics.
Also, first steps towards simpler API and a
reusable diff package in x/tools:
- add TODO for new API. In particular, the diff package shouldn't care
about filenames, spans, and URIs. These are gopls concerns.
- diff.String is the main diff function.
- diff.Unified prints edits in unified form;
all its internals are now hidden.
- the ComputeEdits func type is moved to gopls (source.DiffFunction)
- remove all non-critical uses of myers.ComputeEdits. The only
remaining one is in gopls' defaults, but perhaps that gets
overridden by the default GoDiff setting in hooks, to BothDiffs
(sergi + pjw impls), so maybe it's now actually unused in practice?
Change-Id: I6ceb5c670897abbf285b243530a7372dfa41edf6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/436778
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
GNU diff -u prints -0,0 for the special case of inserting
into an empty file. (I don't understand why this case is
special, but it's fair to assume it has been debugged;
perhaps patch(1) has a bug.)
This change matches that special behavior, and adds a test.
It also adds a (disabled) test for another bug I encountered.
Also, remove some overzealous uses of t.Helper() that served
to obscure the failure.
Change-Id: I3e0c389c478cde45163353130e36f2f8741a8659
Reviewed-on: https://go-review.googlesource.com/c/tools/+/436782
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
The code that generates a name for a struct type,
and a default value for a struct field, now
supports the case where either contains a type
parameter.
Also:
- use type-checker's name for the struct type unless
it is a bare struct.
- populateValue: return *new(T) for a type parameter.
- various minor cleanups.
- various TODO comments for clarifications.
- fuzzy.FindBestMatch: use strings not identifiers.
Remove Find prefix (also FindMatchingIdentifiers).
Fixesgolang/go#54836
Change-Id: I4f6132598b4ac7e72ea1405e4a14d6a23c1eeeaa
Reviewed-on: https://go-review.googlesource.com/c/tools/+/436777
Auto-Submit: Alan Donovan <adonovan@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
An application that links in version 1.18 of (say)
go/types cannot process Go source files reported
by version 1.19 of 'go list'. There is no way to
tell go list to behave as if it was go1.18, so
for now we proceed with parsing/typechecking but,
in case of errors, we issue an additional informative
diagnostic.
Fixesgolang/go#55883Fixesgolang/go#55045
Updates golang/go#50825
Updates golang/go#52078
Change-Id: I5fd99b09742c136f4db7f71d2a75e4cdb730460d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/435356
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
We're almost certain that the go process shown by ps
is not the one that we're waiting for in runCmdContext,
but only by printing the pid can we be sure.
Updates golang/go#54461
Change-Id: I1ce9580de6ee6bc4557d76c2a6b05f5a3e2eb6c2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/434637
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Add experimental new logic to the loopclosure analyzer that checks for
access to loop variables from parallel subtests. For now, this is gated
behind an internal variable so that we may experiment with it without
yet affecting cmd/vet.
Add an internal/loopclosure command that enables the experimental new
check.
Change-Id: Ibf7e388a58a2b3e712e66e095d06612cf3ea918c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/430916
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Add a TODO and wait for a shorter period of time following Kill, per
post-submit advice from bcmills on CL 424075.
For golang/go#54461
Change-Id: Ia0e388c0119660844dad32629ebca4f122fded12
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431075
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
When a go command hangs during gopls regression tests, print out
additional information about processes and file descriptors.
For golang/go#54461
Change-Id: I92aa4665e9056d15a274c154fce2783bed79718e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/424075
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This CL was created using the following commands:
./gopls/internal/migrate.sh
git add .
git codereview gofmt
For golang/go#54509
Change-Id: Iceeec602748a5e6f609c3ceda8d19157e5c94009
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426796
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Change DocumentChanges field type from []TextDocumentEdit to []DocumentChanges. DocumentChanges is a union type of TextDocumentEdit and RenameFile used for renaming package feature. It distinguishes a renaming directory ops from a text document edit ops.
For golang/go#41567
Change-Id: I25d106b34821effc53b712800f7175248e59ee25
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427538
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Dylan Le <dungtuanle@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
CL 410955 changes printing of unions which breaks two typeparams tests.
Use regexp matching and adjust the wanted results accordingly.
For golang/go#53279.
For golang/go#54822.
Change-Id: I7060df47d36ce3069570237dafff024aaad637a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428055
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
CL 410955 changes printing of unions which breaks a few lsp tests.
Disable them for now so we can submit CL 410955.
For golang/go#53279.
For golang/go#54822.
Change-Id: I54ff99a4f5530181a39557b6b62e776af082c28d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/428054
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
CL 425716 changes parser behavior for incorrect code (it is more
lenient) which breaks a few lsp tests. Disable them for now so we
can submit CL 425716.
For golang/go#54511.
For golang/go#54822.
Change-Id: I00fa67e29628137f3e4e44c38e92094ea581a61b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/427654
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Add functions to the output when hovering over a type.
Fixesgolang/go#54008
Change-Id: Ia0a7b5a878c3d63c4bbc549f003c45592db1c135
Reviewed-on: https://go-review.googlesource.com/c/tools/+/420714
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This change prevents analysis from running on a package containing
any kind of error unless the analyzer has indicated that it is robust.
This is presumed to be the cause of several panics in production.
And a test.
Updates golang/go#54762
Change-Id: I9327e18ef8d7773c943ea45fc786991188358131
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426803
Run-TryBot: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This is a follow-up on CL 425497. Must be submitted after CL 425007.
For golang/go#54511.
Change-Id: Ice9c1c62b911efa8efa20ea295bf313aabe8c5bb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425594
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
While moving internal/lsp to gopls/internal/lsp, we discovered that
we're bumping up against a command line length limit on windows. Use an
arbitrary shorter module path to avoid this, for now.
Updates golang/go#54800
Updates golang/go#54509
Change-Id: I7be07da29a769c1ce7c31cbbd374ca47b0944132
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426801
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
In several places throughout the x/tools codebase, the internal/lsp/diff
package is used to provide clearer test output when comparing large,
multi-line strings. In some places, this is implemented via the
tests.Diff helper function, but in others it is not (presumably due to
import cycles).
Factor out this pattern into a diff.Pretty function, and add commentary.
Also remove the *testing.T argument, as diffs should never fail; opt to
panic instead. Also add a test.
Using this function, simplify the logic to comparing our 1.18 markdown
output with 1.19 golden content, by normalizing differences between the
two.
This is necessary as markdown content will change as a result of moving
internal/lsp to gopls/internal/lsp.
For golang/go#54509
Change-Id: Ie1fea1091bbbeb49e00c4efa7e02707cafa415cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426776
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
This method does not in fact report whether the package is ill-typed.
It actually reports whether any of three fields of pkg are nil.
They never are.
This does rather explain why type-error analyzers are executed
on (genuinely) ill-typed packages, despite the !IllTyped()
condition. And why analyzers that aren't prepared to handle
ill-typed code (!RunDespiteErrors) sometimes crash in production.
Updates golang/go#54762
Change-Id: I95421584bec68fb849b5ed52cc4e6d9b6bb679be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426802
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
This change consolidates the logic of the memoized function
for analysis (previously split across execAll and runAnalysis)
to make the error control flow clearer. The new function,
actionImpl, follows the same conventions as in other memoized
functions.
Errors from await (e.g. cancellation) are now separate from
errors from analysis itself. Only the latter are now ignored
in the diagnostics loop over the roots.
Also, where previously the recursion would ignore failed
dependencies (proceeding to call runAnalysis even after
seeing an &actionData{err!=nil}), now the recursion aborts
if one of the prerequisites fails, as it should.
The only edges currently enabled are "horizontal" (inputs,
not facts). This would explain the crash in golang/go#54798,
in which the result of the nspector pass was not available
to the structtag pass.
Also:
- merge the loops over deps in execAll and runAnalysis.
- remove unnecessary checks for context cancellation in
loops of pure computation.
- don't suppress errors from awaitPromise.
- add commentary.
- turn two "can't happen" errors into panics.
- remove unnecessary logging of analysis failures.
Fixesgolang/go#54798
Change-Id: Iefb42d2d074a31f2f717dc94c38aed7f1dab1c80
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426800
Auto-Submit: Alan Donovan <adonovan@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
In the presence of type errors, TypeOf may return nil, and this appears
to have contributed to a crash in the fillreturns analysis. I haven't
been able to find or deduce a test case, but this change makes the logic
more defensive.
Also remove a stale pre-go1.17 test that used to trigger a panic
(the one fixed here? unclear) to assert that panics were recoverable.
Updates golang/go#54655
Change-Id: Ic9ca9a307eede50a2d4db6424822a155dd43e635
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426019
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Run reset_golden.sh, so that our golden files are stable. This will be
useful later, when we migrate internal/lsp to gopls/internal/lsp, and
golden files must be updated to account for changing offsets.
For golang/go#54509
Change-Id: I2e9a8d3493d64d632b9f0f0e0360d633803f9d92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426797
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
The diagnostics emitted by the Go toolchain vary from one
release to the next, and the gopls tests run against multiple
versions. Therefore our tests need a way to express multiple
possibilities in their expectations. This change interprets
the patterns in @diag test annotations as regular expressions,
allowing some flexibility in recognizing both old and new
messages. It's not a panacea but it is one step to reducing
the considerable friction of making changes to the compiler
or go/types in the main tree.
Details:
- Factor the three implementations of the Tests.Diagnostics
abstract method so that they all use DiffDiagnostics
to report differences, substantially rewriting one of them.
- Move the "no_diagnostics" hack, of which there were three
copies, not all consistent, into DiffDiagnostics.
- Eliminate the named type for each tests.Data field;
a type alias is all that's needed.
- Add Diagnostics.String method.
- Add various TODOs for further improvements.
- Add various apparently missing Fatal statements within
the tests.
Change-Id: Id38ad72a851b551dd4eb1d8c021bcb8adbb2213f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425956
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
This is a simple revert of CL 425497, which disabled the tests.
The problem was due to a misencoded FMOVD instruction causing
some 0.0 constants to compile to nonzero; fixed by CL 425188.
Updates golang/go#54655
Updates golang/go#425188
Change-Id: I2231b57b7b78ac1ae2e8b60cda62898ea7122cda
Reviewed-on: https://go-review.googlesource.com/c/tools/+/426017
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
The Check for upgrades codelens was only looking for upgrades for
the current module, but was applying diagnostics to all go.mod
files in the workspace. This change makes sure to only apply the
diagnostics in the same selected go.mod.
Fixesgolang/go#54556
Change-Id: I1eacbc8af2e9dcfe1e1a67516f047bcb94099872
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425195
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This change ensures that the End position provided to span.NewRange
in suggestedAnalysisFixes is valid even when the diagnostic has
only a valid start position. This seems to be the cause of
some panics observed in the ARM builders in the attached issue.
Also, reduce the scope of the recover operation to just the analyzer's
run method: we don't want to hide further bugs (or discard stack traces)
in the setup or postprocessing logic.
Also:
- split a single assertion in span.NewRange into two.
- Add information to various error messages to help identify causes.
- Add TODO comments about inconsistent treatment of token.File
in span.FileSpan, and temporarily remove bug.Errorf that
is obviously reachable from valid inputs.
- Add TODO to fix another panic in an analyzer that is covered
by our tests but was hitherto suppressed.
- Add TODO to use bug.Errorf after recover to prevent recurrences.
We can't do that until the previous panic is fixed.
Updates https://github.com/golang/go/issues/54655
Change-Id: I0576d03fcfffe0c8df157cf6c6520c9d402f8803
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425356
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
This is a stopgap until I can diagnost the problem, but in the meantime
we need to fix the builders.
Updates https://github.com/golang/go/issues/54655
Change-Id: I6260828e8c07e3121c45f99166a26d51aa9805a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425575
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tim King <taking@google.com>