D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6939 - wrong type qualifier combination
Summary: wrong type qualifier combination
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: accepts-invalid, patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-11-12 10:54 UTC by timon.gehr
Modified: 2011-12-20 13:02 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-12 10:54:30 UTC
Tested with DMD 2.056

shared    int* x;
immutable int* y;
const     int* z;

static assert(is(typeof(1?x:y)  == shared(const(int))*)); // fail.
static assert(!is(typeof(1?x:y) == const(int)*));         // fail.

static assert(is(typeof(1?x:z)  == shared(const(int))*)); // fail.
static assert(!is(typeof(1?x:z) == const(int)*));         // fail.


All static assertions should pass.
Comment 1 timon.gehr 2011-11-12 11:50:15 UTC
Oops.

Obviously x and z should not have a common type at all.
So the third static assertion should not pass. (it currently fails for the wrong reason though).

Replace the test with this:

shared    int* x;
immutable int* y;
const     int* z;

static assert(is(typeof(1?x:y)  == shared(const(int))*));  // fail
static assert(!is(typeof(1?x:y) == const(int)*));          // fail
static assert(!is(typeof(1?x:z)));                         // fail

shared    int[] a;
immutable int[] b;
const     int[] c;

static assert(is(typeof(1?a:b)  == shared(const(int))[])); // pass (ok)
static assert(!is(typeof(1?a:b) == const(int)[]));         // pass (ok)
static assert(!is(typeof(1?x:z)));                         // fail

All of these should pass.
Comment 2 timon.gehr 2011-11-12 11:54:47 UTC
...

static assert(!is(typeof(1?a:c)));                         // fail
Comment 3 timon.gehr 2011-11-12 12:02:03 UTC
inout is buggy too: inout and shared are combined to shared const.

inout(int[]) foo(inout int[] x, shared int[] y, inout int* a, shared int* b){
	static assert(!is(typeof(1?x:y))); // fail
	static assert(!is(typeof(1?a:b))); // fail
	return x;
}

Both assertions should pass.