D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6928 - alias this, immutable and common type fail in presence of fields with indirections
Summary: alias this, immutable and common type fail in presence of fields with indirec...
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-11-10 08:24 UTC by timon.gehr
Modified: 2011-11-15 21:23 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 timon.gehr 2011-11-10 08:24:28 UTC
T x;
struct S{
	T get() const {return x;}
	alias get this;
}
struct T{int* p;} // p is necessary.

immutable(S) s; 
immutable(T) t;

static assert(is(typeof(1? s:t))); // ok.
static assert(is(typeof(1? t:s))); // ok.

static assert(is(typeof(1? s:t)==typeof(1? t:s))); // fail.


void main(){
	auto x = 1? t:s; // ok.
	auto y = 1? s:t; // compile error.
}

The code should compile fine.