Fix extractor crash when missing type information

This commit is contained in:
Owen Mansel-Chan 2022-04-25 14:44:35 +01:00 коммит произвёл Chris Smowton
Родитель ba147e8661
Коммит 2e8b9a9a7d
1 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -918,14 +918,22 @@ 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 {
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.IndexExpr.Index()
} else {
if _, ok := typeofx.Underlying().(*types.Signature); ok {
kind = dbscheme.GenericFunctionInstantiationExpr.Index()
} else {
// Can't distinguish between actual index expressions (into a map,
// array, slice, string or pointer to array) and generic type
// specialization expression, so we do it later in QL.
// Can't distinguish between actual index expressions (into a
// map, array, slice, string or pointer to array) and generic
// type specialization expression, so we do it later in QL.
kind = dbscheme.IndexExpr.Index()
}
}
extractExpr(tw, expr.X, lbl, 0)
extractExpr(tw, expr.Index, lbl, 1)
case *ast.IndexListExpr: