October 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6789

           Summary: std.stdio.File + ternary = bug
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dsimcha@yahoo.com


--- Comment #0 from David Simcha <dsimcha@yahoo.com> 2011-10-07 16:48:04 PDT ---
I haven't been able to reduce this far enough to know for sure whether this is a DMD or Phobos bug, but the following ternary operator expression should work:

import std.stdio;

void main() {
    bool foo;
    auto lines = (foo ? File("test.d") : File("test.d")).byLine();
    writeln(lines.empty);  // true

    auto handle = File("test.d");
    lines = handle.byLine();
    writeln(lines.empty);  // false
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6789


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-23 03:58:17 PDT ---
This is not a bug. The test actually works if the file "test.d" exists
beforehand.
If it doesn't exist, one must open the file in write mode. By default, the file
is open in read mode.
This works as intended.

import std.stdio;

void main() {
    bool foo;
    auto lines = (foo ? File("test.d", "w") : File("test.d", "w")).byLine();
    writeln(lines.empty);  // true

    auto handle = File("test.d");
    lines = handle.byLine();
    writeln(lines.empty);  // false
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------