Bug 8447 – Self importing is allowed?

Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-26T13:59:00Z
Last change time
2012-12-22T13:13:23Z
Assigned to
nobody
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2012-07-26T13:59:15Z
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 by andrej.mitrovich — 2012-10-04T20:29:10Z
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 by dmitry.olsh — 2012-12-22T13:13:23Z
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.