D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2777 - alias this doesn't forward __dollar and slice op.
Summary: alias this doesn't forward __dollar and slice op.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-01 08:51 UTC by David Simcha
Modified: 2015-06-09 01:18 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2009-04-01 08:51:46 UTC
import std.stdio;
struct ArrayWrapper(T) {
    T[] array;
    alias array this;
}

void main() {
    ArrayWrapper!(uint) foo;
    foo.length = 5;  // Works
    foo[0] = 1;      // Works
    writeln(foo[0]);  // Works
    writeln(foo[$ - 1]);  // Error:  undefined identifier __dollar
    writeln(foo[0..2]);  // Error:  ArrayWrapper!(uint) cannot be sliced with []
}