alias to fully qualified symbol gives error, but when module is also a symbol
Adam D. Ruppe
destructionator at gmail.com
Sun May 5 18:07:10 UTC 2019
On Sunday, 5 May 2019 at 15:22:31 UTC, Dennis wrote:
> I was trying to rename an imported `sqrt` (wrongly), but I
> stumbled upon this weird behavior:
> ```
> void main() {
> import core.stdc.math: sqrtf, sqrt;
> alias sqrtd = core.stdc.math.sqrt;
> auto a = sqrtd(1);
> }
> ```
> onlineapp.d(3): Error: undefined identifier core.stdc.math.sqrt
You didn't actually import the name `core` there, only the
specific symbols `sqrtf` and `sqrt`, which are now considered
direct children of your scope. So it doesn't know where to begin
with that fully qualified name - it doesn't know what `core` is.
So this is working as designed by the module and name lookup
rules.
The std.stdio one is supposed to be an error; the old buggy
behavior was to bypass the private import in these cases and that
is why it is deprecated pending changes.
More information about the Digitalmars-d-learn
mailing list