Why is compilation failing with this selective import?
Timon Gehr
timon.gehr at gmx.ch
Sat Dec 21 13:06:05 PST 2013
On 12/21/2013 09:56 PM, Nick Hamann wrote:
> I'm not sure if this is a bug or if I'm doing something wrong.
>
> Compilation succeeds and the program runs successfully with this code:
>
> import std.stdio;
> import std.conv : to;
> void main() {
> auto x = std.conv.to!double("7.3");
> writeln(x - 2.2);
> }
> ...
The first import seems to introduce the identifier 'std' (+ more). The
second import seems to introduce 'conv' into the scope of 'std'.
>
> However, when I change the first line to "import std.stdio : writeln;",
> I instead get:
>
> : dmd main.d
> main.d(5): Error: undefined identifier std
> ...
Now it does not introduce the identifier 'std'.
>
> I'm running DMD 2.064 on 64-bit Arch Linux.
This part of the language is not specified too well. It cannot hurt to
report this though. The current behaviour is non-modular, as which
modules are available depends on which modules you imported transitively.
More information about the Digitalmars-d-learn
mailing list