Skip to content

Commit ccdef3c

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/golang: fix nil panic in InlayHint
Fixes golang/go#67142 Change-Id: Iee99c1fb0378c409bbbe803ad66b99a068e6d4bc Reviewed-on: https://go-review.googlesource.com/c/tools/+/582957 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 74c9cfe commit ccdef3c

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

gopls/internal/golang/inlay_hint.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ func parameterNames(node ast.Node, m *protocol.Mapper, tf *token.File, info *typ
139139
if !ok {
140140
return nil
141141
}
142-
signature, ok := typeparams.CoreType(info.TypeOf(callExpr.Fun)).(*types.Signature)
142+
t := info.TypeOf(callExpr.Fun)
143+
if t == nil {
144+
return nil
145+
}
146+
signature, ok := typeparams.CoreType(t).(*types.Signature)
143147
if !ok {
144148
return nil
145149
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Regression test for golang/go#67142.
2+
3+
-- flags --
4+
-ignore_extra_diags
5+
-min_go=go1.21
6+
7+
-- settings.json --
8+
{
9+
"hints": {
10+
"assignVariableTypes": true,
11+
"compositeLiteralFields": true,
12+
"compositeLiteralTypes": true,
13+
"constantValues": true,
14+
"functionTypeParameters": true,
15+
"parameterNames": true,
16+
"rangeVariabletypes": true
17+
}
18+
}
19+
20+
-- go.mod --
21+
module w
22+
23+
go 1.21.9
24+
25+
-- p.go --
26+
//@inlayhints(out)
27+
package p
28+
29+
var _ = rand.Float64()
30+
31+
-- @out --
32+
//@inlayhints(out)
33+
package p
34+
35+
var _ = rand.Float64()
36+

0 commit comments

Comments
 (0)