Skip to content

Commit

Permalink
Don't panic when scanning map interface types
Browse files Browse the repository at this point in the history
Signed-off-by: JoramWilander <jwawilander@gmail.com>
  • Loading branch information
jwilander authored and dennwc committed Jul 24, 2018
1 parent 5fd124f commit 9175115
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ func scanType(typ types.Type) (t Type) {
case *types.Map:
key := scanType(u.Key())
val := scanType(u.Elem())
if val == nil {
report.Warn("ignoring map with value type %s", typ.String())
return nil
}
t = NewMap(key, val)
default:
report.Warn("ignoring type %s", typ.String())
Expand Down
5 changes: 5 additions & 0 deletions scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func TestScanType(t *testing.T) {
types.NewInterface(nil, nil),
nil,
},
{
"map interface",
types.NewMap(types.Typ[types.String], &types.Interface{}),
nil,
},
}

for _, c := range cases {
Expand Down

0 comments on commit 9175115

Please sign in to comment.