Change information
Commit message:
gopls/internal/golang/completion: avoid SEGV from double deslicing
Completing at the cursor in
func f[T ~[]int](x T) {var s string; _ = append(x, append(<cursor>x, x...)...)
causes an extra deslicing in expectedCallParamType which makes the
expected param type as both variadic and nil which produces []nil
as the inner append's type, which gets matched against s's type
for completion, which seems to cause the panic.
The fix is to avoid slicing if there's a ..., in which case a slice is
being passed directly, so the code doesn't need to deslice.
Fixes: golang/go#74564
Change-Id: I4771417438969ba494ac51283c7932bbf26cb117
Files:
- M gopls/internal/golang/completion/builtin.go
- M gopls/internal/golang/completion/completion.go
- M gopls/internal/test/integration/completion/completion_test.go
Change size: S
Delta: 3 files changed, 28 insertions(+), 5 deletions(-)
Branch: refs/heads/master