www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10350] New: Valid code cannot be compiled with "-inline"

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

           Summary: Valid code cannot be compiled with "-inline"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: fengli gmail.com


--- Comment #0 from fengli gmail.com 2013-06-12 23:42:53 PDT ---
The following code compiles fine with the command "dmd test.d"

import std.array, std.algorithm, std.algorithm, std.string;
void main()
{
    int[string] s;
    auto a = join(map!(a=>format("%s %d", a, s[a]))(s.keys));
}

However, if I try to compile it with "dmd -inline test.d", I get 
this error message:

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

The above test was performed with DMD 2.063 on OSX.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 12 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10350


Joseph Rushton Wakeling <joseph.wakeling webdrake.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joseph.wakeling webdrake.ne
                   |                            |t


--- Comment #1 from Joseph Rushton Wakeling <joseph.wakeling webdrake.net>
2013-07-11 06:35:32 PDT ---
Interesting -- I have a similar problem when compiling a program using
schwartzSort with the -debug flag:

import std.algorithm, std.range;
void main()
{
        size_t[] x = [4, 9, 3, 2, 1, 10, 8, 5, 7, 6];
        size_t[] i = iota(x.length).array;
        schwartzSort!(a => x[a], "a < b")(i);
}

This compiles fine with dmd -inline but generates a similar error message when
dmd -debug is used:

/opt/dmd/include/d2/std/algorithm.d(9117): Error: delegate
schwartz.main.__lambda2!ulong.__lambda2 is a nested function and cannot be
accessed from schwartz.main.schwartzSort!(__lambda2, "a < b",
cast(SwapStrategy)0, ulong[]).__lambda1621!(ulong, ulong).__lambda1621
/opt/dmd/include/d2/std/algorithm.d(9117): Error: delegate
schwartz.main.__lambda2!ulong.__lambda2 is a nested function and cannot be
accessed from schwartz.main.schwartzSort!(__lambda2, "a < b",
cast(SwapStrategy)0, ulong[]).__lambda1621!(ulong, ulong).__lambda1621

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