possible mixin template bug?
Kenji Hara
k.hara.pg at gmail.com
Mon Sep 23 05:08:27 PDT 2013
The symbols that are introduced by mixin template never override/conflict
with the formally defined symbols.
It's a designed behavior.
Kenji Hara
2013/9/23 growler <growlercab at gmail.com>
> This compiles and runs but I think it is a bug.
> ---
> import std.stdio;
> mixin template TestMixin(T) {
> int testMixin;
> }
> struct Test {
> int testMixin;
> mixin TestMixin!Test;
> }
> void main() {
> Test t;
> t.testMixin = 10;
> writefln("%s", t);
> }
> ---
> $ ./hack
> Test(10, 0)
>
> I can also change the struct to be:
> ---
> struct Test {
> string testMixin;
> mixin TestMixin!Test;
> }
> // and the assignment in main() to
> t.testMixin = "some string";
> ---
> $ ./hack
> Test("some string", 0)
>
> so whether this is a bug or not, I think it is bad. Any thoughts?
>
> G.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130923/8549ec9d/attachment-0001.html>
More information about the Digitalmars-d
mailing list