Closed SMLsk closed 2 years ago
Hi. The first case is possibly not ineffectual because the analyzer has no idea what the call to err.Error()
might do; it might capture the address of err
and store it for later use, making the next assignment effectual.
Of course, we know that this doesn't happen because we know how errors.New
and err.Error
work. But ineffassign doesn't look at types or inter-function data flow.
Thanks!
ineffassign version: last version available go version: go1.18.2
I thought err = errors.New("2") and err2 = errors.New("2") would report the ineffectual assignment, but actually only the second case will report.