mixin module template -> undefined identifier

Robert Schadek realburner at gmx.de
Thu Oct 3 11:39:38 PDT 2013


On 10/03/2013 08:10 PM, David Nadlinger wrote:
> On Thursday, 3 October 2013 at 17:52:13 UTC, Robert Schadek wrote:
>>
>> dmd moduleA.d moduleB.d -ofmix -unittest
>> moduleA.d(4): Error: undefined identifier Foo
>> moduleB.d(10): Error: template instance A.func!(Foo) error instantiating
>
> Yes, this is indeed very much by design – A does not import B, so
> there is no reason why the name "Foo" should exist in A.
Yes, it does not exists in the module but func is a template and I was
under the impression symbols would be seen when instantiated. I mean the
error starts with A.func!(Foo) error instantiating.
>
> To access the template parameter, just use it directly in the mixin
> (as in »mixin("T.fun()")«). I'm aware that the situation where you
> actually stumbled over this is probably a bit more complex, but in my
> experience an equivalent rewrite can almost always be performed quite
> easily once you have wrapped your head around the concept.
Not as easy to fix this as I have a library that generates me sqlite
code at compile time which I than mixin to have as good as handwritten
code. I just found it odd that it works if I instantiate the template
from the same module.




More information about the Digitalmars-d mailing list