D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8447 - Self importing is allowed?
Summary: Self importing is allowed?
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-26 13:59 UTC by Dmitry Olshansky
Modified: 2012-12-22 13:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dmitry Olshansky 2012-07-26 13:59:15 UTC
Program:

module huh;
import huh;

compiles alright.

However the same thing in a bigger project cased spurious forward references around std.conv.text. (Sorry failed to reduce.)

Shouldn't compiler just statically disallow self-importing ?
Comment 1 Andrej Mitrovic 2012-10-04 20:29:10 UTC
Phobos has a couple of these self-imports. They all seem to be in unittest blocks, which maybe makes copy-pasting samples to outside modules easier since you automatically get a free import statement included.

Maybe we should allow them in function/unittest scope, and disallow them in module scope. Or should we just ban them outright?

I'm running a test suite on a fix right now.
Comment 2 Dmitry Olshansky 2012-12-22 13:13:23 UTC
Going to close it for a moment as the codebase changed radically over time and I'm not 100% sure self-importing was the core cause.