diff --git a/ql/test/library-tests/semmle/go/Types/SignatureType_getNumParameter.expected b/ql/test/library-tests/semmle/go/Types/SignatureType_getNumParameter.expected index 1e7e4fd9cb5..6f7f3920bdf 100644 --- a/ql/test/library-tests/semmle/go/Types/SignatureType_getNumParameter.expected +++ b/ql/test/library-tests/semmle/go/Types/SignatureType_getNumParameter.expected @@ -4,3 +4,4 @@ | pkg1/tst.go:33:1:35:1 | function declaration | 0 | | pkg1/tst.go:37:1:37:26 | function declaration | 1 | | pkg1/tst.go:39:1:57:1 | function declaration | 2 | +| unknownFunction.go:8:1:12:1 | function declaration | 0 | diff --git a/ql/test/library-tests/semmle/go/Types/SignatureType_getNumResult.expected b/ql/test/library-tests/semmle/go/Types/SignatureType_getNumResult.expected index d38ddcce152..3b37704f7b3 100644 --- a/ql/test/library-tests/semmle/go/Types/SignatureType_getNumResult.expected +++ b/ql/test/library-tests/semmle/go/Types/SignatureType_getNumResult.expected @@ -4,3 +4,4 @@ | pkg1/tst.go:33:1:35:1 | function declaration | 1 | | pkg1/tst.go:37:1:37:26 | function declaration | 0 | | pkg1/tst.go:39:1:57:1 | function declaration | 0 | +| unknownFunction.go:8:1:12:1 | function declaration | 0 | diff --git a/ql/test/library-tests/semmle/go/Types/notype.expected b/ql/test/library-tests/semmle/go/Types/notype.expected new file mode 100644 index 00000000000..669165864d4 --- /dev/null +++ b/ql/test/library-tests/semmle/go/Types/notype.expected @@ -0,0 +1,3 @@ +| unknownFunction.go:9:7:9:21 | unknownFunction | invalid type | +| unknownFunction.go:9:7:9:23 | call to unknownFunction | invalid type | +| unknownFunction.go:10:7:10:15 | ...+... | invalid type | diff --git a/ql/test/library-tests/semmle/go/Types/notype.ql b/ql/test/library-tests/semmle/go/Types/notype.ql new file mode 100644 index 00000000000..9c781d2bff2 --- /dev/null +++ b/ql/test/library-tests/semmle/go/Types/notype.ql @@ -0,0 +1,8 @@ +import go + +from Expr e +where + // filter out expressions that don't have any semantics + exists(DataFlow::exprNode(e)) and + not type_of(e, _) +select e, e.getType() diff --git a/ql/test/library-tests/semmle/go/Types/unknownFunction.go b/ql/test/library-tests/semmle/go/Types/unknownFunction.go new file mode 100644 index 00000000000..5af16d4b13f --- /dev/null +++ b/ql/test/library-tests/semmle/go/Types/unknownFunction.go @@ -0,0 +1,12 @@ +package main + +// This file tests type inference for expressions referencing undeclared entities. +// It is therefore expected to produce extractor warnings. + +import "fmt" + +func unknownFunctionTest() { + e := unknownFunction() + f := "hi " + e + fmt.Println(e, f) +}