Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
June 09, 2013 Compiler bug ? | ||||
---|---|---|---|---|
| ||||
Hello guys! It seems that it is bug. And critical for me. http://dpaste.1azy.net/b93f5776 Regards. |
June 09, 2013 Re: Compiler bug ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | 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 |
June 09, 2013 Re: Compiler bug ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Temtaime | 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
|
June 09, 2013 Re: Compiler bug ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | Oh, i see. Great thanks! |
June 09, 2013 Re: Compiler bug ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juan Manuel Cabo | Yes, it's strange. Using alias doesn't lead to this. |
Copyright © 1999-2021 by the D Language Foundation