fix nil pointer dereference
This commit is contained in:
@@ -2,6 +2,7 @@ package build
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"go/types"
|
||||
|
||||
"github.com/mmcloughlin/avo"
|
||||
"github.com/mmcloughlin/avo/gotypes"
|
||||
@@ -53,7 +54,7 @@ func (c *Context) Signature(s *gotypes.Signature) {
|
||||
}
|
||||
|
||||
func (c *Context) SignatureExpr(expr string) {
|
||||
s, err := gotypes.ParseSignatureInPackage(c.pkg.Types, expr)
|
||||
s, err := gotypes.ParseSignatureInPackage(c.types(), expr)
|
||||
if err != nil {
|
||||
c.AddError(err)
|
||||
return
|
||||
@@ -61,6 +62,13 @@ func (c *Context) SignatureExpr(expr string) {
|
||||
c.Signature(s)
|
||||
}
|
||||
|
||||
func (c *Context) types() *types.Package {
|
||||
if c.pkg == nil {
|
||||
return nil
|
||||
}
|
||||
return c.pkg.Types
|
||||
}
|
||||
|
||||
func (c *Context) Instruction(i *avo.Instruction) {
|
||||
c.activefunc().AddNode(i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user