Closed ianrose14 closed 6 years ago
example program:
package main import ( "log" ) func main() { out := func() (ok bool) { ok = true defer func() { if r := recover(); r != nil { log.Println("panic happened!") } }() panic("oh crud") return false }() log.Println(out) }
ineffassign prints: ineffectual assignment to ok
ineffassign
ineffectual assignment to ok
but if you remove that assignment (line 9), the program will print false instead of true
Thanks for the report. The tool does not correctly handle named results in the face of possible panics. A fix is forthcoming.
example program:
ineffassign
prints:ineffectual assignment to ok
but if you remove that assignment (line 9), the program will print false instead of true