Bug 11308 – Don't use Voldemort types for std.process output

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-20T13:02:00Z
Last change time
2014-04-18T10:48:59Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-10-20T13:02:41Z
----- 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.
Comment #1 by monarchdodra — 2014-04-17T16:24:55Z
Comment #2 by github-bugzilla — 2014-04-18T10:48:58Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f07abda274275b7b629e6aebfcd309449707d80e Fix Issue 11308 - Don't use Voldemort types for std.process output So that the return type of `execute` and `executeShell` are compatible. https://github.com/D-Programming-Language/phobos/commit/9579b42cc5058e7071c8af88d97a78fbb8f4546f Merge pull request #2085 from monarchdodra/processRet Fix Issue 11308 - Don't use Voldemort types for std.process output