Bug 9996 – Outer variable in nested function cannot be accessed. (-inline)
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2013-04-26T09:56:00Z
Last change time
2013-06-10T05:43:09Z
Assigned to
nobody
Creator
html
Comments
Comment #0 by html — 2013-04-26T09:56:17Z
DMD 2.062, x86/Linux
test.d:
------------------------------------------------------------
import std.algorithm;
import std.array;
import std.string;
string[] arr = ["param"];
void main()
{
bool b;
string i(string n) { return n ~ (b ? "b" : "a"); }
arr.map!i().join(", ");
}
------------------------------------------------------------
dmd -inline test.d
------------------------------------------------------------
test.d(10): Error: function D main is a nested function and cannot be accessed from std.array.join!(MapResult!(i, string[]), string).join
test.d(10): Error: function D main is a nested function and cannot be accessed from std.array.join!(MapResult!(i, string[]), string).join
test.d(10): Error: function D main is a nested function and cannot be accessed from std.array.join!(MapResult!(i, string[]), string).join
Comment #1 by bearophile_hugs — 2013-04-26T12:16:11Z
I think this is a dupe.
Comment #2 by verylonglogin.reg — 2013-06-10T05:43:09Z
Same test (except `join` is used instead of `array`) as in Issue 4841 description.
*** This issue has been marked as a duplicate of issue 4841 ***