Thread overview
[Issue 7129] New: Compiling certain nested structs with -inline causes error "*** is a nested function and cannot be accessed from ***"
Dec 18, 2011
Torarin
Dec 21, 2011
Don
Jan 26, 2013
Nils
Jun 10, 2013
Denis Shelomovskij
December 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7129

           Summary: Compiling certain nested structs with -inline causes
                    error "*** is a nested function and cannot be accessed
                    from ***"
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: torarind@gmail.com


--- Comment #0 from Torarin <torarind@gmail.com> 2011-12-18 15:27:19 PST ---
This regression was introduced with the 2.057 release.

I first hit the issue with code resembling the following:
---------------------------------------------------------
import std.stdio, std.algorithm;

void main() {
 writeln(filter!"a != 'r'"("Merry Christmas!"));
}
--------------------------------------------------------
Compiling with -inline gives:
/src/phobos/std/algorithm.d(1120): Error: function
std.algorithm.filter!("a != 'r'").filter!(string).filter is a nested
function and cannot be accessed from formatValue

This reduced test case gives a clue as to what is going on:
---------------------------------------------------------
auto fun()
{
 struct Result {
   this(int u) {}

   auto bar() {
       return Result(0);
   }
 }
 return Result();
}

void main() {
 auto t = fun();
 auto a = t.bar();
}
---------------------------------------------------------
Compiled with -inline:
t.d(7): Error: function t.fun is a nested function and cannot be
accessed from main

It seems what is happening is that bar is being inlined in main, but dmd doesn't know where to get the new fun.Result's context pointer from.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7129


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
           Severity|regression                  |normal


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-12-21 14:36:24 PST ---
This isn't a regression. The reduced test case behaved the same in 2.026, which was the first version that could compile 'auto' functions.

This is probably a duplicate of bug 4724 (which involves -inline).
Could also be a dup of bug 4286 or bug 4841 (which involves -inline, but uses
delegates and alias templates)
Bug 5941 seems to be simplest test case for this species of bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7129


Nils <nilsbossung@googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nilsbossung@googlemail.com


--- Comment #4 from Nils <nilsbossung@googlemail.com> 2013-01-26 01:33:38 PST ---
Can't reproduce with the original test case, but this version still fails:

auto fun()
{
 int i;
 struct Result {
   this(int u) {}

   auto bar() {
       i = 42;
   }
 }
 return Result();
}

void main() {
 auto t = fun();
 t.bar();
}

-- 
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=7129


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

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


--- Comment #5 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-06-10 16:46:20 MSD ---
Mark it as a duplicate and add failing test from Comment 4 to Issue 4841.

*** This issue has been marked as a duplicate of issue 4841 ***

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