[Issue 17194] New: [scope] Fwd reference error with nested struct

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Feb 16 23:21:16 PST 2017


https://issues.dlang.org/show_bug.cgi?id=17194

          Issue ID: 17194
           Summary: [scope] Fwd reference error with nested struct
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: radu.racariu at gmail.com

The following:

struct V
{
    W w;

    struct W
    {
        this(scope ref V v)
        {
            this.v = &v;
        }
        V* v;
    }
}

void main()
{
    V v;
}

Produces this:

Error: struct app.V no size because of forward reference

Expecting: to compile.

Error is also not pointing the line number the issue was suppose to be.

Work around:

1. Removing the "scope" keyword makes the program compile.

2. Changing W ctor signature to: 

this(scope V* v)
{
 this.v = v;
}

also makes it work.

Compiled with dmd 2.073.1 on win32

--


More information about the Digitalmars-d-bugs mailing list