www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7129] New: Compiling certain nested structs with -inline causes error "*** is a nested function and cannot be accessed from ***"

reply d-bugmail puremagic.com writes:
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



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: -------
Dec 18 2011
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Dec 21 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7129


Nils <nilsbossung googlemail.com> changed:

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



---
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: -------
Jan 26 2013
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jun 10 2013