Bug 18039 – Deprecation: symbol is not visible from module when accessed in a with () of something that imports it

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-12-06T11:59:12Z
Last change time
2018-02-14T13:12:31Z
Assigned to
No Owner
Creator
JR

Comments

Comment #0 by zorael — 2017-12-06T11:59:12Z
Arch/Manjaro 64-bit, dmd 2.0.77.0 app.d --------------------- import third; void main() { import std.stdio; import second : Second; Second second; with (second) { writeln(Third.stringof); } } second.d --------------------- module second; struct Second { import third : Third; } third.d --------------------- module third; struct Third {} source/app.d(11,17): Deprecation: second.Second.Third is not visible from module app The top-level `import third` in app.d is ignored and it only complains about implicitly (and erroneously?) inheriting the import from `with (second)`. You can only silence it by moving the import out of Second (eg. to module-level), or by placing a new `import third` inside the with ().
Comment #1 by razvan.nitu1305 — 2018-02-14T13:09:54Z
The compiler does the right thing here. According to the spec: https://dlang.org/spec/statement.html#WithStatement , the symbol resolution is done by first searching the members of second. It then finds the selective import and thinks that an illegal access is being made. That is correct and in this case it is the user's job to disambiguate : (1) writeln(third.Third.stringof) (2) making the import in Struct second public (3) making the import in Struct second non-selective (e.g. import third) Closing as invalid.