D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3507 - [module] Flag unused imports to avoid unnecessary dependencies
Summary: [module] Flag unused imports to avoid unnecessary dependencies
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: bootcamp, diagnostic
Depends on:
Blocks:
 
Reported: 2009-11-13 17:06 UTC by Leandro Lucarella
Modified: 2022-12-19 15:13 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Leandro Lucarella 2009-11-13 17:06:47 UTC
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 Andrei Alexandrescu 2016-10-14 01:20:50 UTC
I'm assigning this to bootcamp although it's a large-ish project, probably appropriate for a separate tool.
Comment 2 RazvanN 2022-12-19 15:13:36 UTC
Yes, this is a perfect fit for dmd as a library. This is not going to make it in the compiler reference implementation.