www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 106] New: template - mixin sequence

reply d-bugmail puremagic.com writes:
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.


-- 
Apr 14 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 -----BEGIN PGP SIGNATURE----- iD8DBQFERJGB3w+/yD4P9tIRAvQLAKCZlMeVCuB2WGV975S0pfioob051ACfTKWi 3gBu7yGjWtVeFKhflqz73GQ= =LV2Z -----END PGP SIGNATURE-----
Apr 17 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=106


benoit tionex.de changed:

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





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".


-- 
Apr 18 2006