I think its broken or something. It looks like its trying to find __dollar in the current scope. Because this non-solution seems to work:
module opDollarTest; import std.stdio; class Foo { int[] data; this(int[] data) { this.data = data; } int opIndex(int a) { return data[a]; } @property size_t length() { return data.length; } @property size_t opDollar() { return length; } } void main() { auto foo = new Foo([1,2,3,4,5]); size_t __dollar() { return foo.opDollar(); } writeln(foo[$-1]); }