Skip to content

Commit

Permalink
gopls/internal/golang: fix nil panic in InlayHint
Browse files Browse the repository at this point in the history
Fixes golang/go#67142

Change-Id: Iee99c1fb0378c409bbbe803ad66b99a068e6d4bc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/582957
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
  • Loading branch information
adonovan authored and gopherbot committed May 2, 2024
1 parent 74c9cfe commit ccdef3c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gopls/internal/golang/inlay_hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ func parameterNames(node ast.Node, m *protocol.Mapper, tf *token.File, info *typ
if !ok {
return nil
}
signature, ok := typeparams.CoreType(info.TypeOf(callExpr.Fun)).(*types.Signature)
t := info.TypeOf(callExpr.Fun)
if t == nil {
return nil
}
signature, ok := typeparams.CoreType(t).(*types.Signature)
if !ok {
return nil
}
Expand Down
36 changes: 36 additions & 0 deletions gopls/internal/test/marker/testdata/inlayhints/issue67142.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Regression test for golang/go#67142.

-- flags --
-ignore_extra_diags
-min_go=go1.21

-- settings.json --
{
"hints": {
"assignVariableTypes": true,
"compositeLiteralFields": true,
"compositeLiteralTypes": true,
"constantValues": true,
"functionTypeParameters": true,
"parameterNames": true,
"rangeVariabletypes": true
}
}

-- go.mod --
module w

go 1.21.9

-- p.go --
//@inlayhints(out)
package p

var _ = rand.Float64()

-- @out --
//@inlayhints(out)
package p

var _ = rand.Float64()

0 comments on commit ccdef3c

Please sign in to comment.