Re: [go-nuts] Unused var written in closure

2016-07-04 Thread Ian Lance Taylor
On Sun, Jul 3, 2016 at 11:57 PM, Gordon Klaus wrote: > Ok, so strictly speaking there is no bug. Both gc and gccgo are > spec-compliant; gc just opts not to raise an error in this case. (One might > say it is a bug that gc doesn't raise the error consistently, but I don't > think the spec says a

Re: [go-nuts] Unused var written in closure

2016-07-03 Thread Gordon Klaus
Ok, so strictly speaking there is no bug. Both gc and gccgo are spec-compliant; gc just opts not to raise an error in this case. (One might say it is a bug that gc doesn't raise the error consistently, but I don't think the spec says anything about consistency, only optionality.) In any case, I

Re: [go-nuts] Unused var written in closure

2016-07-03 Thread Ian Lance Taylor
On Sat, Jul 2, 2016 at 2:20 AM, wrote: > More generally, this is https://github.com/golang/go/issues/10989. > > Such ineffectual assignments can be detected using > https://github.com/gordonklaus/ineffassign. > > An analysis showed that only a small fraction of such were bugs, making the > backwa

Re: [go-nuts] Unused var written in closure

2016-07-02 Thread gordon . klaus
More generally, this is https://github.com/golang/go/issues/10989. Such ineffectual assignments can be detected using https://github.com/gordonklaus/ineffassign. An analysis showed that only a small fraction of such were bugs, making the backwards-incompatible language change not worthwhile. @

Re: [go-nuts] Unused var written in closure

2016-06-26 Thread Ian Lance Taylor
On Sat, Jun 25, 2016 at 12:34 PM, Val 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(

[go-nuts] Unused var written in closure

2016-06-25 Thread Val
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() { er