D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5959 - Return by reference with nested function should be allowed
Summary: Return by reference with nested function should be allowed
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
: 2509 (view as issue list)
Depends on:
Blocks:
 
Reported: 2011-05-08 12:06 UTC by Kenji Hara
Modified: 2011-09-24 05:36 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2011-05-08 12:06:04 UTC
Define nested ref function is not allowed with current dmd, but should be.
----
int n;
void main()
{
    ref int f(){ return n; }            // NG
//  nothrow ref int f(){ return n; }    // OK
//  auto ref int f(){ return n; }       // OK
    f() = 1;
    assert(n == 1);
----

See parse.c, calling route parseDeclDefs -> parseDeclaration changed with dmd 2.020(Fixing issue 2345), but did not changed parseStatement -> parseDeclaration from git brame.

It seems to me that this is a parser problem.
Comment 2 yebblies 2011-06-06 21:28:24 UTC
*** Issue 2509 has been marked as a duplicate of this issue. ***
Comment 3 Kenji Hara 2011-09-24 05:36:01 UTC
Already fixed, but not marked.