The following code triggers an error:
template Foo()
{
uint getSize()
{
return (*this).sizeof; // line 5
}
}
void main()
{
struct A1
{
mixin Foo!(); // line 13
}
}
test.d(5): struct test.main.A1 no size yet for forward reference
test.d(13): mixin test.main.A1.Foo!() error instantiating
Comment #1 by jdrewsen — 2011-07-05T00:47:13Z
Reduced test case a bit:
mixin template A() {
void foo() {}
}
void bar() {
static struct C {
mixin A!();
};
}
Comment #2 by andrej.mitrovich — 2012-12-23T11:13:18Z
(In reply to comment #1)
> Reduced test case a bit:
>
> mixin template A() {
> void foo() {}
> }
>
> void bar() {
> static struct C {
> mixin A!();
> };
> }
That works in 2.061, however OP code still doesn't work. Also it should probably use 'typeof(this).sizeof', not '(*this).sizeof' (which gives a separate error).
Comment #3 by k.hara.pg — 2013-04-06T10:52:17Z
(In reply to comment #2)
> That works in 2.061, however OP code still doesn't work.
OP code is a dup of bug 9417.
*** This issue has been marked as a duplicate of issue 9417 ***