Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a780c23

Browse files
committed
Eliminate false positive for new(js.object)
1 parent b14cef0 commit a780c23

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

analysis/passes/jsobjectptr/jsobjectptr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
3535
parent := stack[len(stack)-2]
3636
switch pt := parent.(type) {
3737
case *ast.StarExpr:
38-
// Fall through
38+
return true
3939
case *ast.CallExpr:
4040
fun, ok := pt.Fun.(*ast.Ident)
4141
if !ok {

analysis/passes/jsobjectptr/testdata/src/jsobjectptr/jsobjectptr.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var (
2222
_ struct{ x js.Object } // want "js.Object must always be a pointer"
2323
_ = struct{ x js.Object }{} // want "js.Object must always be a pointer"
2424
_ = new(js.Object)
25+
_ *js.Object
2526
)
2627

2728
func _(js.Object) {} // want "js.Object must always be a pointer"

0 commit comments

Comments
 (0)