Thread overview
[Issue 7559] New: Nested function error without -inline
Jun 10, 2013
Denis Shelomovskij
February 21, 2012
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


--- Comment #0 from bearophile_hugs@eml.cc 2012-02-21 14:16:16 PST ---
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: -------
March 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7559



--- Comment #1 from bearophile_hugs@eml.cc 2013-03-01 04:40:57 PST ---
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: -------
March 01, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7559



--- Comment #2 from bearophile_hugs@eml.cc 2013-03-01 04:43:02 PST ---
(In reply to comment #1)
> 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: -------
June 10, 2013
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


--- Comment #3 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-06-10 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: -------