Template bug with second mixin?

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 4 23:28:17 PST 2014


On Fri, 05 Dec 2014 07:06:34 +0000
Andre via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:

> Hi,
> 
> following coding fails to compile with 2.066.0 and
> 2.067.0-b1.
> 
> 
> This is a bug, or?
> source\app.d(9): Error: mixin 
> app.Data.insertReadMethods!("readTinyInt", ubyte)
> is not defined
> 
> template insertReadMethods(string MethodName, DataType)
> {
> 	enum insertReadMethods = "";
> }
> 
> struct Data
> {
> 	mixin insertReadMethods!("readTinyInt", ubyte);
> 	mixin insertReadMethods!("readTinyInt", ubyte);
> }
> 
> void main(){}
i.e. "mixin template" inserts it's names into the same scope, and
compiler searching symbols from innermost scope up to module scope.

here first mixin inserts 'enum' member, and searching for second mixin
hits that enum member. to avoid things going out of control compiler is
not trying to guess what you want but stops with error, giving you a
chance to fix the code.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141205/63bd87b7/attachment.sig>


More information about the Digitalmars-d-learn mailing list