D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6492 - properties of alias this'd array overrides method
Summary: properties of alias this'd array overrides method
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-08-14 09:35 UTC by Trass3r
Modified: 2011-10-23 07:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Trass3r 2011-08-14 09:35:08 UTC
import std.stdio;
struct F
{
	int[] g;
	alias g this;
	
	auto ptr()
	{
		return g.ptr;
		write("ptr\n");
	}
}

void main()
{
	F a;
	auto p = a.ptr;
}

prints nothing even though ptr method should override g's .ptr
Comment 1 Kenji Hara 2011-10-23 02:32:51 UTC
This is sample-code bug.

import std.stdio;
struct F
{
    int[] g;
    alias g this;

    auto ptr()
    {
        write("ptr\n");  // print before return
        return g.ptr;
    }
}
void main()
{
    F a;
    auto p = a.ptr;
}
Comment 2 Trass3r 2011-10-23 07:07:04 UTC
How embarrassing.
Comment 3 Kenji Hara 2011-10-23 07:15:24 UTC
Never mind!