On Sat, Jun 25, 2016 at 12:34 PM, Val <delepl...@gmail.com> wrote: > Hello > It seems that this code doesn't compile : > > func main() { > var err error > err = f() > } > > prog.go:8: err declared and not used > > > but this one does : > > func main() { > var err error > g := func() { > err = f() > } > g() > } > > Is the function binding regarded as a "use"? Or does escape analysis decide > to not check too deep about never-read variables? > > Whether expected or not, I supposed this compiler behavior won't change, > because of the Go1 compatibility promise.
While the rest of this thread gives something of an explanation, I think this is a bug, and I think it could be fixed in a future release. This is https://golang.org/issue/3059. The gccgo compiler does give an error for this code. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.