Type Inference Bug?

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 11:19:23 PST 2014


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

> Now how about this one:
>
> alias Unshared(T: shared U, U) = U;
> pragma(msg, Unshared!(shared const int)); //Prints const(int)
>
> Does the `:` denote subtyping as well, or equality? I'm sure that

Neither.  IIRC it's something close to type implicit conversion rules.

alias A(T : long) = T;
pragma(msg, A!int);

> in this case it's the latter, which makes me more strongly suspect that
> `is(T == shared U, U)` not working is a bug.

Probably.  It looks like that matches only shared(U) and not 
const(shared(U)), so it could be intentional that it means exactly shared. 
I would guess it's an oversight.

> Furthermore, I'm starting to get very confused:
>
> enum sameTypes(T, U) = is(T: U) && is(U: T);
>
> assert(sameTypes!(const int, immutable int)); //Ok, wtf?
> assert(sameTypes!(int, immutable int); //Ok, wtf?

All of those types implicitly convert to each other.



More information about the Digitalmars-d mailing list