Bug 10350 – Valid code cannot be compiled with "-inline"

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-12T23:42:00Z
Last change time
2013-11-21T04:08:55Z
Assigned to
nobody
Creator
fengli

Comments

Comment #0 by fengli — 2013-06-12T23:42:53Z
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.
Comment #1 by joseph.wakeling — 2013-07-11T06:35:32Z
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
Comment #2 by yebblies — 2013-11-21T04:08:55Z
Works fine, both of them.