Thread overview
class X has forward references
Jun 12
bauss
Jun 12
bauss
June 12
What could cause that error?

I cannot find anything in the documentation nor does the error message itself give much information.

I can't really give a good example, but I can tell as much as I have a few inheritances of classes using templates.

I just don't think that would be the issue.

When I try to make a minimized example it doesn't happen, so I'm going to assume it's either a function or a member or something in one of the inheritances that does it.

It would be really helpful if I knew what I was looking for, because it's thousands of lines of code I have to dig through with trial and error.
June 12
On 6/12/18 4:14 PM, bauss wrote:
> What could cause that error?
> 
> I cannot find anything in the documentation nor does the error message itself give much information.

A forward reference that can't be figured out by the compiler. This is one of the DMD front end's real weak spots.

> I can't really give a good example, but I can tell as much as I have a few inheritances of classes using templates.

Yes, I've had weird forward reference errors in the past, and the only way I've been able to solve them is to move stuff around.

> I just don't think that would be the issue.
> 
> When I try to make a minimized example it doesn't happen, so I'm going to assume it's either a function or a member or something in one of the inheritances that does it.
> 
> It would be really helpful if I knew what I was looking for, because it's thousands of lines of code I have to dig through with trial and error.

Have you tried dustmite?

I would think at least it should print the symbol it's not able to resolve.

-Steve
June 12
On Tuesday, 12 June 2018 at 20:30:22 UTC, Steven Schveighoffer wrote:
> On 6/12/18 4:14 PM, bauss wrote:
>> What could cause that error?
>> 
>> I cannot find anything in the documentation nor does the error message itself give much information.
>
> A forward reference that can't be figured out by the compiler. This is one of the DMD front end's real weak spots.
>
>> I can't really give a good example, but I can tell as much as I have a few inheritances of classes using templates.
>
> Yes, I've had weird forward reference errors in the past, and the only way I've been able to solve them is to move stuff around.
>
>> I just don't think that would be the issue.
>> 
>> When I try to make a minimized example it doesn't happen, so I'm going to assume it's either a function or a member or something in one of the inheritances that does it.
>> 
>> It would be really helpful if I knew what I was looking for, because it's thousands of lines of code I have to dig through with trial and error.
>
> Have you tried dustmite?
>
> I would think at least it should print the symbol it's not able to resolve.
>
> -Steve

Yeah I get the symbol that it cannot resolve.

I'm moving stuff around now and the error has disappeared.

Now I just have to fix all the errors related to moving stuff around.

Thanks though!
June 12
On 06/12/2018 01:14 PM, bauss wrote:
> What could cause that error?

Could be this point apparently during semantic analysis:


https://github.com/dlang/dmd/blob/4e35f945e3245467c7ae0abe60fc3ec896c8b45f/src/dmd/semantic2.d#L576

private extern(C++) final class Semantic2Visitor : Visitor
{
    // ...

    override void visit(AggregateDeclaration ad)
    {
        //printf("AggregateDeclaration::semantic2(%s) type = %s, errors = %d\n", ad.toChars(), ad.type.toChars(), ad.errors);
        if (!ad.members)
            return;

        if (ad._scope)
        {
            ad.error("has forward references");
            return;
        }

        // ...
    }
}

Does that mean that the scope pointer is already set when this AggregateDeclaration is being visited? If it's a bug, perhaps someone can think of a way of reproducing it.

Ali