www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - It is a bug?

reply "Kozzi11" <kozzi11 gmail.com> writes:
#main.d:

import m.f;
class A {
     //class main.A member m is not accessible
     //mixin(t!(typeof(this), "m"));
     void m() {};
     //here is ok
     //mixin(t!(typeof(this), "m"));
}
void main(string[] args){}

#m.f
module m.f;
string t(alias cls, string method)() {
     import std.traits;
     static if (isSomeFunction!(__traits(getMember, cls, method))) 
{}
     return "";
}

But when I put content from m.f into main.d everything works ok. 
Or even when I change __traits(getMember, cls, method) to cls.m 
everything works, but even with mixin it doesnt work 
(mixin("cls.m"))
Jul 30 2014
parent reply "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Wednesday, 30 July 2014 at 07:08:17 UTC, Kozzi11 wrote:
 #main.d:

 import m.f;
 class A {
     //class main.A member m is not accessible
     //mixin(t!(typeof(this), "m"));
     void m() {};
     //here is ok
     //mixin(t!(typeof(this), "m"));
 }
The compiler is trying to construct type A. The first thing it sees is a need to get the members of the class. What members are in the class? "I don't know I'm trying to mix one in right now!" That said, there may be away around it so you can search bugzilla and file an improvement to see the response.
Jul 30 2014
parent "Daniel Kozak" <kozzi11 gmail.com> writes:
On Wednesday, 30 July 2014 at 16:14:56 UTC, Jesse Phillips wrote:
 On Wednesday, 30 July 2014 at 07:08:17 UTC, Kozzi11 wrote:
 #main.d:

 import m.f;
 class A {
    //class main.A member m is not accessible
    //mixin(t!(typeof(this), "m"));
    void m() {};
    //here is ok
    //mixin(t!(typeof(this), "m"));
 }
The compiler is trying to construct type A. The first thing it sees is a need to get the members of the class. What members are in the class? "I don't know I'm trying to mix one in right now!"
Yes, this make sense. But why it is not a problem when 't' template is in the same file.
Jul 30 2014