digitalmars.D.bugs - [Issue 10437] New: Warnings for unused private imports
- d-bugmail puremagic.com (30/30) Jun 21 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10437
- d-bugmail puremagic.com (15/15) Jun 21 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10437
- d-bugmail puremagic.com (12/12) Jun 21 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10437
- d-bugmail puremagic.com (17/31) Jun 21 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10437
- d-bugmail puremagic.com (16/31) Jun 21 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10437
http://d.puremagic.com/issues/show_bug.cgi?id=10437 Summary: Warnings for unused private imports Product: D Version: future Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: qznc web.de The compiler should output warnings, if the source code contains imports, which are not used and can be removed. Example: For debugging the following private imports were used, but now the module does not contain any writeln or text call anymore, but parse is used. private import std.stdio; private import std.conv: text, parse; The compiler should print warnings like: foo.d(3): Warning: unused private import std.stdio; should be deleted foo.d(4): Warning: unused private import std.conv: text; should be deleted This has been discussed together with other unused stuff, but there seems to be no conclusion in the thread. http://forum.dlang.org/thread/i4luk9$2rdg$1 digitalmars.com This enhancement helps to keep a code base clean. Less imports might reduce compile times. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 21 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10437 What will occur with template function? import std.conv : to; T convert(T, S)(S src) { return to!T(src); } void main() {} // template function convert is not instantiated. In this case, imported std.conv is unused then compiler might warn it. Is this right? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 21 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10437 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 06:16:52 PDT --- This warning should at best be a separate switch (or we should add customization to the -w switch like we have with -transition). I dislike chatty compilers which complain about every single little nuisance. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 21 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10437What will occur with template function? import std.conv : to; T convert(T, S)(S src) { return to!T(src); } void main() {} // template function convert is not instantiated. In this case, imported std.conv is unused then compiler might warn it. Is this right?I think the question is misleading. The actual question is how clever the analysis is. Call-graph information provides a similar scenario: import std.stdio; void foo() { writeln("foo"); } void main () {} // foo is never called In such scenarios, deleting a statement might declare a whole chain (actually DAG) of (template or normal) functions unused. It is a question of taste, if the user should be flooded with warnings in this case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 21 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10437I think the question is misleading. The actual question is how clever the analysis is. Call-graph information provides a similar scenario: import std.stdio; void foo() { writeln("foo"); } void main () {} // foo is never called In such scenarios, deleting a statement might declare a whole chain (actually DAG) of (template or normal) functions unused. It is a question of taste, if the user should be flooded with warnings in this case.It's impossible to do that strictly with templates. Let's try to show more suitable case. import std.conv; import std.stdio; auto call(string name, A...)(A args) { return mixin(name~"(args)"); } Until 'call' template function is instantiated, compiler cannot determine which import declaration is actually unused. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 21 2013