Skip to content

Commit

Permalink
Merge pull request #4 from gostaticanalysis/fix-panic-for-funclit
Browse files Browse the repository at this point in the history
Fix panic for func lit
  • Loading branch information
tenntenn authored Aug 12, 2021
2 parents b11e963 + 2dd381a commit 6bc5e75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions passes/fieldtype/fieldtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,15 @@ func fieldkey(pass *analysis.Pass, fs map[string]*types.Func, call *ast.CallExpr
id = fun
case *ast.SelectorExpr:
id = fun.Sel
default:
return "", ""
}

obj := pass.TypesInfo.ObjectOf(id)
if obj == nil {
return "", ""
}

f := fs[obj.Name()]
if f == nil || f != obj {
return "", ""
Expand Down
1 change: 1 addition & 0 deletions passes/fieldtype/testdata/src/a/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ func f() {
zap.Any("id", "100") // OK - ignore
zap.Reflect("id", "100") // OK - ignore
zap.String("xxx", "100") // OK
func() {}() // OK
}

0 comments on commit 6bc5e75

Please sign in to comment.