Bug 7758 – Mixin error: No size yet for forward reference

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-23T21:06:00Z
Last change time
2013-11-22T00:13:38Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-03-23T21:06:20Z
string Test(alias member)() { return ""; } struct S { int i; mixin(Test!i()); } void main() { } test.d(9): Error: struct test.S no size yet for forward reference test.d(10): called from here: Test() test.d(10): Error: argument to mixin must be a string, not (Test()) If I use a mixin template instead it can work: mixin template Test(alias member) { typeof(member) x; } struct S { int i; mixin Test!i; } void main() { } And yet if I try to use mixin() inside of a mixin template it doesn't work: string test(alias member)() { return ""; } mixin template Test(alias member) { mixin(test!member()); } struct S { int i; mixin Test!i; } void main() { } test.d(10): Error: struct test.S no size yet for forward reference test.d(6): called from here: test() test.d(6): Error: argument to mixin must be a string, not (test()) test.d(12): Error: mixin test.S.Test!(i) error instantiating
Comment #1 by ellery-newcomer — 2012-08-28T16:43:36Z
I got it to trip with mixin templates: dmd code.d xobject.d descrobject.d xobject.d(6): Error: struct xobject.Foo no size yet for forward reference // code.d import xobject; // xobject.d import descrobject; template VAR_HEAD() { } struct Foo { mixin VAR_HEAD!(); } // descrobject.d import xobject; __gshared Foo foo;
Comment #2 by k.hara.pg — 2013-11-22T00:13:38Z
With 2.064, the code: string test(alias member)() { return ""; } struct S { int i; mixin(test!i()); } Prints: test.d(1): Error: function test.S.test!(i).test need 'this' to access member test test.d(5): called from here: test() --- This exactly is same behavior with: struct S { string foo() { return ""; } mixin(foo()); // call member function 'foo' without valid 'this' } Prints: test.d(3): Error: function test.S.foo need 'this' to access member foo test.d(4): called from here: foo() --- Therefore the original issue is already fixed.