mirror of
https://github.com/github/codeql.git
synced 2026-01-29 06:12:58 +01:00
Merge pull request #199 from max/notype-test
Add test for handling of expressions without extracted type.
This commit is contained in:
@@ -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 |
|
||||
|
||||
@@ -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 |
|
||||
|
||||
3
ql/test/library-tests/semmle/go/Types/notype.expected
Normal file
3
ql/test/library-tests/semmle/go/Types/notype.expected
Normal file
@@ -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 |
|
||||
8
ql/test/library-tests/semmle/go/Types/notype.ql
Normal file
8
ql/test/library-tests/semmle/go/Types/notype.ql
Normal file
@@ -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()
|
||||
12
ql/test/library-tests/semmle/go/Types/unknownFunction.go
Normal file
12
ql/test/library-tests/semmle/go/Types/unknownFunction.go
Normal file
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user