Merge pull request #199 from max/notype-test

Add test for handling of expressions without extracted type.
This commit is contained in:
Sauyon Lee
2019-12-06 01:59:32 -08:00
committed by GitHub Enterprise
5 changed files with 25 additions and 0 deletions

View File

@@ -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 |

View File

@@ -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 |

View 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 |

View 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()

View 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)
}