Fix another place where type could be nil

This commit is contained in:
Owen Mansel-Chan
2022-04-26 13:50:27 +01:00
committed by Chris Smowton
parent 06d139848d
commit aa62fabe26

View File

@@ -940,10 +940,18 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int) {
if expr == nil {
return
}
if _, ok := typeOf(tw, expr.X).Underlying().(*types.Signature); ok {
kind = dbscheme.GenericFunctionInstantiationExpr.Index()
} else {
typeofx := typeOf(tw, expr.X)
if typeofx == nil {
// We are missing type information for `expr.X`, so we cannot
// determine whether this is a generic function instantiation
// or not.
kind = dbscheme.GenericTypeInstantiationExpr.Index()
} else {
if _, ok := typeofx.Underlying().(*types.Signature); ok {
kind = dbscheme.GenericFunctionInstantiationExpr.Index()
} else {
kind = dbscheme.GenericTypeInstantiationExpr.Index()
}
}
extractExpr(tw, expr.X, lbl, 0)
extractExprs(tw, expr.Indices, lbl, 1, 1)