Skip to content

Commit

Permalink
Fix nil pointer dereference and continue checking package even if the…
Browse files Browse the repository at this point in the history
…re are type errors (#7)
  • Loading branch information
richardartoul authored Nov 27, 2017
1 parent 2afb68a commit 9f7e9fe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion linters/badtime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func handleImportPaths(
conf := loader.Config{
Fset: fs,
Build: &ctx,
// Continue even if type or IO errors are present
AllowErrors: true,
}

for _, importPath := range importPaths {
Expand Down Expand Up @@ -130,7 +132,10 @@ func (v nodeVisitor) Visit(node ast.Node) ast.Visitor {
if ok && v.equalityCallback != nil {
xType := v.types[binary.X].Type
yType := v.types[binary.Y].Type
if isTimeOrContainsTime(xType) && isTimeOrContainsTime(yType) && binary.Op == token.EQL {
if binary.Op == token.EQL &&
// Type can be nil if there was a type-error
xType != nil && isTimeOrContainsTime(xType) &&
yType != nil && isTimeOrContainsTime(yType) {
v.equalityCallback(v.fs.Position(binary.Pos()), xType.String(), yType.String())
}
return nil
Expand Down

0 comments on commit 9f7e9fe

Please sign in to comment.