Bug 7559 – Nested function error without -inline

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-02-21T14:16:00Z
Last change time
2013-06-10T05:37:20Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-02-21T14:16:16Z
This may be related to Issue 4841. But here the inaccessible nested function error appears even without "-inline", so maybe the causes are different: import std.algorithm: all; bool isOdd(int x) { return x % 2 != 0; } void main() { auto data = [1, 3, 5]; assert(all!isOdd(data)); // OK assert(all!(x => x % 2)(data)); // error } DMD 2.059head gives: ...\dmd2\src\phobos\std\functional.d(279): Error: function test.main.not!(__lambda2).not!(int).not is a nested function and cannot be accessed from std.algorithm.find!(not,int[]).find I'd also like to receive an error in my program code, at line 6.
Comment #1 by bearophile_hugs — 2013-03-01T04:40:57Z
import std.array: array; import std.algorithm: map; void main() { int[] foo; auto r1 = map!(i => foo[0])([0]); auto r2 = array(r1); } Gives: temp.d(5): Error: function D main is a nested function and cannot be accessed from std.array.array!(MapResult!(__lambda2, int[])).array
Comment #2 by bearophile_hugs — 2013-03-01T04:43:02Z
(In reply to comment #1) > import std.array: array; > import std.algorithm: map; > void main() { > int[] foo; > auto r1 = map!(i => foo[0])([0]); > auto r2 = array(r1); > } > > > Gives: > > temp.d(5): Error: function D main is a nested function and cannot be accessed > from std.array.array!(MapResult!(__lambda2, int[])).array Sorry, that does need -inline. Example moved to Issue 4841.
Comment #3 by verylonglogin.reg — 2013-06-10T05:37:20Z
Original test passes now.