Thread overview | |||||
---|---|---|---|---|---|
|
September 23, 2013 possible mixin template bug? | ||||
---|---|---|---|---|
| ||||
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. |
September 23, 2013 Re: possible mixin template bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to growler Attachments:
| 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@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.
>
|
September 23, 2013 Re: possible mixin template bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | On Monday, 23 September 2013 at 12:08:37 UTC, Kenji Hara wrote:
> The symbols that are introduced by mixin template never override/conflict
> with the formally defined symbols.
> It's a designed behavior.
>
> Kenji Hara
>
>
Thanks Kenji for the information. I guess I'd better go back and read the docs again...and scurry off back to D.learn :D
G.
|
Copyright © 1999-2021 by the D Language Foundation