digitalmars.D.learn - Compiler bug ?
- Temtaime (4/4) Jun 09 2013 Hello guys!
- Kenji Hara (25/29) Jun 09 2013 The code should be rejected. It's a compiler bug.
- Temtaime (2/2) Jun 09 2013 Oh, i see.
- Juan Manuel Cabo (23/27) Jun 09 2013 I don't know whether it's a bug, but I managed to reduce the error
- Temtaime (1/1) Jun 09 2013 Yes, it's strange. Using alias doesn't lead to this.
Hello guys! It seems that it is bug. And critical for me. http://dpaste.1azy.net/b93f5776 Regards.
Jun 09 2013
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
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
Yes, it's strange. Using alias doesn't lead to this.
Jun 09 2013