www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11794] New: Compilation fails with a certain selective import

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11794

           Summary: Compilation fails with a certain selective import
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: nick wabbo.org


--- Comment #0 from nick wabbo.org 2013-12-21 15:52:44 PST ---
I'm not sure whether this is a problem with my code or a bug. The following
code compiles and executes as expected:

import std.stdio;
import std.conv : to;
void main() {
    auto x = std.conv.to!double("7.3");
    writeln(x - 2.2);
}


However, changing the first line to this:

import std.stdio : writeln;

results in the following error:


: dmd main.d
main.d(5): Error: undefined identifier std



This is with DMD 2.064.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 21 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11794



--- Comment #1 from nick wabbo.org 2013-12-21 15:55:30 PST ---
I apologize, the code I pasted is somewhat confusing. There should be a blank
line after the imports and before the main() declaration, so that the error
message is referring to the "auto x = std.conv.to!double("7.3");" line.



import std.stdio;
import std.conv : to;

void main() {
    auto x = std.conv.to!double("7.3");
    writeln(x - 2.2);
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 21 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11794


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-12-22
01:18:03 PST ---
(In reply to comment #0)
 I'm not sure whether this is a problem with my code or a bug.
I think it's a duplicate report, I've seen this before. When you use selective imports you cannot use the fully qualified name of the symbol, e.g.: ----- import std.stdio : writeln; void main() { std.stdio.writeln("foo"); // error } ----- This is by design. However, for some reason "std.conv" is available when you import std.stdio, but I think this is a dupe report. Here's the accepts-invalid test case: ----- import std.stdio; void main() { std.conv.to!int("1"); // this should be an error.. } ----- -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 22 2013