Thread overview
[Bug 106] New: template - mixin sequence
Apr 14, 2006
d-bugmail
Apr 18, 2006
Thomas Kuehne
Apr 18, 2006
d-bugmail
April 14, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=106

           Summary: template - mixin sequence
           Product: D
           Version: 0.150
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: benoit@tionex.de


for a mixin it is important where the template is declared.

mixin T!(int);
template T(t){
 t a;
}

does not work. Error: mixin forward reference to template.

In one module this is no problem. I can modify the sequence.
The problem comes, if the template and the mixin are in different modules.

I added "import A" to my file "B", and _suddenly_ the compile fails in module
"C" with the "forward refer..." message.
In module "C" i also have an "import A" and there I use mixins with
templates out of A.

I changed the source file order in the dmd command line and it compiles. So it seems to me, it is the sequence of template declaration and mixin which depends on the order of the source files.

Solution should be to drop the dependency to the sequence template declaration and mixin.

My project relies very strong on the mixin feature. :( Please give this bug a high priority.


-- 

April 18, 2006
d-bugmail@puremagic.com schrieb am 2006-04-14:
> for a mixin it is important where the template is declared.
>
> mixin T!(int);
> template T(t){
>  t a;
> }
>
> does not work. Error: mixin forward reference to template.
>
> In one module this is no problem. I can modify the sequence.
> The problem comes, if the template and the mixin are in different modules.
>
> I added "import A" to my file "B", and _suddenly_ the compile fails in module
> "C" with the "forward refer..." message.
> In module "C" i also have an "import A" and there I use mixins with
> templates out of A.
>
> I changed the source file order in the dmd command line and it compiles. So it seems to me, it is the sequence of template declaration and mixin which depends on the order of the source files.
>
> Solution should be to drop the dependency to the sequence template declaration and mixin.

Added to DStress as http://dstress.kuehne.cn/compile/f/forward_reference_13_E.d

Thomas


April 18, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=106


benoit@tionex.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |blocker




------- Comment #2 from benoit@tionex.de  2006-04-18 13:14 -------
The workaround "changing the source file order" does not always help.
I changed the file order manually and dmd fails also.
In the moment I cannot compile code, that is compilable in another file
constellation.

my actual situation: FileA uses mixins from FileB. I put FileB as the first file in the source file list, FileA as last.

-v output is:
it passes all files with "parse". Than the first file with "semantic" is FileB,
but it failes here with:
..FileA(..): mixin forward reference to template

I repeat, FileA+FileB do compile if they are part of another build process.

So I think this should be marked as "blocker".


--