D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6837 - alias this + UFCS = fail
Summary: alias this + UFCS = fail
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-10-21 07:30 UTC by Kenji Hara
Modified: 2011-11-16 09:35 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 Kenji Hara 2011-10-21 07:30:55 UTC
struct Ref1(T)
{
    T storage;
    alias storage this;
}

struct Ref2(T)
{
    T storage;
    @property ref T get(){ return storage; }
    alias get this;
}

int front(int[] arr){ return arr[0]; }

void popFront(ref int[] arr){ arr = arr[1..$]; }

void main()
{
    assert([1,2,3].front == 1);

    auto r1 = Ref1!(int[])([1,2,3]);
//  assert(r1.front() == 1);    // ng
    assert(r1.front == 1);      // ok
//  r1.popFront();              // ng
    r1.storage.popFront();      // ok

    auto r2 = Ref2!(int[])([1,2,3]);
//  assert(r2.front() == 1);    // ng
    assert(r2.front == 1);      // ok
//  r2.popFront();              // ng
//  r2.get.popFront();          // ng
    r2.get().popFront();        // ok
}