зеркало из https://github.com/github/codeql-go.git
Fix extractor crash when missing type information
This commit is contained in:
Родитель
ba147e8661
Коммит
2e8b9a9a7d
|
@ -918,13 +918,21 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int) {
|
||||||
if expr == nil {
|
if expr == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, ok := typeOf(tw, expr.X).Underlying().(*types.Signature); ok {
|
typeofx := typeOf(tw, expr.X)
|
||||||
kind = dbscheme.GenericFunctionInstantiationExpr.Index()
|
if typeofx == nil {
|
||||||
} else {
|
// We are missing type information for `expr.X`, so we cannot
|
||||||
// Can't distinguish between actual index expressions (into a map,
|
// determine whether this is a generic function instantiation
|
||||||
// array, slice, string or pointer to array) and generic type
|
// or not.
|
||||||
// specialization expression, so we do it later in QL.
|
|
||||||
kind = dbscheme.IndexExpr.Index()
|
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.
|
||||||
|
kind = dbscheme.IndexExpr.Index()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
extractExpr(tw, expr.X, lbl, 0)
|
extractExpr(tw, expr.X, lbl, 0)
|
||||||
extractExpr(tw, expr.Index, lbl, 1)
|
extractExpr(tw, expr.Index, lbl, 1)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче