Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 2e8b9a9

Browse files
owen-mcsmowton
authored andcommitted
Fix extractor crash when missing type information
1 parent ba147e8 commit 2e8b9a9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

extractor/extractor.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,21 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int) {
918918
if expr == nil {
919919
return
920920
}
921-
if _, ok := typeOf(tw, expr.X).Underlying().(*types.Signature); ok {
922-
kind = dbscheme.GenericFunctionInstantiationExpr.Index()
923-
} else {
924-
// Can't distinguish between actual index expressions (into a map,
925-
// array, slice, string or pointer to array) and generic type
926-
// specialization expression, so we do it later in QL.
921+
typeofx := typeOf(tw, expr.X)
922+
if typeofx == nil {
923+
// We are missing type information for `expr.X`, so we cannot
924+
// determine whether this is a generic function instantiation
925+
// or not.
927926
kind = dbscheme.IndexExpr.Index()
927+
} else {
928+
if _, ok := typeofx.Underlying().(*types.Signature); ok {
929+
kind = dbscheme.GenericFunctionInstantiationExpr.Index()
930+
} else {
931+
// Can't distinguish between actual index expressions (into a
932+
// map, array, slice, string or pointer to array) and generic
933+
// type specialization expression, so we do it later in QL.
934+
kind = dbscheme.IndexExpr.Index()
935+
}
928936
}
929937
extractExpr(tw, expr.X, lbl, 0)
930938
extractExpr(tw, expr.Index, lbl, 1)

0 commit comments

Comments
 (0)