[Issue 5531] Erratic type deduction with pointers and type modifiers

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 21 01:56:48 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=5531

Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
These seem to have been mostly fixed (or, at least, changed) since they were
posted.

(In reply to Michel Fortin from comment #0)
> template ap(T : int*) {
>     enum ap = 1;
> }
> 
> static assert(ap!(int*));
> static assert(ap!(const(int*))); // FIXME: should not match
> static assert(ap!(const(int)*)); // FIXME: should not match
> static assert(ap!(immutable(int*))); // FIXME: should not match
> static assert(ap!(immutable(int)*)); // FIXME: should not match
> static assert(ap!(shared(int*))); // FIXME: should not match
> static assert(ap!(shared(int)*)); // FIXME: should not match

All fixed.

> template bp(T : const(int*)) {
>     enum bp = 1;
> }
> 
> static assert(bp!(int*));
> static assert(bp!(const(int*)));
> static assert(bp!(const(int)*));
> static assert(bp!(immutable(int*)));
> static assert(bp!(immutable(int)*));
> static assert(bp!(shared(int*))); // FIXME: should not match
> static assert(bp!(shared(int)*)); // FIXME: should not match

Also fixed.

> template cp(T : const(int)*) {
>     enum cp = 1;
> }
> 
> static assert(cp!(int*));
> static assert(cp!(const(int*))); // FIXME: should not match (const ptr)
> static assert(cp!(const(int)*));
> static assert(cp!(immutable(int*))); // FIXME: should not match (immutable
> ptr)
> static assert(cp!(immutable(int)*));

Here it looks like it's intentionally allowing it to strip head const, which is
generally harmless.

> template dp(T : U*, U) {
>     alias U dp;
> }
> 
> static assert(is(dp!(int*) == int));
> static assert(is(dp!(const(int*)) == const(int))); // FIXME: should not
> match (const ptr)
> static assert(is(dp!(const(int)*) == const(int)));
> static assert(is(dp!(immutable(int*)) == immutable(int))); // FIXME: should
> not match (immutable ptr)
> static assert(is(dp!(immutable(int)*) == immutable(int)));
> 
> template fp(T : const(U)*, U) {
>     alias U fp;
> }
> 
> static assert(is(fp!(int*) == int));
> static assert(is(fp!(const(int*)) == int)); // FIXME: should not match
> (const ptr)
> static assert(is(fp!(const(int)*) == int));
> static assert(is(fp!(immutable(int*)) == int)); // FIXME: should not match
> (immutable ref)
> static assert(is(fp!(immutable(int)*) == int));

Ditto.

> static assert(cp!(shared(int*))); // FIXME: should not match
> static assert(cp!(shared(int)*)); // FIXME: should not match
> 
> static assert(is(dp!(shared(int*)) == shared(int))); // FIXME: should not
> match (shared ptr)
> static assert(is(dp!(shared(int)*) == shared(int)));
> 
> template ep(T : const(U*), U) {
>     alias U ep;
> }
> 
> static assert(!is(ep!(shared(int*)))); // no match
> static assert(!is(ep!(shared(int)*))); // no match
> 
> static assert(!is(fp!(shared(int*)))); // no match
> static assert(!is(fp!(shared(int)*))); // no match

Not sure about shared. I believe finalizing shared is still a work in progress.

In any case, if any of these are still pertinent, they need to be filed as
separate bugs. Aggregate bugs are not very actionable.

I'll close this as it looks like the situation changed quite a bit in the 6
years since this was posted. Please file any remaining problems you believe are
still pertinent today as new issues.

--


More information about the Digitalmars-d-bugs mailing list