bradleyfalzon / closecheck

Check for missing close method calls on objects that may require them - SEE EPILOGUE
Apache License 2.0
1 stars 0 forks source link

Panic in github.com/ncw/swift #6

Closed bradleyfalzon closed 8 years ago

bradleyfalzon commented 8 years ago
panic: interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident

goroutine 1 [running]:
panic(0x65fba0, 0xc42caba7c0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/bradleyfalzon/closecheck.(*visitor).Visit(0xc42cab5890, 0x7f3b4da89d28, 0xc420ce8990, 0x1, 0xc4212334a0)
        /home/bradleyf/go/src/github.com/bradleyfalzon/closecheck/closecheck.go:235 +0x674
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7f3b4da89d28, 0xc420ce8990)
        /usr/local/go/src/go/ast/walk.go:52 +0x63
go/ast.walkStmtList(0x7b7400, 0xc42cab5890, 0xc420944420, 0x2, 0x2)
        /usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7e80, 0xc420f1c1e0)
        /usr/local/go/src/go/ast/walk.go:224 +0x1d48
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b80c0, 0xc420ce8a40)
        /usr/local/go/src/go/ast/walk.go:98 +0x2ffa
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7ec0, 0xc4207fc100)
        /usr/local/go/src/go/ast/walk.go:136 +0x11f5
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7f3b4da89f68, 0xc420ce8a50)
        /usr/local/go/src/go/ast/walk.go:213 +0x2054
go/ast.walkStmtList(0x7b7400, 0xc42cab5890, 0xc420285580, 0x8, 0x8)
        /usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7e80, 0xc420f1c840)
        /usr/local/go/src/go/ast/walk.go:224 +0x1d48
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7f3b4ddac220, 0xc4207fc340)
        /usr/local/go/src/go/ast/walk.go:231 +0x1f1a
go/ast.walkStmtList(0x7b7400, 0xc42cab5890, 0xc4219c6600, 0xc, 0x10)
        /usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b7e80, 0xc420f1ca80)
        /usr/local/go/src/go/ast/walk.go:224 +0x1d48
go/ast.Walk(0x7b7400, 0xc42cab5890, 0x7b8080, 0xc420f1cab0)
        /usr/local/go/src/go/ast/walk.go:344 +0xf03
github.com/bradleyfalzon/closecheck.Check(0xc420675000, 0xc4202404d0, 0xc42aba1eb8, 0x0, 0x1)
        /home/bradleyf/go/src/github.com/bradleyfalzon/closecheck/closecheck.go:37 +0x1a3

Code:

233                 if interfaceCloses(iface) {
234                     // Function's argument requires an io.Closer, it will likely close it
235                     argIdent := fun.Args[i].(*ast.Ident)
236                     if argIdent != nil {
237                         v.addClosed(v.pi.ObjectOf(argIdent).Pos())
238                     }
239                 }

Offending line:

 314             checkClose(resp.Body, &err)

argIdent probably just needs to be swapped around for exprDef function.