www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Compiler bug ?

reply "Temtaime" <temtaime gmail.com> writes:
Hello guys!

It seems that it is bug. And critical for me.
http://dpaste.1azy.net/b93f5776

Regards.
Jun 09 2013
next sibling parent reply "Kenji Hara" <k.hara.pg gmail.com> writes:
On Sunday, 9 June 2013 at 13:37:45 UTC, Temtaime wrote:
 Hello guys!

 It seems that it is bug. And critical for me.
 http://dpaste.1azy.net/b93f5776

 Regards.
The code should be rejected. It's a compiler bug. But, you can do what you want as follows. import std.stdio, std.typetuple; struct A { ("1") int a; ("2") int b; ("3") int c; } auto bar(alias expr)() property { writeln(expr); } void main() { A a; foreach(it; __traits(allMembers, A)) { enum tp = [__traits(getAttributes, mixin(`a.` ~ it))]; // or alias tp = TypeTuple!(__traits(getAttributes, mixin(`a.` ~ it))); writeln(`passing: `, tp[0]); bar!(tp[0])(); } } Kenji Hara
Jun 09 2013
parent "Temtaime" <temtaime gmail.com> writes:
Oh, i see.
Great thanks!
Jun 09 2013
prev sibling parent reply "Juan Manuel Cabo" <juanmanuel.cabo gmail.com> writes:
On Sunday, 9 June 2013 at 13:37:45 UTC, Temtaime wrote:
 Hello guys!

 It seems that it is bug. And critical for me.
 http://dpaste.1azy.net/b93f5776

 Regards.
I don't know whether it's a bug, but I managed to reduce the error to the following code (removing __traits code): import std.stdio; import std.typetuple; void bar(alias expr)() { writeln(expr); } void main() { foreach(it; TypeTuple!("a","b","c")) { auto tp = TypeTuple!(it); bar!(tp[0])(); writeln(`should be: `, tp[0]); } } This prints: a should be: a a should be: b a should be: c --jm
Jun 09 2013
parent "Temtaime" <temtaime gmail.com> writes:
Yes, it's strange. Using alias doesn't lead to this.
Jun 09 2013