| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
September 15, 2011 Possible bug with mixin and __traits(allMembers,T) | ||||
|---|---|---|---|---|
| ||||
The following program
mixin template Members(){
static int i1;
static int i2;
static int i3; //comment out to make func2 visible
static int i4; //comment out to make func1 visible
}
class Test {
mixin Members;
typedef void function() func1;
typedef bool function() func2;
static void init(){
foreach(m;__traits(allMembers,Test)){
pragma(msg,m);
}
}
}
int main(string[] argv)
{
return 0;
}
Gives me the output:
i1
i2
i3
i4
toString
toHash
opCmp
opEquals
Monitor
factory
If I comment out i4:
i1
i2
i3
func1
toString
...
And if I comment out i3 in addition to i4:
i1
i2
func1
func2
toString
...
Is this some new feature of mixin I'm missing, oder is this a bug?
Started to happen in dmd 2.055 does not happen with dmd 2.054
--
Kind Regards
Benjamin Thaut
| ||||
September 15, 2011 Re: Possible bug with mixin and __traits(allMembers,T) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | On 15/09/2011 06:56, Benjamin Thaut wrote:
> The following program
>
> mixin template Members(){
> static int i1;
> static int i2;
> static int i3; //comment out to make func2 visible
> static int i4; //comment out to make func1 visible
> }
>
> class Test {
> mixin Members;
>
> typedef void function() func1;
> typedef bool function() func2;
>
> static void init(){
> foreach(m;__traits(allMembers,Test)){
> pragma(msg,m);
> }
> }
> }
>
> int main(string[] argv)
> {
> return 0;
> }
>
> Gives me the output:
> i1
> i2
> i3
> i4
> toString
> toHash
> opCmp
> opEquals
> Monitor
> factory
>
> If I comment out i4:
> i1
> i2
> i3
> func1
> toString
> ...
>
> And if I comment out i3 in addition to i4:
> i1
> i2
> func1
> func2
> toString
> ...
>
> Is this some new feature of mixin I'm missing, oder is this a bug?
> Started to happen in dmd 2.055 does not happen with dmd 2.054
>
Moving the mixin to between the typedefs has the same effect as commenting out i4 (only the order of the members is different). Moving the mixin to after both typedefs has the same effect as commenting out both i3 and i4 (modulo change of order). I think that shows that it is definitely a bug and not a feature!
A...
| |||
September 15, 2011 Re: Possible bug with mixin and __traits(allMembers,T) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Alix Pexton | 2011/9/15 Alix Pexton <alix.DOT.pexton@gmail.dot.com>: > On 15/09/2011 06:56, Benjamin Thaut wrote: >> >> The following program >> >> mixin template Members(){ >> static int i1; >> static int i2; >> static int i3; //comment out to make func2 visible >> static int i4; //comment out to make func1 visible >> } >> >> class Test { >> mixin Members; >> >> typedef void function() func1; >> typedef bool function() func2; >> >> static void init(){ >> foreach(m;__traits(allMembers,Test)){ >> pragma(msg,m); >> } >> } >> } >> >> int main(string[] argv) >> { >> return 0; >> } >> >> Gives me the output: >> i1 >> i2 >> i3 >> i4 >> toString >> toHash >> opCmp >> opEquals >> Monitor >> factory >> >> If I comment out i4: >> i1 >> i2 >> i3 >> func1 >> toString >> ... >> >> And if I comment out i3 in addition to i4: >> i1 >> i2 >> func1 >> func2 >> toString >> ... >> >> Is this some new feature of mixin I'm missing, oder is this a bug? Started to happen in dmd 2.055 does not happen with dmd 2.054 >> > > Moving the mixin to between the typedefs has the same effect as commenting out i4 (only the order of the members is different). Moving the mixin to after both typedefs has the same effect as commenting out both i3 and i4 (modulo change of order). I think that shows that it is definitely a bug and not a feature! It is regression of fixing issue 2234 (http://d.puremagic.com/issues/show_bug.cgi?id=2234). I'll post pull request to fix it. Kenji Hara | |||
September 15, 2011 Re: Possible bug with mixin and __traits(allMembers,T) | ||||
|---|---|---|---|---|
| ||||
2011/9/15 kenji hara <k.hara.pg@gmail.com>: > It is regression of fixing issue 2234 > (http://d.puremagic.com/issues/show_bug.cgi?id=2234). > I'll post pull request to fix it. I filed this issue into (bugzilla http://d.puremagic.com/issues/show_bug.cgi?id=6674), and posted pull request. Thanks for your reporting, Benjamin Thaut. Kenji Hara | ||||
September 15, 2011 Re: Possible bug with mixin and __traits(allMembers,T) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to kenji hara | Thank you for fixing it that quickly ;-) Kind Regards Benjamin Thaut | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply