Bug 3507 – [module] Flag unused imports to avoid unnecessary dependencies
Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2009-11-13T17:06:47Z
Last change time
2022-12-19T15:13:36Z
Keywords
bootcamp, diagnostic
Assigned to
No Owner
Creator
Leandro Lucarella
Comments
Comment #0 by leandro.lucarella — 2009-11-13T17:06:47Z
Dependencies makes compile time increase in large projects and have other bad impact in the code. An import might even execute code (module ctors), which can make the program slower at *run-time* unnecessarily if the module is not really used.
I think unused import should trigger *at least* an optional warning (with -w or something) to aid the programmer in detecting unused modules. A way to tell the compiler that an unused module is OK should be provided (in case we need the module ctor to run), a possible syntax is a special renamed import:
import void = foo.bar.baz;
A special selective import can do the job too:
import foo.bar.baz: void;
Comment #1 by andrei — 2016-10-14T01:20:50Z
I'm assigning this to bootcamp although it's a large-ish project, probably appropriate for a separate tool.
Comment #2 by razvan.nitu1305 — 2022-12-19T15:13:36Z
Yes, this is a perfect fit for dmd as a library. This is not going to make it in the compiler reference implementation.