www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7559] New: Nested function error without -inline

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

           Summary: Nested function error without -inline
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This may be related to Issue 4841. But here the inaccessible nested function
error appears even without "-inline", so maybe the causes are different:


import std.algorithm: all;
bool isOdd(int x) { return x % 2 != 0; }
void main() {
    auto data = [1, 3, 5];
    assert(all!isOdd(data)); // OK
    assert(all!(x => x % 2)(data)); // error
}


DMD 2.059head gives:

...\dmd2\src\phobos\std\functional.d(279): Error: function
test.main.not!(__lambda2).not!(int).not is a nested function and cannot be
accessed from std.algorithm.find!(not,int[]).find


I'd also like to receive an error in my program code, at line 6.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 21 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7559




import std.array: array;
import std.algorithm: map;
void main() {
    int[] foo;
    auto r1 = map!(i => foo[0])([0]);
    auto r2 = array(r1);
}


Gives:

temp.d(5): Error: function D main is a nested function and cannot be accessed
from std.array.array!(MapResult!(__lambda2, int[])).array

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





 import std.array: array;
 import std.algorithm: map;
 void main() {
     int[] foo;
     auto r1 = map!(i => foo[0])([0]);
     auto r2 = array(r1);
 }
 
 
 Gives:
 
 temp.d(5): Error: function D main is a nested function and cannot be accessed
 from std.array.array!(MapResult!(__lambda2, int[])).array
Sorry, that does need -inline. Example moved to Issue 4841. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7559


Denis Shelomovskij <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |verylonglogin.reg gmail.com
         Resolution|                            |WORKSFORME



16:37:20 MSD ---
Original test passes now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 10 2013