June 10, 2011 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #10 from bearophile_hugs@eml.cc 2011-06-10 14:04:58 PDT --- (In reply to comment #9) > I would point out that if it is made an error to have unused local variables, function parameters must _not_ be included in it. That would be a major problem in cases where overridden functions don't use all of their parameters, but they have to have them because the base class' function does. Don't worry, warnings against "unused local variables" and "unused argument values" are meant to be two distinct features. Each of them needs a separate discussion and has to stand for its own. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2011 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies@gmail.com --- Comment #11 from yebblies <yebblies@gmail.com> 2011-06-10 23:53:26 PDT --- (In reply to comment #8) > This is accepts-invalid, not an enhancement request. > > http://www.digitalmars.com/d/1.0/function.html > "It is an error to declare a local variable that is never referred to." See: http://www.digitalmars.com/d/archives/digitalmars/D/bugs/2105.html http://www.digitalmars.com/d/archives/digitalmars/D/Re_Wish_Variable_Not_Used_Warning_73539.html It actually seems more likely that this is a bug in the spec, as I think Walter is against pretty much anything that requires flow analysis. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2011 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #12 from bearophile_hugs@eml.cc 2011-06-11 02:41:14 PDT --- (In reply to comment #11) > (In reply to comment #8) > > This is accepts-invalid, not an enhancement request. > > > > http://www.digitalmars.com/d/1.0/function.html > > "It is an error to declare a local variable that is never referred to." > > See: > http://www.digitalmars.com/d/archives/digitalmars/D/bugs/2105.html > http://www.digitalmars.com/d/archives/digitalmars/D/Re_Wish_Variable_Not_Used_Warning_73539.html > > It actually seems more likely that this is a bug in the spec, as I think Walter is against pretty much anything that requires flow analysis. In the beginning this was an enhancement request, now someone has made it a kind of error. But in the end the situation is the same. In most cases in well written code you don't want unused variables, and various experiments have shown that unused experiments are often associated with bugs. On the other hand lint tools in C that are able to spot such unused variables are seldom used, and several of the most used compilers do spot such unused variables today. So I conclude that I'd like the D compiler to spot them automatically for me. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2011 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #13 from Stewart Gordon <smjg@iname.com> 2011-06-11 06:30:32 PDT --- (In reply to comment #11) > It actually seems more likely that this is a bug in the spec, as I think Walter is against pretty much anything that requires flow analysis. What has this issue to do with flow analysis? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2011 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #14 from yebblies <yebblies@gmail.com> 2011-06-11 07:38:51 PDT --- (In reply to comment #13) > (In reply to comment #11) > > It actually seems more likely that this is a bug in the spec, as I think Walter is against pretty much anything that requires flow analysis. > > What has this issue to do with flow analysis? You're right! I'm still fairly sure I've seen Walter say no to this request somewhere. If I can find it I'll change the report to spec/enhancement. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2011 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #15 from Stewart Gordon <smjg@iname.com> 2011-06-11 08:21:48 PDT --- (In reply to comment #14) > I'm still fairly sure I've seen Walter say no to this request somewhere. If I can find it I'll change the report to spec/enhancement. This isn't an enhancement. That the compiler doesn't behave according to the spec is an outright bug. It might be a case of removing the statement from the spec. But - it won't stop people wanting the compiler to warn of an unused local variable, so this would remain valid albeit as an enhancement request - any clue of why Walter may have changed his mind about this? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 11, 2011 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #16 from yebblies <yebblies@gmail.com> 2011-06-11 08:38:50 PDT --- (In reply to comment #15) > (In reply to comment #14) > > I'm still fairly sure I've seen Walter say no to this request somewhere. If I can find it I'll change the report to spec/enhancement. > > This isn't an enhancement. That the compiler doesn't behave according to the spec is an outright bug. > > It might be a case of removing the statement from the spec. But > - it won't stop people wanting the compiler to warn of an unused local > variable, so this would remain valid albeit as an enhancement request > - any clue of why Walter may have changed his mind about this? All I can find is http://www.digitalmars.com/d/archives/digitalmars/D/Unused_variables_better_as_error_or_warning_115751.html#N115794 and http://www.digitalmars.com/d/archives/c++/command-line/282.html (from 2003!) If the spec is wrong, then this _is_ a valid enhancement _and_ a valid spec bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 02, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 Marco Leise <Marco.Leise@gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |Marco.Leise@gmx.de --- Comment #17 from Marco Leise <Marco.Leise@gmx.de> 2012-02-02 06:56:03 PST --- (In reply to comment #9) > I would point out that if it is made an error to have unused local variables, function parameters must _not_ be included in it. That would be a major problem in cases where overridden functions don't use all of their parameters, but they have to have them because the base class' function does. In languages where you cannot omit the name of the parameter it is a problem. In D you just leave the parameter name away and this problem is solved + it becomes evident from looking at the method, that it doesn't use a certain parameter. That would make a nice coding standard as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 06, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 timon.gehr@gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timon.gehr@gmx.ch --- Comment #18 from timon.gehr@gmx.ch 2012-02-05 17:12:23 PST --- Whether or not a parameter is used is unrelated to whether or not it has a name. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2012 [Issue 3960] Unused local variables not reported | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=3960 --- Comment #19 from Marco Leise <Marco.Leise@gmx.de> 2012-02-09 01:15:45 PST --- (In reply to comment #18) > Whether or not a parameter is used is unrelated to whether or not it has a name. You can't use an unnamed parameter, or can you? What I wanted to hint at is this: interface I { void foo(int a, int b); } class C { int sum_a; void foo(int a, int b) { sum_a += a; } } This is a typical situation I face in Java code. The IDE (Eclipse in this case) would warn me, that I don't use parameter 'b'. Now my code is perfectly fine and my implementation of foo() doesn't depend on the value of 'b' to do its job. The better solution is to write: void foo(int a, int) { sum_a += a; } Now the interface is happy, as is the compiler check, because we made it clear, that we intended to ignore 'b'. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation