[tools] gopls/internal/golang/completion: avoid SEGV from double deslicing

2 views
Skip to first unread message

Peter Weinberger (Gerrit)

unread,
Aug 7, 2026, 10:59:40 AM (3 days ago) Aug 7
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Hongxiang Jiang, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com

Peter Weinberger submitted the change

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
Reviewed-by: Hongxiang Jiang <hxj...@golang.org>
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
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I4771417438969ba494ac51283c7932bbf26cb117
Gerrit-Change-Number: 809600
Gerrit-PatchSet: 2
Gerrit-Owner: Peter Weinberger <p...@google.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Peter Weinberger <p...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages