Fails to identify defers in nested BlockStmt
dennisfischer opened this issue · comments
Dennis Fischer commented
Defers in nested BlockStmt
are not detected.
package main
import (
"fmt"
)
func main() {
for i := 0; i < 5; i++ {
defer fmt.Println("Hello, playground")
{
defer fmt.Println("Hello, playground") //Not detected
}
fmt.Println(i)
}
}
Bug is in
Lines 42 to 50 in adb0f52
Instead of looking into the BlockStmt
of the for loop all child elements have to be checked. I haven't worked much with ast
package, but I'd assume that you'd need another walker+visitor here.
Garrett Squire commented
Thanks for this, I had totally overlooked those types of statements and expressions initially. I believe there is a better way than trying to account for all nodes that can contain defer
statements so I will have to take a further look.