Hey, try this code (tested under dmd 2.066.1 win32):
module test;
struct Container( T ) {
private:
T[] array;
public:
int opApply( int delegate( ref T ) func ) {
return 0;
}
}
class C {
}
class D {
mixin( {
foreach( memberName; __traits( allMembers, typeof( this ) ) ) {
static if( __traits( compiles, __traits( getOverloads, typeof( this ), memberName )[ 0 ] ) ) {
} }
return "";
} () );
Container!C cont_;
void asd() {
foreach( l; cont_ ) {
}
}
}
void main() {
}
It gives me quite weird linker error:
Error 42: Symbol Undefined _D4test23__T9ContainerTC4test1CZ9Container7opApplyMFNaNbNiNfDFKC4test1CZiZi
This seems to be minimal test case.
Comment #1 by czdanol — 2014-11-15T00:34:12Z
Sorry, this seems to be the minimal test case:
module x;
struct A( T ) { void a() {} }
class B {}
class C {
enum a = {
static if( __traits( compiles, __traits( getMember, typeof( this ), "b" ) ) ) {}
return 0;
};
// Surprisingly, this has to be after that enum
A!B b;
void asd() { b.a(); }
}
void main() {
}
Oh and yeah, test via rdmd or under RELEASE
Comment #2 by k.hara.pg — 2014-11-16T10:37:12Z
(In reply to Daniel Čejchan from comment #1)
> Sorry, this seems to be the minimal test case:
This is only in 2.066.1 release branch. In master branch, it is fortunately fixed by the change for issue 13226.
https://github.com/D-Programming-Language/dmd/pull/3841