Commit 851c747
committed
gopls/internal/golang: fix crash when hovering over implicit
After months of intermittent investigation, I was finally able to
reproduce the telemetry crash of golang/go#69362: if the operant of the
type switch is undefined, the selectedType will be nil, and therefore
logic may proceed to the point where it reaches a nil entry in
types.Info.Defs.
The fix is of course straightforward, now that we understand it: we
cannot rely on types.Info.Defs not containing nil entries. A follow-up
CL will introduce an analyzer to detect such problematic uses of the
go/types API.
Fixes golang/go#69362
Change-Id: I8f75c24710dbb2e78c79d8b9d721f45d9a040cd7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/652015
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>1 parent 3e76cae commit 851c747
File tree
2 files changed
+16
-9
lines changed- gopls/internal
- golang
- test/marker/testdata/hover
2 files changed
+16
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
387 | 382 | | |
388 | 383 | | |
389 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments