Summary: Using inner struct which references nested function in
                    a no-attribute or auto-return member function causes
                    "nested function cannot be accessed" error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 2011-05-07 00:11:05 PDT ---
May or may not be the same as issue 5939. Happens at least since 2.042.

Test case:
auto f() {
    static int h(int x) pure nothrow @safe { return x*x*x-x*x; }
    struct S {
        int get() {
            return h(8);
    return S.init;
void main() {
    typeof(f()) z;
    assert(z.get == 448);
    assert(z.get == 448);
x.d(11): Error: function x.f is a nested function and cannot be accessed from

The bug will appear only when the 'get' function
 - is an auto-return function (e.g. '@property auto get()')
 - or has no attributes at all (e.g. 'int get()')

The bug is gone when you supply at least one attribute to 'get', e.g. '@safe
int get()'.

I don't know if it is a reject-valid or accept-invalid.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to