www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11308] New: Don't use Voldemort types for std.process output

http://d.puremagic.com/issues/show_bug.cgi?id=11308

           Summary: Don't use Voldemort types for std.process output
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com
                CC: k.hara.pg gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-10-20
13:02:41 PDT ---
-----
import std.process;

void main()
{
    auto res = executeShell("dmd");
    if (res.status) { }
    if (res.output) { }

    // ok, reuse variable
    res = executeShell("rdmd");
    if (res.status) { }
    if (res.output) { }

    // NG. Even though return types are the same
    res = execute(["dmd"]);
}
-----

$ dmd test.d
 Error: cannot implicitly convert expression (execute(["dmd"], null,
cast(Config)0, 4294967295u)) of type ProcessOutput to ProcessOutput
The voldemort situation makes reusing variables impossible, even though the same exact type is returned (the only difference being the template is instantiated differently). As a reduced test-case: ----- auto foo(T)() { struct S { int x; } return S(1); } void main() { auto res = foo!int(); res = foo!int(); // NG: Error: cannot implicitly convert expression (foo()) of type S to S res = foo!double(); } ----- This is a borderline compiler bug. Kenji I've CC'ed you to see if this is something worth thinking about, could the compiler be smart enough to deduce that the two Voldemort types are really the same type? But even so, using `auto` for these process functions makes it very hard to figure out what the return type of a function is. We might as well use a proper non-voldemort struct. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 20 2013