Thread overview
Compiler bug ?
Jun 09, 2013
Temtaime
Jun 09, 2013
Kenji Hara
Jun 09, 2013
Temtaime
Jun 09, 2013
Juan Manuel Cabo
Jun 09, 2013
Temtaime
June 09, 2013
Hello guys!

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

Regards.
June 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
June 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

June 09, 2013
Oh, i see.
Great thanks!
June 09, 2013
Yes, it's strange. Using alias doesn't lead to this.