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 }
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 }
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ca6643e4c20100419e50c5500396aa3b8021f806 Add IntervalExp and fix parser, and disabled test for issue 6789 All of N-dimensional array operations are now translated to ArrayExp. But currently they are immediately translated to SliceExp, so have no effect.
2.065 exhibits the bug. 2.066 and 2.067 throw some AssertError. Since 2.068 the program prints "false" twice. Closing as WORKSFORME.