digitalmars.D.bugs - [Issue 9175] New: std.algorithm.remove!(predicate) problems
- d-bugmail puremagic.com (45/45) Dec 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9175
http://d.puremagic.com/issues/show_bug.cgi?id=9175
           Summary: std.algorithm.remove!(predicate) problems
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc
This works correctly:
import std.algorithm;
void main() {
    auto array = [40, 20, 10, 30];
    array = remove!"a <= 20"(array); // OK
    assert(array == [40, 30]);
}
This doesn't compile:
import std.algorithm;
void main() {
    auto array = [40, 20, 10, 30];
    auto p = (int x) => x <= 20;
    array = remove!p(array); // Error.
    assert(array == [40, 30]);
}
DMD 2.061alpha gives:
test.d(5): Error: variable p cannot be read at compile time
While a module-level function:
import std.algorithm;
bool p(int x) { return x <= 20; }
void main() {
    auto array = [40, 20, 10, 30];
    array = remove!p(array);
    assert(array == [40, 30]);
}
DMD gives:
...\dmd2\src\phobos\std\algorithm.d(6843): Error: not a property p
...\dmd2\src\phobos\std\algorithm.d(6949): Error: not a property p
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
 Dec 17 2012








 
  
  
  d-bugmail puremagic.com
 d-bugmail puremagic.com