D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7426 - Inner struct "no size yet for forward reference" when using .tupleof inside it.
Summary: Inner struct "no size yet for forward reference" when using .tupleof inside it.
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: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-02-02 12:06 UTC by kennytm
Modified: 2012-02-08 08:49 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 kennytm 2012-02-02 12:06:40 UTC
Test case:

------------------
struct S7426
{
    static struct Inner
    {
        int x;
        alias typeof(Inner.tupleof) T;
    }
}
------------------

Compile with 'dmd -c test7426.d', expecting to pass silently, but fails with:

test7426.d(4): Error: struct test7426.S7426.Inner no size yet for forward reference

The regression is introduced in commit f2635c912999f819f6f99f46373a768df7f5abfa when fixing bug 7190.
Comment 1 kennytm 2012-02-05 00:47:28 UTC
Pull #696.

https://github.com/D-Programming-Language/dmd/pull/696
Comment 2 David Simcha 2012-02-05 20:13:36 UTC
Probably related test case:

struct S {
    static if(hasIndirections!(typeof(this))) {}
}

template hasIndirections(T)
{
    enum hasIndirections = hasIndirectionsImpl!(T.tupleof);
}

template hasIndirectionsImpl(T...)
{
    static if (!T.length)
    {
        enum hasIndirectionsImpl = false;
    }
    else
    {
        enum hasIndirectionsImpl = true;
    }
}
Comment 3 kennytm 2012-02-05 23:45:05 UTC
(In reply to comment #2)
> Probably related test case:
> 
> struct S {
>     static if(hasIndirections!(typeof(this))) {}
> }
> 
> template hasIndirections(T)
> {
>     enum hasIndirections = hasIndirectionsImpl!(T.tupleof);
> }
> 
> template hasIndirectionsImpl(T...)
> {
>     static if (!T.length)
>     {
>         enum hasIndirectionsImpl = false;
>     }
>     else
>     {
>         enum hasIndirectionsImpl = true;
>     }
> }

Pull #696 removed the 'no size yet for forward reference' in this test case, but DMD will complain 'template instance test.hasIndirectionsImpl!(tuple()) error instantiating' anyway.
Comment 5 Walter Bright 2012-02-06 19:38:15 UTC
This isn't a regression, it never really did work right. But the partial fix at least makes it work correctly for the original bug report.

It may not be completely fixable.
Comment 6 David Simcha 2012-02-06 19:47:50 UTC
Still broken with my test case.  Where do we draw the line between regressions and non-regressions?  2.058 has a lot of borderline cases where internal changes in the compiler make pre-existing bugs affect code they didn't used to affect.
Comment 7 David Simcha 2012-02-08 08:49:24 UTC
(In reply to comment #6)
> Still broken with my test case.  Where do we draw the line between regressions
> and non-regressions?  2.058 has a lot of borderline cases where internal
> changes in the compiler make pre-existing bugs affect code they didn't used to
> affect.

From discussion on the Phobos newsgroup, my test case shouldn't work because  X.tupleof shouldn't be defined, if X is not fully defined yet.  I'll close this bug report as fixed but start a new one requesting a decent error message so it's clearer that this is why it doesn't work.