www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7758] New: Mixin error: No size yet for forward reference

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7758

           Summary: Mixin error: No size yet for forward reference
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



21:06:20 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 23 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7758


Ellery Newcomer <ellery-newcomer utulsa.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ellery-newcomer utulsa.edu



16:43:36 PDT ---
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;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2012