Bug 17181 – Local imports in templates should be added to imported modules list of module that instantiated it

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-02-14T21:11:34Z
Last change time
2022-04-28T05:40:48Z
Assigned to
RazvanN
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=22651

Comments

Comment #0 by bugzilla — 2017-02-14T21:11:34Z
Given: module foo; import bar; int foo() { return bar.abc(1); } and: module bar; int abc()(int i) { import std.stdio; return i; } std.stdio should be added to foo's list of imported modules.
Comment #1 by andrei — 2017-02-14T21:15:49Z
Comment #2 by code — 2017-02-15T14:03:07Z
Just as a heads up, I'd expect having to deal with real-world breakage due to constructor cycles as a side effect of fixing this.
Comment #3 by razvan.nitu1305 — 2019-01-07T16:53:35Z
Does this bug have a visible manifestation? I can compile this code successfully. Can this be tested somehow? It's not obvious from the bug description what is the intended behavior.
Comment #4 by code — 2019-01-07T17:41:53Z
(In reply to RazvanN from comment #3) > Does this bug have a visible manifestation? If you check `ModuleInfo.importedModules` for `foo`, `std.stdio` wouldn't be there (or at least wasn't back then).
Comment #5 by razvan.nitu1305 — 2019-01-08T14:15:03Z
So, if I understand correctly, the idea here is that when a template is instantiated, the code generated for the template instantiation should be put in foo.o, right? Otherwise, why would it be in bar?
Comment #6 by razvan.nitu1305 — 2019-01-08T15:29:44Z