D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6520 - Problem with -inline with lazy arguments and inner functions
Summary: Problem with -inline with lazy arguments and inner functions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-08-17 07:47 UTC by bearophile_hugs
Modified: 2012-04-26 13:07 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-08-17 07:47:52 UTC
A reduced program:


int foo(int n, lazy int x) {
    int inner() {
        n--;
        return foo(n, inner());
    };
    return n <= 0 ? n : inner();
}
void main() {
    assert(foo(10, 1) == 0);
}



With DMD 2.055beta it compiles and runs correctly.

But compiling it with -inline DMD gives:

test.d(4): Error: delegate test.foo.inner.__dgliteral3 is a nested function and cannot be accessed from foo
Comment 1 SomeDude 2012-04-26 11:40:42 UTC
Compiles fine with -inline on 2.059 Win32
Comment 2 bearophile_hugs 2012-04-26 13:07:56 UTC
(In reply to comment #1)
> Compiles fine with -inline on 2.059 Win32

Thank you.