[Issue 9175] New: std.algorithm.remove!(predicate) problems

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 17 21:56:37 PST 2012


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 at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-12-17 21:56:35 PST ---
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: -------


More information about the Digitalmars-d-bugs mailing list