[PATCH 1/2] [D] Don't recursively look for a symbol in all imports of imported modules.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] [D] Don't recursively look for a symbol in all imports of imported modules.

Iain Buclaw
Consider the following pathological case:
---
module A;
import B, C;
---
module C;
import A;
---

When looking up a symbol in module 'B' from module 'A', although it
won't lead to infinite recursion, it will cause a to and fro to occur
between the two cyclic imports.  This get exponentially worse when
there are tens or hundreds of modules all importing each other.

Although there is a genuine case to recursively search imports from
foreign modules, this only makes sense in D for 'public' imports,
which would be expressed as:
---
module A;
import B;
---
module B;
public import C;  // All symbols in 'C' are available to any module
that imports 'B'
---

However there is no way to detect this as of today in DWARFv4.  Only
DW_TAG_imported_declarations get a DW_AT_accessibility attribute.
Though perhaps DW_AT_visibility would be more accurate because 'static
import' would be considered as qualified.

But I digress on matters outside the scope of this patch. :-)

Regards,
Iain.
---

dlang-searchimports.patch (1K) Download Attachment