Bug 6939 – wrong type qualifier combination

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-11-12T10:54:00Z
Last change time
2011-12-20T13:02:38Z
Keywords
accepts-invalid, patch, rejects-valid
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2011-11-12T10:54:30Z
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 by timon.gehr — 2011-11-12T11:50:15Z
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 by timon.gehr — 2011-11-12T11:54:47Z
... static assert(!is(typeof(1?a:c))); // fail
Comment #3 by timon.gehr — 2011-11-12T12:02:03Z
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.
Comment #4 by k.hara.pg — 2011-12-19T07:11:08Z
Comment #5 by bugzilla — 2011-12-20T13:02:38Z