www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5753] New: Disallow map() of void function

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5753

           Summary: Disallow map() of void function
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This code compiles with no errors (DMD 2.052), but in my opinion it has to
raise a compile-time error, because map() must statically refuse functions that
return void:


import std.algorithm;
void foo() {}
void main() {
    int[] data = [1, 2, 3];
    map!((int i){ return foo(); })(data);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 19 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5753




A simpler example:


import std.algorithm;
void foo(int x) {}
void main() {
    int[] data = [1, 2, 3];
    map!foo(data);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 19 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5753


Pedro Rodrigues <pdfrodrigues gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pdfrodrigues gmail.com



12:17:15 PDT ---
I propose the following fix for this issue
https://github.com/pdfr/phobos/commit/67ff377318e7d392115d4565a8043f4a347a3c13

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 24 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5753




For Phobos devs: see also the comment about mixing up lazy evaluation with side
effects: http://d.puremagic.com/issues/show_bug.cgi?id=5804#c2

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