--- code
struct MyString
{
private string value;
mixin Proxy!value;
this(string s){ value = s; }
}
// Test BUG #
MyString a = MyString("a");
MyString b = MyString("b");
MyString a1 = MyString("a");
assert(a == a);
assert(a == a1);
assert(a != b);
---
--- compile
$ dmd testproxy.d
../src/phobos/std/typecons.d(2658): Error: undefined identifier 'startsWith'
testproxy.d(16): Error: template instance testproxy.main.MyString.Proxy!(value).opEquals!(MyString) error instantiating
---
If the test code placed in typecons.d, it's ok.
If place it in another file, compiles error. Bug if add 'import std.algorithm', compiles passed, why it depends user's context?
Seems it is a DMD's bug?
Comment #1 by issues.dlang — 2012-09-04T01:16:44Z
It works in std.typecons, because std.typecons imports std.algorithm. Your module doesn't, and you're mixing Proxy into your module, so it needs to import std.algorithm. This is _not_ a compiler bug.
Now that we have local imports, Proxy can have the import for std.algorithm internally, so that should probably be added. But previously, there was no way to have Proxy import what it needed, and you'd have to import it in whatever module you mixed it into. But fortunately, that's now fixable.