Type Inference Bug?

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 20 23:40:34 PST 2014


"Meta"  wrote in message news:wzczhiwokauvkkevtdxr at forum.dlang.org...

> shared const int i;
>
> static if (is(typeof(i) T == shared U, U))
> {
>      //Prints "shared(const(int))"
>      pragma(msg, U);
> }
>
> This seems like subtly wrong behaviour to me. If T == shared U, for some 
> U, then shouldn't U be unshared? If T is shared(const(int)), and T is the 
> same as the type U with the 'shared' qualifier applied to it, then U 
> should be of type const(int), not shared(const(int)).
>
> I'm bringing this up partially because it seems wrong to me, and partially 
> because we currently don't have a good why of "shaving" the outermost 
> qualifier off a type, and this seemed the natural way to do it to me (I 
> was surprised when it didn't work).

It doesn't print anything for me.  This code seems to have the desired 
effect:

shared const int i;

void main()
{
    static if (is(typeof(i) : shared(U), U))
    {
         //Prints "const(int)"
         pragma(msg, U);
    }
} 



More information about the Digitalmars-d mailing list