Template Mixin Conflicts

Alice via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 6 05:21:23 PDT 2014


And just this second I found this... but it's a few months old 
and has no follow up.

http://forum.dlang.org/thread/mailman.1054.1398548687.2763.digitalmars-d-bugs@puremagic.com


On Monday, 6 October 2014 at 12:17:01 UTC, Alice wrote:
> Hi,
>
>
> I've created a template mixin which contains a struct 
> definition. The template is meant to be mixed into each module 
> - to provide a little bit of auto generated info in each module 
> - generated at compile time. As soon as I reference the symbols 
> in any context, it starts complaining about conflicts between 
> the two modules.
>
> It doesn't have to be a struct; the conflicts exist whether I 
> define a struct, class, function, or whatever... any symbol.
>
> It is valid to manually define symbols with the same name in 
> different modules, since they each exist in a different scope, 
> so why does a symbol brought in by a mixin conflict?
>
> Even defining the struct as private doesn't help. Any ideas 
> would be most appreciated.
>
>
> Here's a very simple failing case:
>
>
> // ModuleA.d
> module ModuleA;
>
> import ModuleB;
>
> mixin MixinUsefulStuff;
>
> pragma(msg, "a = ", SomeData.a); // Error: 
> ModuleB.MixinUsefulStuff!().SomeData at ModuleB.d(5) conflicts 
> with ModuleA.MixinUsefulStuff!().SomeData at ModuleB.d(5)
>
>
> // ModuleB.d
> module ModuleB;
>
> mixin template MixinUsefulStuff()
> {
> 	struct SomeData
> 	{
> 		enum a = 123;
> 	}
> }
>
> mixin MixinUsefulStuff;



More information about the Digitalmars-d-learn mailing list