Thread overview
[Issue 17194] [scope] Fwd reference error with nested struct
Jul 14, 2017
Elie Morisse
Jul 15, 2017
Vladimir Panteleev
Aug 31, 2017
Walter Bright
Jan 09, 2018
Mike Franklin
Dec 17, 2022
Iain Buclaw
July 14, 2017
https://issues.dlang.org/show_bug.cgi?id=17194

Elie Morisse <syniurge@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |syniurge@gmail.com
           Hardware|x86_64                      |All
                 OS|Windows                     |All

--- Comment #1 from Elie Morisse <syniurge@gmail.com> ---
It's not specific to nested classes:

struct S {
    S2 a;
}

struct S2 {
    void foo(scope S s) { }
}

=> Error: struct S no size because of forward reference

Kinda related: issue 17548 was another bogus forward ref error originating from the same TypeStruct.hasPointers call in TypeFuntion.semantic (but as I understand it that call isn't the actual problem).

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17194

--- Comment #2 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Elle's example stopped working after https://github.com/dlang/dmd/pull/5897 but I don't know enough about scope whether know if this can be marked as a regression.

--
August 31, 2017
https://issues.dlang.org/show_bug.cgi?id=17194

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
This is a bit of a hopeless circular tangle. 'scope' is ignored if the type has no pointers. So S is checked for pointers. S.a is of type S2, which then must be checked for pointers. Checking S2 for pointers means evaluating each member to see if it is a field, which gets us back to looking at the 'scope'.

Not sure if this is reasonably fixable.

--
August 31, 2017
https://issues.dlang.org/show_bug.cgi?id=17194

--- Comment #4 from radu.racariu@gmail.com ---
I think the original description is different than Elie's example.

For one, the argument is sent by ref - the issue I was describing is related to the interaction of 'scope' and 'ref'.

I expected that 'scope ref V' be the same as 'scope V*'

--
November 06, 2017
https://issues.dlang.org/show_bug.cgi?id=17194

--- Comment #5 from radu.racariu@gmail.com ---
Just to point that "scope" is to blame here, removing "scope" from the inner stuct ctor like:

+++++++++++++++++++
struct V
{
    W w;

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

void main()
{
        V v;
}
+++++++++++++++++++

compiles without errors.

--
January 09, 2018
https://issues.dlang.org/show_bug.cgi?id=17194

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=18216

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=17194

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

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

--- Comment #6 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19235

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--