D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7945 - alias this doesn't work on function ref parameter
Summary: alias this doesn't work on function ref parameter
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: pull, rejects-valid
: 7991 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-04-19 06:36 UTC by Kenji Hara
Modified: 2012-05-20 23:46 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2012-04-19 06:36:22 UTC
The four calls should work, but #1 doesn't work.

struct S
{
    int v;
    alias v this;
}
void foo(ref int n){}

void main()
{
    auto s = S(1);
    // variable s is lvalue, so
    // alias this expanded expression s.v is also lvalue and matches to ref.

    foo(s);         // 1.NG -> OK
    s.foo();        // 2.OK, ufcs
    foo(s.v);       // 3.OK
    s.v.foo();      // 4.OK, ufcs
}
Comment 2 github-bugzilla 2012-04-19 14:14:42 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ec6a33778767db278613b058641c849ea7625b43
fix Issue 7945 - alias this doesn't work on function ref parameter
Comment 3 Kenji Hara 2012-05-20 23:46:01 UTC
*** Issue 7991 has been marked as a duplicate of this issue. ***