Skip to content

Commit

Permalink
ValueSpec.Type is not always available
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Sep 25, 2023
1 parent 59612ee commit 035b04f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ func collectFunctypes(p *packages.Package, name string, fn ast.Node, scope *func
switch s := spec.(type) {
case *ast.ValueSpec:
for _, name := range s.Names {
scope.insert(name, s.Type)
typ := s.Type
if typ == nil {
typ = typeExpr(p, p.TypesInfo.TypeOf(name))
}
scope.insert(name, typ)
}
}
}
Expand Down

0 comments on commit 035b04f

Please sign in to comment.