Type Inference Bug?
Meta via Digitalmars-d
digitalmars-d at puremagic.com
Fri Nov 21 08:15:02 PST 2014
On Friday, 21 November 2014 at 07:40:31 UTC, Daniel Murphy wrote:
> 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);
> }
> }
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
in this case it's the latter, which makes me more strongly
suspect that
`is(T == shared U, U)` not working is a bug.
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?
What in the world is going on here? Note that this is from
Dpaste, so it's DMD 2.065, but I doubt there is that much
difference between 2.065 and 2.066.
More information about the Digitalmars-d
mailing list