Type Inference Bug?

Meta via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 20 14:40:08 PST 2014


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).


More information about the Digitalmars-d mailing list