Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 14834 - dirEntries with mask stopped working with "-inline …
…-debug"
- Loading branch information
Showing
3 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module link14834a; | ||
|
||
struct DirIterator | ||
{ | ||
int i = 1; | ||
|
||
@property bool empty() { return i == 0; } | ||
@property int front() { return 10; } | ||
void popFront() { --i; } | ||
} | ||
|
||
auto dirEntries(string path) | ||
{ | ||
bool f(int x) | ||
{ | ||
assert(path == "."); // should pass | ||
return true; | ||
} | ||
return filter!f(DirIterator()); | ||
} | ||
|
||
template filter(alias pred) | ||
{ | ||
auto filter(R)(R range) | ||
{ | ||
return FilterResult!(pred, R)(range); | ||
} | ||
} | ||
|
||
struct FilterResult(alias pred, R) | ||
{ | ||
R input; | ||
|
||
this(R r) | ||
{ | ||
input = r; | ||
while (!input.empty && !pred(input.front)) | ||
{ | ||
input.popFront(); | ||
} | ||
} | ||
|
||
@property bool empty() { return input.empty; } | ||
|
||
@property auto ref front() | ||
{ | ||
return input.front; | ||
} | ||
|
||
void popFront() | ||
{ | ||
do | ||
{ | ||
input.popFront(); | ||
} while (!input.empty && !pred(input.front)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import link14834a; | ||
|
||
void main() | ||
{ | ||
foreach (n; dirEntries(".")) | ||
{ | ||
assert(n == 10); | ||
} | ||
} |