Name lookups in D
kdevel
kdevel at vogtner.de
Sun Dec 13 21:54:05 UTC 2020
On Friday, 11 December 2020 at 01:38:44 UTC, Adam D. Ruppe wrote:
[...]
> With a normal import, the module name is the only thing
> actually added to the scope. Everything in that module is found
> by walking the import chains after not finding it locally
> (unless you use `static import` which means it does not add it
> to the chain).
Just 'implemented' the following bug:
~~~
import std.conv;
class B {
}
class D : B {
string text;
}
void main ()
{
B b = new D;
string s = b.text;
}
~~~
Due to UFCS std.conv.text grabs the object. Only a `static import`
or a selective import would reveal the problem during compile
time.
More information about the Digitalmars-d
mailing list