D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3015 - Lookup of non-member not working
Summary: Lookup of non-member not working
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-05-20 20:24 UTC by Andrei Alexandrescu
Modified: 2015-06-09 01:27 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2009-05-20 20:24:15 UTC
This code doesn't compile:

struct R
{
    bool empty();
    ref int front();
    void popFront();
}

ref int popNext(ref R fwdRange)
{
    auto result = & fwdRange.front();
    fwdRange.popFront;
    return *result;
}

void main()
{
    R r;
    int x = r.popNext;
}

The code should work: popNext should be looked up in R's outer scope if not a member.
Comment 1 Gide Nwawudu 2009-05-21 10:00:14 UTC
Added keyword, error message is as follows.

C:> dmd test.d
test.d(18): Error: no property 'popNext' for type 'R'
Comment 2 Georg Wrede 2009-05-21 17:39:39 UTC
Invisible first paramter? Not with a one-parameter function?
Comment 3 Andrej Mitrovic 2012-10-28 11:51:15 UTC
Seems to work now.